33 #ifdef RVIZ_HAVE_YAMLCPP_05 34 #include <yaml-cpp/yaml.h> 36 #include <yaml-cpp/node.h> 37 #include <yaml-cpp/parser.h> 51 std::ifstream in( qPrintable( filename ));
57 std::stringstream ss( data.toStdString() );
66 #ifdef RVIZ_HAVE_YAMLCPP_05 67 yaml_node = YAML::Load(in);
70 parser.GetNextDocument( yaml_node );
76 catch( YAML::ParserException& ex )
85 switch( yaml_node.Type() )
87 case YAML::NodeType::Map:
89 #ifdef RVIZ_HAVE_YAMLCPP_05 90 for( YAML::const_iterator it = yaml_node.begin(); it != yaml_node.end(); ++it )
92 for( YAML::Iterator it = yaml_node.begin(); it != yaml_node.end(); ++it )
96 #ifdef RVIZ_HAVE_YAMLCPP_05 97 key = it->first.as<std::string>();
102 #ifdef RVIZ_HAVE_YAMLCPP_05 110 case YAML::NodeType::Sequence:
112 #ifdef RVIZ_HAVE_YAMLCPP_05 113 for( YAML::const_iterator it = yaml_node.begin(); it != yaml_node.end(); ++it )
115 for( YAML::Iterator it = yaml_node.begin(); it != yaml_node.end(); ++it )
123 case YAML::NodeType::Scalar:
126 #ifdef RVIZ_HAVE_YAMLCPP_05 127 s = yaml_node.as<std::string>();
131 config.
setValue( QString::fromStdString( s ));
134 case YAML::NodeType::Null:
void readYamlNode(Config &config, const YAML::Node &yaml_node)
void setValue(const QVariant &value)
Ensures this is a valid Config object, sets the type to Value then sets the value.
QString errorMessage()
Return an error message if the latest read call had an error, or the empty string if not...
void readStream(Config &config, std::istream &in, const QString &filename="data stream")
Read config data from a std::istream. This potentially changes the return value sof error()...
YamlConfigReader()
Constructor. Object begins in a no-error state.
Configuration data storage class.
void readFile(Config &config, const QString &filename)
Read config data from a file. This potentially changes the return value sof error(), statusMessage(), and config().
Config mapMakeChild(const QString &key)
Create a child node stored with the given key, and return the child.
bool error()
Return true if the latest readFile() or readString() call had an error.
Config listAppendNew()
Ensure the referenced Node is of type List, append a new Empty Node to the end of the list...
void readString(Config &config, const QString &data, const QString &filename="data string")
Read config data from a string. This potentially changes the return value sof error(), statusMessage(), and config().