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


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

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


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

示例1: defaultString

bool
KnobSerialization::checkForDefaultValueNode(const YAML::Node& node, const std::string& nodeType, bool dataTypeSet)
{
    std::string defaultString("Default");
    std::string defaultTypeName = defaultString + nodeType;
    if (!node[defaultTypeName]) {
        return false;
    }

    // If the _dataType member was set in checkForValueNode, ensure that the data type of the value is the same as
    // the default value.
    if (dataTypeSet) {
        SerializationValueVariantTypeEnum type = dataTypeFromString(nodeType);
        if (type != _dataType) {
            throw std::invalid_argument(_scriptName + ": Default value and value type differ!");
        }
    } else {
        _dataType = dataTypeFromString(nodeType);
    }


    YAML::Node defNode = node[defaultTypeName];
    int nDims = defNode.IsSequence() ? defNode.size() : 1;
    _defaultValues.resize(nDims);
    for (int i = 0; i < nDims; ++i) {
        _defaultValues[i].serializeDefaultValue = true;
        YAML::Node dimNode = defNode.IsSequence() ? defNode[i] : defNode;
        decodeValueFromNode(dimNode, _defaultValues[i].value, _dataType);
    }

    return true;
}
开发者ID:kcotugno,项目名称:Natron,代码行数:32,代码来源:KnobSerialization.cpp

示例2: load

/**
 * Loads the map data set from a YAML file.
 * @param node YAML node.
 */
void MapDataSet::load(const YAML::Node &node)
{
	for (YAML::const_iterator i = node.begin(); i != node.end(); ++i)
	{
		_name = i->as<std::string>(_name);
	}
}
开发者ID:Scarberian,项目名称:OpenXcom,代码行数:11,代码来源:MapDataSet.cpp

示例3: handleRuningStateChangedMsg

void ScServer::handleRuningStateChangedMsg( const QString & data )
{
    std::stringstream stream;
    stream << data.toStdString();
    YAML::Parser parser(stream);

    bool serverRunningState;
    std::string hostName;
    int port;

    YAML::Node doc;
    while(parser.GetNextDocument(doc)) {
        assert(doc.Type() == YAML::NodeType::Sequence);

        bool success = doc[0].Read(serverRunningState);
        if (!success) return; // LATER: report error?

        success = doc[1].Read(hostName);
        if (!success) return; // LATER: report error?

        success = doc[2].Read(port);
        if (!success) return; // LATER: report error?
    }

    QString qstrHostName( hostName.c_str() );

    onRunningStateChanged( serverRunningState, qstrHostName, port );

    emit runningStateChange( serverRunningState, qstrHostName, port );
}
开发者ID:edsonedge,项目名称:supercollider,代码行数:30,代码来源:sc_server.cpp

示例4: ParseDerivedDimensions

//==============================================================================
/// Parse the derived dimension list from a document.
/// 
/// \param [in] dim_list The YAML list node for the dimensions.
/// 
void DefinitionParser::ParseDerivedDimensions( const YAML::Node& dim_list )
{
    for ( YAML::Iterator it = dim_list.begin(); it != dim_list.end(); ++it )
    {
        ParseDerivedDimension( *it );
    }
}
开发者ID:Fifty-Nine,项目名称:AutoUnits,代码行数:12,代码来源:DefinitionParser.cpp

示例5: Import

void FileBundle::Import(const YAML::Node& config)
{
    switch (config.Type())
    {
    case YAML::NodeType::Scalar:
        ImportScalarNode(config);
        break;
    case YAML::NodeType::Sequence:
        for (auto i = config.begin(); i != config.end(); ++i)
        {
            const YAML::Node& node = *i;
            switch(node.Type())
            {
            case YAML::NodeType::Scalar:
                ImportScalarNode(node);
                break;
            case YAML::NodeType::Map:
                for (auto k = node.begin(); k != node.end(); ++k)
                {
                    auto file = ImportScalarNode(k->second);
                    file->name = k->first.as<string>();
                }
                break;
            }
        }
        break;
    case YAML::NodeType::Map:
        ImportCompositeBundle(config);
        break;
    }
}
开发者ID:jjiezheng,项目名称:ship,代码行数:31,代码来源:file_bundle.cpp

示例6: TSDebug

/**
  reads all the regular expressions from the database.
  and compile them
 */
void
RegexManager::load_config(YAML::Node cfg)
{
   try
   {

     TSDebug(BANJAX_PLUGIN_NAME, "Setting regex re2 options");
     RE2::Options opt;
     opt.set_log_errors(false);
     opt.set_perl_classes(true);
     opt.set_posix_syntax(true);

     TSDebug(BANJAX_PLUGIN_NAME, "Loading regex manager conf");
     //now we compile all of them and store them for later use
     for(YAML::const_iterator it = cfg.begin(); it != cfg.end(); ++it) {
       string cur_rule = (const char*) (*it)["rule"].as<std::string>().c_str();
       TSDebug(BANJAX_PLUGIN_NAME, "initiating rule %s", cur_rule.c_str());

       unsigned int observation_interval = (*it)["interval"].as<unsigned int>();
       unsigned int threshold  = (*it)["hits_per_interval"].as<unsigned int>();

       rated_banning_regexes.push_back(new RatedRegex(cur_rule, new RE2((const char*)((*it)["regex"].as<std::string>().c_str()), opt), observation_interval * 1000, threshold /(double)(observation_interval* 1000)));

     }
    }
   catch(YAML::RepresentationException& e)
     {
       TSDebug(BANJAX_PLUGIN_NAME, "Error loading regex manager conf [%s].", e.what());
	return;
     }
     TSDebug(BANJAX_PLUGIN_NAME, "Done loading regex manager conf");

}
开发者ID:carriercomm,项目名称:banjax,代码行数:37,代码来源:regex_manager.cpp

示例7: if

// Incrementally load YAML
static NEVER_INLINE void operator +=(YAML::Node& left, const YAML::Node& node)
{
	if (node && !node.IsNull())
	{
		if (node.IsMap())
		{
			for (const auto& pair : node)
			{
				if (pair.first.IsScalar())
				{
					auto&& lhs = left[pair.first.Scalar()];
					lhs += pair.second;
				}
				else
				{
					// Exotic case (TODO: probably doesn't work)
					auto&& lhs = left[YAML::Clone(pair.first)];
					lhs += pair.second;
				}
			}
		}
		else if (node.IsScalar() || node.IsSequence())
		{
			// Scalars and sequences are replaced completely, but this may change in future.
			// This logic may be overwritten by custom demands of every specific cfg:: node.
			left = node;
		}
	}
}
开发者ID:Zangetsu38,项目名称:rpcs3,代码行数:30,代码来源:SettingsDialog.cpp

示例8: main

int main(int argc, char* argv[])
{
   
   try
   {
      YAML::Node config = YAML::LoadFile(argv[1]);
      YAML::const_iterator iter =config.begin();
      yaml::ConfigNodePtr np;

      while( iter != config.end())
      {
         const YAML::Node& node = *iter;

         std::string module_name = node["module_name"].as<std::string>();
         
         np = yaml::NodeFactory::Instance().Create( module_name );
         np->Decode(node);
         np->Print(std::cout);
         ++iter;
      }

   }
   catch ( YAML::ParserException& e )
   {
      std::cout << e.what();
   }

   return 0;
}
开发者ID:FlavioFalcao,项目名称:Software-Defined-Radar-Simulator,代码行数:29,代码来源:yaml-test.cpp

示例9: upgradeYaml

void LootSettings::upgradeYaml(YAML::Node& yaml) {
    // Upgrade YAML settings' keys and values from those used in earlier
    // versions of LOOT.

  if (yaml["Debug Verbosity"] && !yaml["enableDebugLogging"])
    yaml["enableDebugLogging"] = yaml["Debug Verbosity"].as<unsigned int>() > 0;

  if (yaml["Update Masterlist"] && !yaml["updateMasterlist"])
    yaml["updateMasterlist"] = yaml["Update Masterlist"];

  if (yaml["Game"] && !yaml["game"])
    yaml["game"] = yaml["Game"];

  if (yaml["Language"] && !yaml["language"])
    yaml["language"] = yaml["Language"];

  if (yaml["Last Game"] && !yaml["lastGame"])
    yaml["lastGame"] = yaml["Last Game"];

  if (yaml["Games"] && !yaml["games"]) {
    yaml["games"] = yaml["Games"];

    for (auto node : yaml["games"]) {
      if (node["url"]) {
        node["repo"] = node["url"];
        node["branch"] = "master";  // It'll get updated to the correct default
      }
    }
  }

  if (yaml["games"]) {
    // Handle exception if YAML is invalid, eg. if an unrecognised
    // game type is used (which can happen if downgrading from a
    // later version of LOOT that supports more game types).
    // However, can't remove elements from a sequence Node, so have to
    // copy the valid elements into a new node then overwrite the
    // original.
    YAML::Node validGames;
    for (auto node : yaml["games"]) {
      try {
        GameSettings settings(node.as<GameSettings>());

        if (!yaml["Games"]) {
            // Update existing default branch, if the default
            // repositories are used.
          if (settings.RepoURL() == GameSettings(settings.Type()).RepoURL()
              && settings.IsRepoBranchOldDefault()) {
            settings.SetRepoBranch(GameSettings(settings.Type()).RepoBranch());
          }
        }

        validGames.push_back(settings);
      } catch (...) {}
    }
    yaml["games"] = validGames;
  }

  if (yaml["filters"])
    yaml["filters"].remove("contentFilter");
}
开发者ID:silentdark,项目名称:loot,代码行数:60,代码来源:loot_settings.cpp

示例10: groupFromYaml

bool BandwidthGui::groupFromYaml(const std::string& yaml, GroupMap* groupMap)
{
	YAML::Node grpInfo = YAML::Load(yaml);
	if (grpInfo.IsNull())
	{
		return true;
	}
	if (grpInfo.Type() != YAML::NodeType::Map)
	{
		return false;
	}
	for (const auto& pair : grpInfo)
	{
		if(pair.first.Type() != YAML::NodeType::Scalar)
		{
			return false;
		}
		std::string key = pair.first.as<std::string>();
		for (const auto& element : pair.second)
		{
			if(element.Type() != YAML::NodeType::Scalar)
			{
				return false;
			}
			(*groupMap)[key].push_back(element.as<std::string>());
		}
	}
	return true;
}
开发者ID:MorS25,项目名称:nimbro_network,代码行数:29,代码来源:bandwidth_gui.cpp

示例11: GetYamlDoc

string M3JointArrayClient::GetCompDir(string component)
{
    YAML::Node doc;
    GetYamlDoc("m3_config.yml",doc);
    
    if(!doc.FindValue("rt_components")) 
    {
	    ROS_ERROR("No rt_components key in m3_config.yml.");
	    return "";
    }
    
    for(YAML::Iterator it=doc["rt_components"].begin();it!=doc["rt_components"].end();++it) 
    {
	    string dir;

	    it.first() >> dir;
	    
	    for(YAML::Iterator it_dir=doc["rt_components"][dir.c_str()].begin();
		    it_dir!=doc["rt_components"][dir.c_str()].end();++it_dir) 
	    {
		    string  name, type;
		    it_dir.first() >> name;
		    it_dir.second() >> type;
		    if (name == component)		    		    		      		    
		      return dir;
	    }
	    
    }
    ROS_ERROR("No Robot Found.");
    return "";
}
开发者ID:CentralLabFacilities,项目名称:meka-ros-pkg,代码行数:31,代码来源:joint_array_client.cpp

示例12: addDevice

/**
 * LoadDevices
 * 
 * Loads devices from configuration object(YAML::Node)
 */
void
InsteonNetwork::loadDevices() {
    YAML::Node device = config_["DEVICES"];
    for (auto it = device.begin(); it != device.end(); ++it) {
        addDevice(it->first.as<int>(0));
    }
}
开发者ID:gitaaronc,项目名称:autohubpp,代码行数:12,代码来源:InsteonNetwork.cpp

示例13: loadPropertySystems

void WorldYamlSource::loadPropertySystems() {

	// iterate through each section (each section is a system)
	std::vector<YAML::Node> nodes = YAML::LoadAllFromFile(dir + "PropertySystems.yaml");
	for (size_t i = 0; i < nodes.size(); i++) {
		YamlWrapper yaml(nodes[i]);

		// parse which system this section is for
		String typeName = yaml.read<String>("Which", "NONE", "Invalid property system.");
		ThingType type = ThingType::fromString(typeName);

		// create the system
		propertySystems[type].reset(new PropertySystem());
		PropertySystem& system = *propertySystems[type];

		// parse the properties of the system
		YAML::Node propertiesNode = yaml["Properties"].getNode();
		for (auto iter = propertiesNode.begin(); iter != propertiesNode.end(); ++iter) {
			YamlWrapper propertyYaml(*iter);
			String name  = propertyYaml.read<String>("Name", "", "Property name not given.");
			Type type    = Type::fromString(propertyYaml.read<String>("Type"));
			Variant def  = readVariant(propertyYaml["Default"].getNode(), type);
			bool mainKey = propertyYaml.read<bool>("MainKey", false);
			system.add(name, type, def, mainKey);
		}
	}
}
开发者ID:lupuchard,项目名称:fek-base,代码行数:27,代码来源:WorldYamlSource.cpp

示例14: loadItems

void WorldYamlSource::loadItems() {
	if (!propertySystems[ThingType::ITEM]) return;
	PropertySystem& itemSys = *propertySystems[ThingType::ITEM];

	std::vector<YAML::Node> nodes = YAML::LoadAllFromFile(dir + "Items.yaml");
	for (size_t i = 0; i < nodes.size(); i++) {
		YamlWrapper yaml(nodes[i]);

		// read base
		String baseName = yaml.read<String>("Base", "", "Item lacks a base.");
		if (baseName == "") continue;
		auto iter = itemBaseNameMap.find(baseName);
		if (iter == itemBaseNameMap.end()) {
			LOG(ERROR) << "'" << baseName << "' is not an existing item base.";
			continue;
		}
		BaseThing& base = *iter->second;

		items.emplace_back(new Item(base, items.size() + 1));
		Item& item = *items.back();

		// read location
		if (yaml["Location"]->IsSequence()) {
			item.moveTo(yaml.read<Coord>("Location", Coord()));
		}

		// read properties
		YAML::Node propertiesNode = yaml["Properties"].getNode();
		for (auto iter = propertiesNode.begin(); iter != propertiesNode.end(); ++iter) {
			const Property& property = itemSys[iter->first.as<String>()];
			item.setValue(property, readVariant(iter->second, property.type));
		}
	}
}
开发者ID:lupuchard,项目名称:fek-base,代码行数:34,代码来源:WorldYamlSource.cpp

示例15: parseConfig

bool Sampler::parseConfig(const string &config_string) {
  YAML::Node node = YAML::Load(config_string);
  for (YAML::const_iterator it = node.begin(); it != node.end(); ++it) {
    string sample_name = it->first.as<string>();
    ui << sample_name << "\n";

    YAML::Node sample_data = it->second;

    if (!sample_data["file"]) {
      ui << "file is required for each sample\n";
      continue;
    }

    string file(sample_data["file"].as<string>());

    float pan = 0.;
    if (sample_data["pan"]) {
      pan = sample_data["pan"].as<float>();
    }

    midi_data_t midi_data = sample_data["midi"].as<int>();

    addSample(midi_data, file, pan);
  }
  return true;
}
开发者ID:ohinds,项目名称:perfen,代码行数:26,代码来源:sampler.cpp


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