当前位置: 首页>>代码示例>>C++>>正文


C++ yaml::Iterator类代码示例

本文整理汇总了C++中yaml::Iterator的典型用法代码示例。如果您正苦于以下问题:C++ Iterator类的具体用法?C++ Iterator怎么用?C++ Iterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Iterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的yaml::Iterator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。