本文整理汇总了C++中yaml::Node::FindValue方法的典型用法代码示例。如果您正苦于以下问题:C++ Node::FindValue方法的具体用法?C++ Node::FindValue怎么用?C++ Node::FindValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yaml::Node
的用法示例。
在下文中一共展示了Node::FindValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: is
TrackExtractor *loadTEFromDisk (const char *tename) {
try {
ifstream is(tename);
if (is.bad()) {
is.close();
cout << "is bad" << endl;
return defaultTE();
}
YAML::Parser parser(is);
YAML::Node node;
parser.GetNextDocument(node);
// std::cout << "parsed\n";
if (node.Type() != YAML::NodeType::Map) {
cout << "failed to parse " << tename << "node is not a map " <<endl;
return defaultTE();
}
if (node.FindValue("max maggot contour angle")) { //it's a maggot
MaggotTrackExtractor *mte = new MaggotTrackExtractor;
// cout << "it's a maggot" << endl;
mte->fromYAML(node);
return mte;
} else {
// cout << "basic track extractor" << endl;
TrackExtractor *te = new TrackExtractor;
te->fromYAML(node);
return te;
}
} catch (YAML::ParserException &e) {
std::cout << "Parser Error " << e.what() << "\n";
return defaultTE();
}
}
示例2: 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 "";
}
示例3:
Mod::Mod(const YAML::Node& globnode, const YAML::Node& modnode) {
const Node* key;
char* value;
if (modnode.FindValue("mod")) {
modnode["mod"] >> mod;
modnode["name"] >> name;
modnode["desc"] >> desc;
} else { // Backwards compatible mode for <= 0.3
示例4: load
void FileDrawNode::load(string const &filename, TextureManager &texRes, SceneManager &sceneRes, ShaderManager &shaderRes, BulletManager &bulletRes)
{
for(size_t idx = 0; idx != objects().size(); ++idx)
{
// if it's already loaded we can stop
if(objects()[idx].filename == filename)
{
log(__FILE__, __LINE__, LogType::warning, "The file " + filename + " is already loaded");
return;
}
}
// open the file
ifstream file(filename);
if(not file.is_open())
{
throw log(__FILE__, __LINE__, LogType::error, "Can't open file " + filename + " for reading");
return;
}
try
{
// determine location of the file
string directory;
size_t locOfLastSlash = filename.find_last_of('/', string::npos);
if(locOfLastSlash != string::npos)
directory = filename.substr(0, locOfLastSlash + 1);
YAML::Parser parser(file);
YAML::Node document;
parser.GetNextDocument(document);
vector<Scene> scenes = parseScenes(document.FindValue("Scenes"), filename, directory, texRes, sceneRes, bulletRes);
vector<Shader> shaders = parseShaders(document.FindValue("Shaders"), defaultShaders(), directory, shaderRes);
objects().push_back({filename, shaders, scenes});
}
catch(exception &except)
{
throw log(__FILE__, __LINE__, LogType::error, except.what());
}
}
示例5: loadYaml
void Robots::loadYaml(string filename)
{
cout << endl << "Loading yaml configuration " << filename << endl;
try
{
ifstream cfgfile(filename.c_str());
if(!cfgfile)
throw string("Failed to open file " + filename);
YAML::Parser parser(cfgfile);
YAML::Node doc;
bool result = parser.GetNextDocument(doc);
if(!result)
throw string("Parser failed to load document");
if(!doc.FindValue("robots"))
{
throw string("Config error : no robots entry in yaml doc");
}
else
{
YAML::Iterator it;
int i;
string name, host, environment, move;
int port;
vector<string> loadedMoves;
for(it=doc["robots"].begin();it!=doc["robots"].end();++it)
{
loadedMoves.clear();
// Name
it.first() >> name;
robots[name] = new Robot(new CommandsStore, name);
// Host & port
if(it.second().FindValue("host"))
{
if(it.second().FindValue("host"))
it.second()["host"] >> host;
else
host = "localhost";
if(it.second().FindValue("port")) {
it.second()["port"] >> port;
} else {
port = 7777;
}
robots[name]->connect(host.c_str(), port);
}
// Environment
if(it.second().FindValue("environment"))
{
it.second()["environment"] >> environment;
robots[name]->loadEnvironment(environment);
}
示例6: Transfer
void
Transfers::load(const YAML::Node & node)
{
// xfers are optional...
const YAML::Node *transfers = node.FindValue("transfers");
if (transfers) {
for ( size_t itransfer = 0; itransfer < transfers->size(); ++itransfer ) {
const YAML::Node & transferNode = (*transfers)[itransfer];
Transfer *transferInfo = new Transfer(*this);
transferInfo->load(transferNode);
this->push_back(transferInfo);
}
}
}
示例7: 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);
}
}
}
示例8: utl_yaml_read_ip_addr
bool utl_yaml_read_ip_addr(const YAML::Node& node,
std::string name,
uint32_t & val){
std::string tmp;
uint32_t ip;
bool res=false;
if ( node.FindValue(name) ) {
node[name] >> tmp ;
if ( my_inet_pton4((char *)tmp.c_str(), (unsigned char *)&ip) ){
val=PKT_NTOHL(ip);
res=true;
}else{
printf(" ERROR not a valid ip %s \n",(char *)tmp.c_str());
exit(-1);
}
}
示例9: reloadConfiguration
void CmdVelMuxNodelet::reloadConfiguration(yocs_cmd_vel_mux::reloadConfig &config, uint32_t unused_level)
{
std::string yaml_cfg_file;
ros::NodeHandle &nh = this->getPrivateNodeHandle();
if( config.yaml_cfg_file == "" )
{
// typically fired on startup, so look for a parameter to set a default
nh.getParam("yaml_cfg_file", yaml_cfg_file);
}
else
{
yaml_cfg_file = config.yaml_cfg_file;
}
/*********************
** Yaml File Parsing
**********************/
std::ifstream ifs(yaml_cfg_file.c_str(), std::ifstream::in);
if (ifs.good() == false)
{
NODELET_ERROR_STREAM("CmdVelMux : configuration file not found [" << yaml_cfg_file << "]");
return;
}
// probably need to bring the try catches back here
YAML::Node doc;
#ifdef HAVE_NEW_YAMLCPP
doc = YAML::Load(ifs);
#else
YAML::Parser parser(ifs);
parser.GetNextDocument(doc);
#endif
/*********************
** Output Publisher
**********************/
std::string output_name("output");
#ifdef HAVE_NEW_YAMLCPP
if ( doc["publisher"] ) {
doc["publisher"] >> output_name;
}
#else
const YAML::Node *node = doc.FindValue("publisher");
if ( node != NULL ) {
*node >> output_name;
}
示例10: parse
void Configuration::parse(YAML::Node &aDoc, int aPort, int aDelay, int aTimeout, const char *aService)
{
if (aDoc.FindValue("adapter") != NULL)
{
const YAML::Node &adapter = aDoc["adapter"];
SET_WITH_DEFAULT(adapter, "port", mPort, aPort);
SET_WITH_DEFAULT(adapter, "scanDelay", mScanDelay, aDelay);
SET_WITH_DEFAULT(adapter, "timeout", mTimeout, aTimeout);
SET_WITH_DEFAULT(adapter, "service", mServiceName, aService);
}
else
{
mPort = aPort;
mScanDelay = aDelay;
mTimeout = aTimeout;
mServiceName = aService;
}
}
示例11: 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() );
}
}
}
示例12:
//----------------------------------------------------------------------------------
bool g3d::VoxelSpace_c::load(const std::string &FileName,YAML::Node &user_doc)
{
bool Res = true;
mcv::MixedFileManager_c FManager;
std::stringstream YamlHeader = FManager.Parse(FileName);
if(YamlHeader.str().empty())
{
std::cout << "VoxelSpace_c::load() Couldn't load File: " << FileName << std::endl;
return false;
}
YAML::Parser parser;
parser.Load(YamlHeader);
parser.GetNextDocument(user_doc);
YAML::Node doc;
parser.GetNextDocument(doc);
doc["VoxelSize"] >> VoxelSize;
int TotalVoxels,vXv,vYv,vZv;
doc["Xv"] >> vXv;
doc["Yv"] >> vYv;
doc["Zv"] >> vZv;
doc["TotalVoxels"] >> TotalVoxels;
int vNbFill;
doc["NbFill"] >> vNbFill;
EigenBox3D vBox;
doc["VoxBox"] >> vBox;
//This is the load SetUp as the data is the master with its Xv,Yv,Zv
//and the <float> is not guarantied through text save and load
//whether use double if more precision is needed but won't correct the text conversion issue
//or save the critical information on data, but it becomes no more editable by the user
//the remaining issue is the float -> text -> float conversion !!! ??? is this safe ?
Reset(vBox.Low,vXv,vYv,vZv,VoxelSize);//will get Xv = vXv ....
doc["TypeName"] >> TypeName;
doc["ColorTable"] >> ColorTable;
if(doc.FindValue("ClassesNames"))
{
doc["ClassesNames"] >> ClassesNames;
}
示例13: load
/**
* Loads the saved battle game from a YAML file.
* @param node YAML node.
*/
void SavedBattleGame::load(const YAML::Node &node, Ruleset *rule, SavedGame* savedGame)
{
int a,b;
int selectedUnit = 0;
Uint32 startTime = SDL_GetTicks();
node["width"] >> _mapsize_x;
node["length"] >> _mapsize_y;
node["height"] >> _mapsize_z;
node["missionType"] >> _missionType;
node["globalshade"] >> _globalShade;
node["turn"] >> _turn;
node["selectedUnit"] >> selectedUnit;
for (YAML::Iterator i = node["mapdatasets"].begin(); i != node["mapdatasets"].end(); ++i)
{
std::string name;
*i >> name;
MapDataSet *mds = new MapDataSet(name);
_mapDataSets.push_back(mds);
}
initMap(_mapsize_x, _mapsize_y, _mapsize_z);
if (!node.FindValue("tileTotalBytesPer"))
{
// binary tile data not found, load old-style text tiles :(
for (YAML::Iterator i = node["tiles"].begin(); i != node["tiles"].end(); ++i)
{
Position pos;
(*i)["position"][0] >> pos.x;
(*i)["position"][1] >> pos.y;
(*i)["position"][2] >> pos.z;
getTile(pos)->load((*i));
}
} else
{
示例14: loadConfig
bool CompoundTask::loadConfig(YAML::Node const& doc)
{
// Before anything, load all of the tasks in the 'tasks' section.
// We will come back later and query the TaskFactory for the tasks
// we need.
std::map<std::string, Task*> taskList;
YAML::Node const* tasksNode = doc.FindValue("tasks");
if (tasksNode != NULL)
{
for (YAML::Iterator it = tasksNode->begin(); it != tasksNode->end(); ++it)
{
// peek into task to get its type and name
std::string taskType;
(*it)["type"] >> taskType;
std::string taskName;
(*it)["name"] >> taskName;
PRINT_DEBUG_STATEMENT_RT("Creating task of type '" << taskType << "' called '" << taskName << "'");
Task* task = taskFactory->loadFromYaml(*it);
if (task != NULL)
{
PRINT_DEBUG_STATEMENT_RT("Done creating task '" << taskName << "'");
taskList.insert(std::make_pair(task->getInstanceName(), task));
}
else
{
CONTROLIT_PR_ERROR_RT << "Factory failed to create task";
return false;
}
}
}
else
{
示例15: load
/**
* Loads a saved game's contents from a YAML file.
* @note Assumes the saved game is blank.
* @param filename YAML filename.
* @param rule Ruleset for the saved game.
*/
void SavedGame::load(const std::string &filename, Ruleset *rule)
{
std::string s = Options::getUserFolder() + filename + ".sav";
std::ifstream fin(s.c_str());
if (!fin)
{
throw Exception("Failed to load savegame");
}
YAML::Parser parser(fin);
YAML::Node doc;
// Get brief save info
parser.GetNextDocument(doc);
std::string v;
doc["version"] >> v;
if (v != Options::getVersion())
{
throw Exception("Version mismatch");
}
_time->load(doc["time"]);
// Get full save data
parser.GetNextDocument(doc);
int a = 0;
doc["difficulty"] >> a;
_difficulty = (GameDifficulty)a;
doc["funds"] >> _funds;
for (YAML::Iterator i = doc["countries"].begin(); i != doc["countries"].end(); ++i)
{
std::string type;
(*i)["type"] >> type;
Country *c = new Country(rule->getCountry(type), false);
c->load(*i);
_countries.push_back(c);
}
for (YAML::Iterator i = doc["regions"].begin(); i != doc["regions"].end(); ++i)
{
std::string type;
(*i)["type"] >> type;
Region *r = new Region(rule->getRegion(type));
r->load(*i);
_regions.push_back(r);
}
for (YAML::Iterator i = doc["ufos"].begin(); i != doc["ufos"].end(); ++i)
{
std::string type;
(*i)["type"] >> type;
Ufo *u = new Ufo(rule->getUfo(type));
u->load(*i);
_ufos.push_back(u);
}
doc["craftId"] >> _craftId;
for (YAML::Iterator i = doc["waypoints"].begin(); i != doc["waypoints"].end(); ++i)
{
Waypoint *w = new Waypoint();
w->load(*i);
_waypoints.push_back(w);
}
doc["ufoId"] >> _ufoId;
doc["waypointId"] >> _waypointId;
doc["soldierId"] >> _soldierId;
for (YAML::Iterator i = doc["bases"].begin(); i != doc["bases"].end(); ++i)
{
Base *b = new Base(rule);
b->load(*i, this);
_bases.push_back(b);
}
for(YAML::Iterator it=doc["discovered"].begin();it!=doc["discovered"].end();++it)
{
std::string research;
*it >> research;
_discovered.push_back(rule->getResearchProject(research));
}
if (const YAML::Node *pName = doc.FindValue("battleGame"))
{
_battleGame = new SavedBattleGame();
_battleGame->load(*pName, rule, this);
}
fin.close();
}