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


C++ Iterator::second方法代码示例

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


在下文中一共展示了Iterator::second方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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)["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);
			}
		}
		else if (key == "regions")
		{
			for (YAML::Iterator j = i.second().begin(); j != i.second().end(); ++j)
			{
				std::string type;
				(*j)["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);
			}
		}
		else if (key == "facilities")
开发者ID:rickyah,项目名称:OpenXcom,代码行数:61,代码来源:Ruleset.cpp

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例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: 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

示例14: 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

示例15: 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


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