本文整理汇总了C++中KeyValue::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyValue::insert方法的具体用法?C++ KeyValue::insert怎么用?C++ KeyValue::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyValue
的用法示例。
在下文中一共展示了KeyValue::insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KeyValue
KeyValue *KeyValueParser::parse() {
KeyValueParser::Token t = getNextToken( dat, &offset, max );
unsigned int i = 0;
if (t.type == KeyValueParser::INTEGER) {
return new KeyValue( KeyValue::INTEGER, t.value );
} else if (t.type == KeyValueParser::FLOAT) {
return new KeyValue( KeyValue::FLOAT, t.value );
} else if (t.type == KeyValueParser::STRING) {
return new KeyValue( KeyValue::STRING, t.value );
} else if (t.type == KeyValueParser::OBJSTART) {
KeyValue *map = new KeyValue( KeyValue::MAP );
while (true) {
KeyValueParser::Token t_expect = getNextTokenProtected( dat, &offset, max );
if (t_expect.type == KeyValueParser::VARIABLE) {
KeyValueParser::Token variable = getNextToken( dat, &offset, max );
KeyValueParser::Token eq = getNextToken( dat, &offset, max );
if (eq.type != KeyValueParser::SETOP) {
printf("Error?");
exit(1);
}
map->insert(variable.value, parse());
} else {
char *key = new char[50];
sprintf(key, "%u", i);
map->insert(std::string(key), parse());
delete key;
i++;
}
KeyValueParser::Token end = getNextToken( dat, &offset, max );
if (end.type == KeyValueParser::COMMA) {
continue;
} else if (end.type == KeyValueParser::OBJEND) {
break;
}
printf("Error?");
throw(1);
}
return map;
}
printf("Error?");
throw(1);
}
示例2: evaluate
bool PathTemplate::evaluate(const Path& otherPath, KeyValue& parameters) const {
parameters.clear();
if (path.size() != otherPath.size()) {
return false;
}
for (size_t i = 0; i < path.size(); ++i) {
if (isPathSegmentVariable[i]) {
parameters.insert(std::make_pair(path[i], otherPath[i]));
} else {
if (path[i] != otherPath[i]) {
parameters.clear();
return false;
}
}
}
return true;
}