29 if (index >=
values.size())
41 for (
unsigned int i=0; i<other.
getLength(); i++)
43 std::vector<std::string> item ;
44 if (other.
getItem(i, item) && item.size() > 1)
45 add(item[0], item[1]);
51 for (
unsigned int i=0; i<
values.size(); i++)
54 for (
unsigned int j=1; j<
values[i].size(); j++)
72 for (
unsigned int i=0; i<
values.size(); i++)
73 if (
values[i].size() > 0 && strcasecmp(
values[i][0].c_str(), str.c_str()) == 0)
84 for (
unsigned int i=0; i<
values.size(); i++)
85 if (strcasecmp(
values[i][0].c_str(), str.c_str()) == 0)
100 return atoi(
values[
id][1].c_str());
110 return atof(
values[
id][1].c_str());
140 std::vector<unsigned int> ids;
143 for (
unsigned int i=0;i<ids.size();i++)
144 result.push_back(
values[ids[i]][1]);
155 return strcasecmp(
values[
id][1].c_str(),
"true") == 0;
164 if (
id >= 0 && replace)
172 std::vector<std::string> newItem;
173 newItem.push_back(n);
174 newItem.push_back(v);
176 values.push_back(newItem);
188 result = (int) atof(
values[
id][1].c_str());
205 result = atof(
values[
id][1].c_str());
240 std::vector<std::string> tokens;
248 for (
unsigned int i=0; i<tokens.size(); i++)
254 p.SetExpr(tokens[i]);
255 double value = p.Eval();
260 catch (Parser::exception_type &e)
264 if (i+1 < tokens.size())
265 result += tokens[i] +
" ";
279 result = strcasecmp(
values[
id][1].c_str(),
"true") == 0;
286 char buffer[1024], buffer2[1024], buffer3[1024];
287 sprintf(buffer,
"%s", input.c_str());
293 while (start != NULL && *start !=
'\0')
297 bool replaced =
false;
300 while (end != NULL && *end !=
'\0')
305 sprintf(buffer3,
"%s", start);
308 sprintf(buffer3,
"%s",
getString(buffer3).c_str());
310 sprintf(buffer3,
"%s", buffer3);
313 sprintf(buffer2,
"%s", end);
316 sprintf(start,
"%s%s", buffer3, buffer2);
352 for (
unsigned int i=0; i<
values.size(); i++)
353 for (
unsigned int j=1; j<
values[i].size(); j++)
361 std::vector<TiXmlElement*> result;
363 for (
unsigned int i=0; i<result.size(); i++)
365 std::string name, value;
376 add(name, value,
true);
void strtokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters)
double parseMathExprRandomInteger(double first, double second)
std::string printToString(const char *format,...)
bool getFloatValue(std::string str, float &result)
double parseMathExprRandomDouble01()
void copyFrom(DataPairs &other)
Copies all Attribute-Value pairs.
bool getItem(unsigned int index, std::vector< std::string > &item)
int getInt(std::string str, int defaultValue=0)
static const char * getAttributeString(TiXmlElement *node, const char *str, const char *def="")
int getIndex(std::string attr, std::vector< unsigned int > &ids)
Retrieves all indexes of Attribute-Value pairs with Attribute name equal to attr. ...
bool getBoolValue(std::string str, bool &result)
std::string getString(std::string str, std::string defaultValue="")
void resolveString(std::string input, std::string &output)
Data Storage Class (Attribute-Value Pairs)
int getFirstIndex(std::string str)
void clear()
Clears storage buffer.
bool getBool(std::string str, bool defaultValue=false)
std::string parseMathExpr(std::string output)
#define LOG_VERBOSE(format,...)
void getStrings(std::string str, std::vector< std::string > &result)
Retrieves all Attribute-Value pairs with Attribute name equal to attr.
bool getStringValue(std::string str, std::string &result)
void findNodes(const char *name, std::vector< TiXmlElement * > &result, TiXmlElement *start, unsigned int level)
void print()
Prints all Attribute-Value pairs.
float getFloat(std::string str, float defaultValue=0.0)
bool getIntValue(std::string str, int &result)
void setMaxSize(unsigned int size)
Sets number of storable items to size.
std::vector< std::vector< std::string > > values
Attribute Names and Values.
Configuration file wrapper.
void loadFromXml(CConfiguration &config, TiXmlElement *node, DataPairs *replace=NULL)
unsigned int getLength()
Returns Number of pairs stored.
void add(std::string attribute, std::string value, bool replace=false)
Adds the attribute-value pair attribute, value.