26 #include "xml_node.hpp" 
   27 #include "casadi_misc.hpp" 
   38     if (c.name == childname) 
return true;
 
   47   for (; it != this->
children.end(); ++it) {
 
   48     if (it->name == childname) 
break;
 
   51   casadi_assert(it != this->
children.end(), 
"Could not find " + childname);
 
   57   return const_cast<XmlNode*
>(
this)->
operator[](childname); 
 
   68     for (
size_t i = 1; i < att.size(); ++i) ss << 
" " << att.at(i);
 
   75   ss << std::scientific << std::setprecision(std::numeric_limits<double>::digits10 + 1) << att;
 
   86   stream << std::string(indent, 
' ') << 
"Node: " << this->
name << std::endl;
 
   90     stream << std::string(indent, 
' ') << 
"----- comment starts ----- "  << std::endl;
 
   91     stream << this->
comment << std::endl;
 
   92     stream << std::string(indent, 
' ') << 
"----- comment ends ----- "  << std::endl;
 
   96   if (!this->
text.empty())
 
   97     stream << std::string(indent+2, 
' ') << 
"Text: " << this->
text << std::endl;
 
  100   for (
auto it = this->
attributes.begin(); it != this->attributes.end(); ++it)
 
  101     stream << std::string(indent+2, 
' ') << 
"attribute " << it->first
 
  102       << 
" = " << it->second << std::endl;
 
  105   for (casadi_int i=0; i < 
size(); ++i) {
 
  106     stream << std::string(indent, 
' ') << 
"Child " << i << 
":" << std::endl;
 
  107     (*this)[i].dump(stream, indent+2);
 
  118   } 
else if (
str == 
"false") {
 
  121     casadi_error(
"XML argument not 'true' or 'false'");
 
  126   std::istringstream buffer(
str);
 
  131   std::istringstream buffer(
str);
 
  136   std::istringstream buffer(
str);
 
  142   std::istringstream buffer(
str);
 
  146     if (buffer.fail()) 
break;
 
  153   std::istringstream buffer(
str);
 
  157     if (buffer.fail()) 
break;
 
  163   std::vector<std::string> ret;
 
  165   for (
auto& c : this->
children) ret.push_back(c.name);
 
  170   std::vector<std::string> ret;
 
  172   for (
auto& a : this->
attributes) ret.push_back(a.first);
 
std::ostream & operator<<(std::ostream &stream, const XmlNode &node)
 
std::string str(const T &v)
String representation, any type.
 
std::vector< std::string > attribute_names() const
Names of attributes.
 
void set_attribute(const std::string &att_name, const std::string &att)
Add an attribute.
 
std::vector< XmlNode > children
 
std::vector< std::string > child_names() const
Names of children.
 
T attribute(const std::string &att_name) const
Get an attribute by its name.
 
bool has_child(const std::string &childname) const
Check if a child is present.
 
bool has_attribute(const std::string &att_name) const
Check if an attribute is present.
 
std::map< std::string, std::string > attributes
 
const XmlNode & operator[](size_t i) const
Get a reference to a child by its index.
 
size_t size() const
Get the number of children.
 
static void read(const std::string &str, std::string *val)
Read the string value of a string (i.e. copy)
 
void dump(std::ostream &stream, casadi_int indent=0) const
Dump representation.