/*======================================================================*/ void addParameter(Parameter theArrayPosition[], Parameter *theParameter) { if (theArrayPosition == NULL) syserr("Adding to null parameter array"); if (isEndOfArray(&theArrayPosition[0])) clearParameter(&theArrayPosition[0], NULL); copyParameter(&theArrayPosition[0], theParameter); setEndOfArray(&theArrayPosition[1]); }
void AIMessage::setLong(unsigned int index, long value) { GP_ASSERT(index < _parameterCount); clearParameter(index); _parameters[index].longValue = value; _parameters[index].type = AIMessage::LONG; }
void AIMessage::setFloat(unsigned int index, float value) { GP_ASSERT(index < _parameterCount); clearParameter(index); _parameters[index].floatValue = value; _parameters[index].type = AIMessage::FLOAT; }
void AIMessage::setInt(unsigned int index, int value) { GP_ASSERT(index < _parameterCount); clearParameter(index); _parameters[index].intValue = value; _parameters[index].type = AIMessage::INTEGER; }
void AIMessage::setBoolean(unsigned int index, bool value) { GP_ASSERT(index < _parameterCount); clearParameter(index); _parameters[index].boolValue = value; _parameters[index].type = AIMessage::BOOLEAN; }
void AIMessage::setDouble(unsigned int index, double value) { GP_ASSERT(index < _parameterCount); clearParameter(index); _parameters[index].doubleValue = value; _parameters[index].type = AIMessage::DOUBLE; }
void AIMessage::setString(unsigned int index, const char* value) { GP_ASSERT(index < _parameterCount); GP_ASSERT(value); clearParameter(index); // Copy the string into our parameter size_t len = strlen(value); char* buffer = new char[len + 1]; strcpy(buffer, value); _parameters[index].stringValue = buffer; _parameters[index].type = AIMessage::STRING; }
void GNEDemandElement::setGenericParametersStr(const std::string& value) { // clear parameters clearParameter(); // separate value in a vector of string using | as separator std::vector<std::string> parsedValues; StringTokenizer stValues(value, "|", true); while (stValues.hasNext()) { parsedValues.push_back(stValues.next()); } // check that parsed values (A=B)can be parsed in generic parameters for (auto i : parsedValues) { std::vector<std::string> parsedParameters; StringTokenizer stParam(i, "=", true); while (stParam.hasNext()) { parsedParameters.push_back(stParam.next()); } // Check that parsed parameters are exactly two and contains valid chracters if (parsedParameters.size() == 2 && SUMOXMLDefinitions::isValidGenericParameterKey(parsedParameters.front()) && SUMOXMLDefinitions::isValidGenericParameterValue(parsedParameters.back())) { setParameter(parsedParameters.front(), parsedParameters.back()); } } }
/*======================================================================*/ void clearParameterArray(Parameter theArray[]) { clearParameter(&theArray[0], theArray[0].candidates); setEndOfArray(theArray); }