Go to the documentation of this file.
9 #include <boost/make_shared.hpp>
24 #include <boost/filesystem.hpp>
60 if (
cfg_->getLabel(name, label) &&
cfg_->nodes[
idx_]->readGroup(label, child_idx))
63 if (
cfg_->nodes[child_idx]->type() == type)
71 addError(
"Expected group: '" + name +
"', found none.");
84 if (parent ==
static_cast<NodeIdx>(-1))
104 if (right_sibling ==
static_cast<NodeIdx>(-1))
107 idx_ = right_sibling;
126 if (
cfg_->getLabel(name, label) &&
cfg_->nodes[
idx_]->readGroup(label, child_idx))
129 return cfg_->nodes[child_idx]->type() == type;
152 while(c !=
static_cast<NodeIdx>(-1))
156 c =
cfg_->getParent(c);
159 if (context.
size() > 1)
163 for(
int i = context.
size() - 2; i > 0; --i)
165 error_msg += context[i] +
".";
168 error_msg += context[0] +
"': \n\n";
172 error_msg +=
"In root of configuration:\n\n";
176 error_msg +=
" " + msg +
"\n\n";
228 NodePtr node = boost::make_shared<Map>(
"");
232 if (!
cfg_->nodes[
idx_]->add(n, previous))
235 if (previous !=
static_cast<NodeIdx>(-1))
236 cfg_->setRightSibling(previous, n);
248 if (parent ==
static_cast<NodeIdx>(-1))
335 catch (boost::filesystem::filesystem_error& e)
343 if ( extension ==
".sdf" || extension ==
".world")
345 else if (extension ==
".xml")
347 else if (extension ==
".yml" || extension ==
".yaml")
350 std::cout <<
"[ReaderWriter::Sync] extension: '" << extension <<
"' is not supported." <<
std::endl;
bool loadFromSDFFile(const std::string &filename)
loadFromSDFFile loads a sdf file into a ReaderWriter class
bool endArrayItem()
endArrayItem go back to the array level
bool loadFromXMLFile(const std::string &filename, ReaderWriter &config)
loadFromXMLFile loads a xml file into a ReaderWriter class
std::string extension() const
bool writeArray(const std::string &name)
writeArray starts writing an array. Or start extending it, if it already exists.
bool next()
next go to next item in an array
bool loadFromYAMLFile(const std::string &filename, const ResolveConfig &resolve_config=ResolveConfig::defaultConfig())
loadFromYAMLFile loads a yaml file into a ReaderWriter class
bool writeGroup(const std::string &name)
writeGroup starts writing a group. Or start extending it, if it already exists.
bool addArrayItem()
addArrayItem create a new item in the array
std::ostream & operator<<(std::ostream &out, const DataConstPointer &d)
bool loadFromXMLFile(const std::string &filename)
loadFromXMLFile loads a xml file into a ReaderWriter class
bool loadFromYAMLFile(const std::string &filename, ReaderWriter &config, const ResolveConfig &resolve_config=ResolveConfig::defaultConfig())
loadFromYAMLFile loads a yaml file into a ReaderWriter class
std::string toYAMLString() const
toYAMLString convert data (from current reading/writing point) to yaml string
bool sync()
sync re-read the source file if the file has changed since last reading time.
bool end()
end go to parent node.
boost::shared_ptr< Data > cfg_
ResolveConfig resolve_config_
bool read(const std::string &name, const NodeType type, RequiredOrOptional opt=OPTIONAL)
read read child with key 'name' of type ARRAY or MAP
boost::shared_ptr< Error > error_
boost::shared_ptr< Data > data
bool loadFromSDFFile(const std::string &filename, ReaderWriter &config)
loadFromSDFFile loads a sdf file into a ReaderWriter class
void addError(const std::string &msg)
ReaderWriter limitScope() const
limitScope Limit the data to the current position. All parents and siblings incl. their child aren't ...
void emit(const tue::config::DataConstPointer &cfg, std::ostream &out, const std::string &indent="")
boost::shared_ptr< std::string > error_context_
bool hasChild(const std::string &name, NodeType type) const
hasChild check if node has a child with key 'name' and type ARRAY or MAP
boost::shared_ptr< Node > NodePtr
Class to config the resolve behaviour of a loader.
std::time_t source_last_write_time_
std::time_t lastWriteTime() const
tue::config::ReaderWriter config