本文整理汇总了C++中yaml::Iterator类的典型用法代码示例。如果您正苦于以下问题:C++ Iterator类的具体用法?C++ Iterator怎么用?C++ Iterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Iterator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ReadFn
Program::Program(const YAML::Node& fns) {
for (YAML::Iterator it = fns.begin(); it != fns.end(); ++it) {
std::string name;
it.first() >> name;
ReadFn(name, it.second());
}
}
开发者ID:jbeder,项目名称:fractran,代码行数:7,代码来源:program.cpp
示例2: load
/**
* Loads a ruleset's contents from a YAML file.
* @param filename YAML filename.
*/
void Ruleset::load(const std::string &filename)
{
std::string s = Options::getDataFolder() + "Ruleset/" + filename + ".rul";
std::ifstream fin(s.c_str());
if (!fin)
{
throw Exception("Failed to load ruleset");
}
YAML::Parser parser(fin);
YAML::Node doc;
parser.GetNextDocument(doc);
for (YAML::Iterator i = doc.begin(); i != doc.end(); ++i)
{
std::string key;
i.first() >> key;
if (key == "countries")
{
for (YAML::Iterator j = i.second().begin(); j != i.second().end(); ++j)
{
std::string type;
j.second()["type"] >> type;
RuleCountry *rule;
if (_countries.find(type) != _countries.end())
{
rule = _countries[type];
}
else
{
rule = new RuleCountry(type);
_countries[type] = rule;
_countriesIndex.push_back(type);
}
rule->load(j.second());
}
}
else if (key == "regions")
{
for (YAML::Iterator j = i.second().begin(); j != i.second().end(); ++j)
{
std::string type;
j.second()["type"] >> type;
RuleRegion *rule;
if (_regions.find(type) != _regions.end())
{
rule = _regions[type];
}
else
{
rule = new RuleRegion(type);
_regions[type] = rule;
_regionsIndex.push_back(type);
}
rule->load(j.second());
}
}
else if (key == "facilities")
开发者ID:ben0x539,项目名称:OpenXcom,代码行数:61,代码来源:Ruleset.cpp
示例3: get_worker_types
worker_types_t context::get_worker_types() const {
worker_types_t worker_types;
if( application_configuration_.count( "configuration-file" ) ) {
std::fstream stream( application_configuration_["configuration-file"].as<string>().c_str() );
YAML::Parser parser( stream );
YAML::Node doc;
parser.GetNextDocument( doc );
YAML::Iterator it = doc.begin();
it.second() >> worker_types;
}
开发者ID:murphybytes,项目名称:kibitz,代码行数:10,代码来源:context.cpp
示例4: load
void ExtraSprites::load(const YAML::Node &node)
{
for (YAML::Iterator i = node.begin(); i != node.end(); ++i)
{
std::string key;
i.first() >> key;
if (key == "width")
{
i.second() >> _width;
}
else if (key == "height")
开发者ID:JacobGade,项目名称:OpenXcom,代码行数:11,代码来源:ExtraSprites.cpp
示例5: load
/**
* Add the weighted options from a YAML::Node to a WeightedOptions.
* The weight option list is not replaced, only values in @a nd will be added /
* changed.
* @param nd The YAML node (containing a map) with the new values.
* @param wo The list to change.
*/
void WeightedOptions::load(const YAML::Node &nd)
{
for (YAML::Iterator val = nd.begin(); val != nd.end(); ++val)
{
std::string id;
unsigned w;
val.first() >> id;
val.second() >> w;
set(id, w);
}
}
开发者ID:Tripphippie,项目名称:OpenXcom,代码行数:18,代码来源:WeightedOptions.cpp
示例6: load
/**
* Loads the inventory from a YAML file.
* @param node YAML node.
*/
void RuleInventory::load(const YAML::Node &node)
{
int a = 0;
for (YAML::Iterator i = node.begin(); i != node.end(); ++i)
{
std::string key;
i.first() >> key;
if (key == "id")
{
i.second() >> _id;
}
else if (key == "x")
开发者ID:GregoryBonik,项目名称:OpenXcom,代码行数:16,代码来源:RuleInventory.cpp
示例7: load
/**
* Loads the article definition from a YAML file.
* @param node YAML node.
*/
void ArticleDefinition::load(const YAML::Node &node)
{
int a = 0;
for (YAML::Iterator i = node.begin(); i != node.end(); ++i)
{
std::string key;
i.first() >> key;
if (key == "id")
{
i.second() >> id;
i.second() >> title;
}
else if (key == "type_id")
开发者ID:DiegoVazquezNanini,项目名称:OpenXcom,代码行数:17,代码来源:ArticleDefinition.cpp
示例8: load
/**
* Loads the unit from a YAML file.
* @param node YAML node.
*/
void Unit::load(const YAML::Node &node)
{
int a = 0;
for (YAML::Iterator i = node.begin(); i != node.end(); ++i)
{
std::string key;
i.first() >> key;
if (key == "type")
{
i.second() >> _type;
}
else if (key == "race")
开发者ID:Arthur1994,项目名称:OpenXcom,代码行数:17,代码来源:Unit.cpp
示例9: parser
void PointMatcher<T>::ICPChainBase::loadFromYaml(std::istream& in)
{
this->cleanup();
YAML::Parser parser(in);
YAML::Node doc;
parser.GetNextDocument(doc);
typedef set<string> StringSet;
StringSet usedModuleTypes;
// Fix for issue #6: compilation on gcc 4.4.4
//PointMatcher<T> pm;
const PointMatcher & pm = PointMatcher::get();
{
// NOTE: The logger needs to be initialize first to allow ouput from other contructors
boost::mutex::scoped_lock lock(loggerMutex);
usedModuleTypes.insert(createModuleFromRegistrar("logger", doc, pm.REG(Logger), logger));
}
usedModuleTypes.insert(createModulesFromRegistrar("readingDataPointsFilters", doc, pm.REG(DataPointsFilter), readingDataPointsFilters));
usedModuleTypes.insert(createModulesFromRegistrar("readingStepDataPointsFilters", doc, pm.REG(DataPointsFilter), readingStepDataPointsFilters));
usedModuleTypes.insert(createModulesFromRegistrar("referenceDataPointsFilters", doc, pm.REG(DataPointsFilter), referenceDataPointsFilters));
//usedModuleTypes.insert(createModulesFromRegistrar("transformations", doc, pm.REG(Transformation), transformations));
//usedModuleTypes.insert(createModuleFromRegistrar("matcher", doc, pm.REG(Matcher), matcher)); // don't destroy the already created tree
usedModuleTypes.insert(createModulesFromRegistrar("outlierFilters", doc, pm.REG(OutlierFilter), outlierFilters));
usedModuleTypes.insert(createModuleFromRegistrar("errorMinimizer", doc, pm.REG(ErrorMinimizer), errorMinimizer));
// See if to use a rigid transformation
if (nodeVal("errorMinimizer", doc) != "PointToPointSimilarityErrorMinimizer")
this->transformations.push_back(new typename TransformationsImpl<T>::RigidTransformation());
else
this->transformations.push_back(new typename TransformationsImpl<T>::SimilarityTransformation());
usedModuleTypes.insert(createModulesFromRegistrar("transformationCheckers", doc, pm.REG(TransformationChecker), transformationCheckers));
usedModuleTypes.insert(createModuleFromRegistrar("inspector", doc, pm.REG(Inspector),inspector));
// FIXME: this line cause segfault when there is an error in the yaml file...
//loadAdditionalYAMLContent(doc);
// check YAML entries that do not correspend to any module
for(YAML::Iterator moduleTypeIt = doc.begin(); moduleTypeIt != doc.end(); ++moduleTypeIt)
{
string moduleType;
moduleTypeIt.first() >> moduleType;
if (moduleType != "matcher" && usedModuleTypes.find(moduleType) == usedModuleTypes.end())
throw InvalidModuleType(
(boost::format("Module type %1% does not exist") % moduleType).str()
);
}
}
开发者ID:oleg-alexandrov,项目名称:libpointmatcher,代码行数:51,代码来源:ICP.cpp
示例10: parse_binding_config
/*!
* Parses the binding config YAML specification.
*
* \param[in] node The YAML node containing the binding config specification.
* \param[out] b The object in which to store the binding configuration information.
*/
void parse_binding_config(YAML::Node const& node, controlit::BindingConfig& bc)
{
// Parameters
// for (YAML::Iterator it = node["parameters"].begin();
// it !=node["parameters"].end(); ++it)
// {
// std::string paramName;
// *it >> paramName;
// bc.addParameter(paramName);
// }
std::string parameter;
node["parameter"] >> parameter;
bc.setParameter(parameter);
// Direction
std::string direction;
node["direction"] >> direction;
bc.setDirection(controlit::BindingConfig::Direction::Undefined);
if (direction == "input") bc.setDirection(controlit::BindingConfig::Direction::Input);
if (direction == "output") bc.setDirection(controlit::BindingConfig::Direction::Output);
if (direction == "bidirectional") bc.setDirection(controlit::BindingConfig::Direction::Bidirectional);
// Target
YAML::Node const& targetNode = *(node.FindValue("target"));
// targetNode["transportType"] >> bc.transportType;
std::string transportType;
std::string transportDataType;
targetNode["type"] >> transportType;
targetNode["dataType"] >> transportDataType;
bc.setTransportType(transportType);
bc.setTransportDataType(transportDataType);
// Target properties
YAML::Node const* propertiesNode = targetNode.FindValue("properties");
if (propertiesNode != NULL)
{
for (YAML::Iterator it = propertiesNode->begin(); it != propertiesNode->end(); ++it)
{
std::string key, value;
it.first() >> key;
it.second() >> value;
bc.addProperty(key, value);
}
}
}
开发者ID:liangfok,项目名称:controlit,代码行数:55,代码来源:parse_binding_config.cpp
示例11: parseConfigVectorFromYamlNode
static ConfigVector parseConfigVectorFromYamlNode(const YAML::Node &n) {
ConfigVector vec;
if(n.Type() == YAML::NodeType::Sequence) {
YAML::Iterator it;
for(it = n.begin(); it != n.end(); ++it) {
ConfigItem item;
if(it->Type() == YAML::NodeType::Scalar) {
item = parseConfigItemFromYamlNode(*it);
} else if(it->Type() == YAML::NodeType::Sequence) {
item[""] = parseConfigVectorFromYamlNode(*it);
} else if(it->Type() == YAML::NodeType::Map) {
item.children = parseConfigMapFromYamlNode(*it);
}
vec.push_back(item);
}
}
return vec;
}
开发者ID:bergatt,项目名称:mars,代码行数:18,代码来源:ConfigData.cpp
示例12: loadChildren
void Property::loadChildren( const YAML::Node& yaml_node )
{
if( yaml_node.Type() != YAML::NodeType::Map )
{
printf( "Property::loadChildren() TODO: error handling - unexpected YAML type.\n" );
return;
}
// A special map entry named "Value" means the value of this property, not a child.
if( const YAML::Node *value_node = yaml_node.FindValue( "Value" ))
{
loadValue( *value_node );
}
// Yaml-cpp's FindValue() and operator[] functions are order-N,
// according to the docs, so we don't want to use those. Instead we
// make a hash table of the existing property children, then loop
// over all the yaml key-value pairs, looking up their targets by
// key (name) in the map. This should keep this function down to
// order-N or close, instead of order N squared.
// First make the hash table of all child properties indexed by name.
QHash<QString, Property*> child_map;
int num_property_children = children_.size();
for( int i = 0; i < num_property_children; i++ )
{
Property* child = children_.at( i );
child_map[ child->getName() ] = child;
}
// Next loop over all yaml key/value pairs, calling load() on each
// child whose name we find.
for( YAML::Iterator it = yaml_node.begin(); it != yaml_node.end(); ++it )
{
QString key;
it.first() >> key;
QHash<QString, Property*>::const_iterator hash_iter = child_map.find( key );
if( hash_iter != child_map.end() )
{
Property* child = hash_iter.value();
child->load( it.second() );
}
}
}
开发者ID:F34140r,项目名称:visualization-userfriendly,代码行数:44,代码来源:property.cpp
示例13: readYamlNode
void YamlConfigReader::readYamlNode( Config& config, const YAML::Node& yaml_node )
{
switch( yaml_node.Type() )
{
case YAML::NodeType::Map:
{
for( YAML::Iterator it = yaml_node.begin(); it != yaml_node.end(); ++it )
{
std::string key;
it.first() >> key;
Config child = config.mapMakeChild( QString::fromStdString( key ));
readYamlNode( child, it.second() );
}
break;
}
case YAML::NodeType::Sequence:
{
for( YAML::Iterator it = yaml_node.begin(); it != yaml_node.end(); ++it )
{
Config child = config.listAppendNew();
readYamlNode( child, *it );
}
break;
}
case YAML::NodeType::Scalar:
{
std::string s;
yaml_node >> s;
config.setValue( QString::fromStdString( s ));
break;
}
case YAML::NodeType::Null:
default:
break;
}
}
开发者ID:jkammerl,项目名称:rviz,代码行数:36,代码来源:yaml_config_reader.cpp
示例14: load
void ExtraStrings::load(const YAML::Node &node)
{
for (YAML::Iterator i = node.begin(); i != node.end(); ++i)
{
std::string key;
i.first() >> key;
if (key == "strings")
{
for (YAML::Iterator j = i.second().begin(); j != i.second().end(); ++j)
{
std::string index;
j.first() >> index;
std::string translation;
j.second() >> translation;
_strings[index] = translation;
}
}
}
}
开发者ID:cybergerac,项目名称:OpenXcom,代码行数:19,代码来源:ExtraStrings.cpp
示例15: load
/*
* Loads the extra sound set from yaml.
* @param node YAML node.
* @param modIndex the internal index of the associated mod.
*/
void ExtraSounds::load(const YAML::Node &node, int modIndex)
{
for (YAML::Iterator i = node.begin(); i != node.end(); ++i)
{
std::string key;
i.first() >> key;
if (key == "files")
{
for (YAML::Iterator j = i.second().begin(); j != i.second().end(); ++j)
{
int index;
j.first() >> index;
std::string filename;
j.second() >> filename;
_sounds[index] = filename;
}
}
}
_modIndex = modIndex;
}
开发者ID:Arthur1994,项目名称:OpenXcom,代码行数:25,代码来源:ExtraSounds.cpp
示例16: parseConfigMapFromYamlNode
static ConfigMap parseConfigMapFromYamlNode(const YAML::Node &n) {
ConfigMap configMap;
for(YAML::Iterator it = n.begin(); it != n.end(); ++it) {
if(it.second().Type() == YAML::NodeType::Scalar) {
configMap[it.first().to<std::string>()].push_back(parseConfigItemFromYamlNode(it.second()));
} else if(it.second().Type() == YAML::NodeType::Sequence) {
configMap[it.first().to<std::string>()] = parseConfigVectorFromYamlNode(it.second());
} else if(it.second().Type() == YAML::NodeType::Map) {
ConfigItem item;
item.children = parseConfigMapFromYamlNode(it.second());
configMap[it.first().to<std::string>()].push_back(item);
} else if(it.second().Type() == YAML::NodeType::Null) {
continue;
} else {
fprintf(stderr, "Unknown YAML::NodeType: %d\n", it.second().Type());
continue;
}
}
return configMap;
}
开发者ID:bergatt,项目名称:mars,代码行数:20,代码来源:ConfigData.cpp
示例17: yaml_traverse
static void yaml_traverse(struct VMGlobals* g, const YAML::Node & node, PyrObject *parent, PyrSlot *slot) {
YAML::NodeType::value type = node.Type();
string out;
PyrObject *result = NULL;
switch (type)
{
case YAML::NodeType::Scalar:
node >> out;
result = (PyrObject*)newPyrString(g->gc, out.c_str(), 0, true);
SetObject(slot, result);
if(parent) g->gc->GCWriteNew(parent, result); // we know result is white so we can use GCWriteNew
break;
case YAML::NodeType::Sequence:
result = newPyrArray(g->gc, node.size(), 0, true);
SetObject(slot, result);
if(parent) g->gc->GCWriteNew(parent, result); // we know result is white so we can use GCWriteNew
for (unsigned int i = 0; i < node.size(); i++) {
const YAML::Node & subnode = node[i];
result->size++;
yaml_traverse(g, subnode, result, result->slots+i);
}
break;
case YAML::NodeType::Map:
{
result = instantiateObject( g->gc, s_dictionary->u.classobj, 0, false, true );
SetObject(slot, result);
if(parent) g->gc->GCWriteNew(parent, result); // we know result is white so we can use GCWriteNew
PyrObject *array = newPyrArray(g->gc, node.size()*2, 0, true);
result->size = 2;
SetObject(result->slots, array); // array
SetInt(result->slots+1, node.size()); // size
g->gc->GCWriteNew(result, array); // we know array is white so we can use GCWriteNew
int j = 0;
for (YAML::Iterator i = node.begin(); i != node.end(); ++i) {
const YAML::Node & key = i.first();
const YAML::Node & value = i.second();
key >> out;
PyrObject *pkey = (PyrObject*)newPyrString(g->gc, out.c_str(), 0, true);
SetObject(array->slots+j, pkey);
array->size++;
g->gc->GCWriteNew(array, pkey); // we know pkey is white so we can use GCWriteNew
array->size++;
yaml_traverse(g, value, array, array->slots+j+1);
j += 2;
}
break;
}
case YAML::NodeType::Null:
SetNil(slot);
break;
default:
postfl("WARNING: yaml_traverse(): unknown/unsupported node type\n");
SetNil(slot);
}
}
开发者ID:kulicuu,项目名称:supercollider,代码行数:64,代码来源:PyrStringPrim.cpp
示例18: ofs
// Called from the consumer since this class is a registered MessageListener.
virtual void
onMessage (const Message * message)
throw ()
{
static int
count = 0;
try
{
count++;
const TextMessage *
textMessage = dynamic_cast < const
TextMessage * >(message);
const BytesMessage *
bytesMessage = dynamic_cast < const
BytesMessage * >(message);
string text = "";
if (bytesMessage != NULL)
{
//std::cout << bytesMessage->getBodyBytes();
//bytesMessage->reset();
size_t i = bytesMessage->getBodyLength ();
printf ("%lu", i);
ofstream ofs ("message.yaml", ofstream::out);
for (int x = 1; x <= i; x++)
{
ofs << bytesMessage->readByte ();
}
ofs.flush ();
ofs.close ();
try
{
std::ifstream fin ("message.yaml");
//std::stringstream fin(std::string(bytesMessage->getBodyBytes()));
YAML::Parser parser (fin);
YAML::Node doc;
// We assume only the first doc, need to check with doc.size
parser.GetNextDocument (doc);
/*
Key: :agent
Key: :body
Key: :callerid
Key: :collectiv
Key: :filter
Key: :hash
Key: :msgtarget
Key: :msgtime
Key: :requestid
Key: :senderid
*/
for (YAML::Iterator it = doc.begin (); it != doc.end (); ++it)
{
std::string key, value;
it.first () >> key;
std::cout << "Key: " << key << std::endl;
}
std::string requestid;
std::string senderid;
std::string msgtarget;
doc[":msgtarget"] >> msgtarget;
doc[":requestid"] >> requestid;
doc[":senderid"] >> senderid;
std::cout << msgtarget << std::endl << requestid << std::
endl << senderid << std::endl;
// Body seems to be multiline string of yaml
// Parsing strings http://stackoverflow.com/questions/2813030/yaml-cpp-parsing-strings
std::string body;
doc[":body"] >> body;
std::stringstream bodystream (body);
YAML::Parser bodyparser (bodystream);
YAML::Node bodydoc;
std::string action;
bodyparser.GetNextDocument (bodydoc);
bodydoc >> action;
std::cout << action;
// Construct YAML body
YAML::Emitter reply_message_body_yaml;
reply_message_body_yaml << "pong";
// Put it in a string
std::string reply_message_body = reply_message_body_yaml.c_str();
std::cout << reply_message_body << std::endl;
// Append PSK to it
std::string psk = "unset";
std::string body_psk = reply_message_body;
body_psk.append(psk);
//.........这里部分代码省略.........
开发者ID:jedi4ever,项目名称:mcollective-cpp-agents,代码行数:101,代码来源:mc-discovery.cpp
示例19: toValueMap
/*
* For converting param specs for Regions and LinkPolicies
*/
ValueMap toValueMap(const char* yamlstring,
Collection<ParameterSpec>& parameters,
const std::string & nodeType,
const std::string & regionName)
{
ValueMap vm;
// yaml-cpp bug: append a space if it is only one character
// This is very inefficient, but should be ok since it is
// just used at construction time for short strings
std::string paddedstring(yamlstring);
// TODO: strip white space to determine if empty
bool empty = (paddedstring.size() == 0);
if (paddedstring.size() < 2)
paddedstring = paddedstring + " ";
std::stringstream s(paddedstring);
// IMemStream s(yamlstring, ::strlen(yamlstring));
// TODO: utf-8 compatible?
YAML::Node doc;
if (!empty)
{
YAML::Parser parser(s);
bool success = parser.GetNextDocument(doc);
if (!success)
NTA_THROW << "Unable to find document in YAML string";
// A ValueMap is specified as a dictionary
if (doc.Type() != YAML::NodeType::Map)
{
std::string ys(yamlstring);
if (ys.size() > 30)
{
ys = ys.substr(0, 30) + "...";
}
NTA_THROW << "YAML string '" << ys
<< "' does not not specify a dictionary of key-value pairs. "
<< "Region and Link parameters must be specified at a dictionary";
}
}
// Grab each value out of the YAML dictionary and put into the ValueMap
// if it is allowed by the nodespec.
YAML::Iterator i;
for (i = doc.begin(); i != doc.end(); i++)
{
const std::string key = i.first().to<std::string>();
if (!parameters.contains(key))
{
std::stringstream ss;
for (UInt j = 0; j < parameters.getCount(); j++)
{
ss << " " << parameters.getByIndex(j).first << "\n";
}
if (nodeType == std::string(""))
{
NTA_THROW << "Unknown parameter '" << key << "'\n"
<< "Valid parameters are:\n" << ss.str();
}
else
{
NTA_CHECK(regionName != std::string(""));
NTA_THROW << "Unknown parameter '" << key << "' for region '"
<< regionName << "' of type '" << nodeType << "'\n"
<< "Valid parameters are:\n" << ss.str();
}
}
if (vm.contains(key))
NTA_THROW << "Parameter '" << key << "' specified more than once in YAML document";
ParameterSpec spec = parameters.getByName(key);
try
{
Value v = toValue(i.second(), spec.dataType);
if (v.isScalar() && spec.count != 1)
{
throw std::runtime_error("Expected array value but got scalar value");
}
if (!v.isScalar() && spec.count == 1)
{
throw std::runtime_error("Expected scalar value but got array value");
}
vm.add(key, v);
} catch (std::runtime_error& e) {
NTA_THROW << "Unable to set parameter '" << key << "'. " << e.what();
}
}
// Populate ValueMap with default values if they were not specified in the YAML dictionary.
for (size_t i = 0; i < parameters.getCount(); i++)
{
std::pair<std::string, ParameterSpec>& item = parameters.getByIndex(i);
if (!vm.contains(item.first))
{
//.........这里部分代码省略.........
开发者ID:h2suzuki,项目名称:nupic.core,代码行数:101,代码来源:YAMLUtils.cpp
示例20: Exception
void
YamlConfiguration::read_config_doc(const YAML::Node &doc, YamlConfigurationNode *&node)
{
if (! node) {
node = new YamlConfigurationNode("root");
}
if (doc.Type() == YAML::NodeType::Map) {
#ifdef HAVE_YAMLCPP_0_5
for (YAML::const_iterator it = doc.begin(); it != doc.end(); ++it) {
std::string key = it->first.as<std::string>();
#else
for (YAML::Iterator it = doc.begin(); it != doc.end(); ++it) {
std::string key;
it.first() >> key;
#endif
YamlConfigurationNode *in = node;
if (key.find("/") != std::string::npos) {
// we need to split and find the proper insertion node
std::vector<std::string> pel = str_split(key);
for (size_t i = 0; i < pel.size() - 1; ++i) {
YamlConfigurationNode *n = (*in)[pel[i]];
if (! n) {
n = new YamlConfigurationNode(pel[i]);
in->add_child(pel[i], n);
}
in = n;
}
key = pel.back();
}
YamlConfigurationNode *tmp = (*in)[key];
if (tmp) {
#ifdef HAVE_YAMLCPP_0_5
if (tmp->is_scalar() && it->second.Type() != YAML::NodeType::Scalar)
#else
if (tmp->is_scalar() && it.second().Type() != YAML::NodeType::Scalar)
#endif
{
throw Exception("YamlConfig: scalar %s cannot be overwritten by non-scalar",
tmp->name().c_str());
}
#ifdef HAVE_YAMLCPP_0_5
tmp->set_scalar(it->second.Scalar());
#else
std::string s;
if (it.second().GetScalar(s)) {
tmp->set_scalar(s);
}
#endif
} else {
#ifdef HAVE_YAMLCPP_0_5
YamlConfigurationNode *tmp = new YamlConfigurationNode(key, it->second);
in->add_child(key, tmp);
read_config_doc(it->second, tmp);
#else
YamlConfigurationNode *tmp = new YamlConfigurationNode(key, it.second());
in->add_child(key, tmp);
read_config_doc(it.second(), tmp);
#endif
}
}
} else if (doc.Type() == YAML::NodeType::Scalar) {
if (doc.Tag() == "tag:fawkesrobotics.org,cfg/tcp-port" ||
doc.Tag() == "tag:fawkesrobotics.org,cfg/udp-port")
{
unsigned int p = 0;
try {
p = node->get_uint();
} catch (Exception &e) {
e.prepend("YamlConfig: Invalid TCP/UDP port number (not an unsigned int)");
throw;
}
if (p <= 0 || p >= 65535) {
throw Exception("YamlConfig: Invalid TCP/UDP port number "
"(%u out of allowed range)", p);
}
} else if (doc.Tag() == "tag:fawkesrobotics.org,cfg/url") {
#ifdef HAVE_YAMLCPP_0_5
std::string scalar = doc.Scalar();
#else
std::string scalar;
doc.GetScalar(scalar);
#endif
#ifdef USE_REGEX_CPP
if (regex_search(scalar, __url_regex)) {
# if 0
// just for emacs auto-indentation
}
# endif
#else
if (regexec(&__url_regex, scalar.c_str(), 0, NULL, 0) == REG_NOMATCH) {
throw Exception("YamlConfig: %s is not a valid URL", scalar.c_str());
}
#endif
} else if (doc.Tag() == "tag:fawkesrobotics.org,cfg/frame") {
#ifdef HAVE_YAMLCPP_0_5
std::string scalar = doc.Scalar();
//.........这里部分代码省略.........
开发者ID:jmlich,项目名称:fawkes,代码行数:101,代码来源:yaml.cpp
注:本文中的yaml::Iterator类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论