5#include <libxml++/libxml++.h>
6#include <boost/lexical_cast.hpp>
13#if LIBXMLXX_MAJOR_VERSION == 2
23 current_node_ =
parser.Document()->get_root_node();
32 while (!spawned_children_.empty()) {
34 spawned_children_.erase(spawned_children_.begin());
45 const xmlpp::Node::NodeList
nodelist = current_node_->get_children();
46 xmlpp::Node::NodeList::const_iterator
it;
58 return current_node_->find(
query).size();
64 using xmlpp::TextNode;
68 throw KeyError(
"Could not find a node by the name: " +
query);
71 if (
nodeset.size() < index + 1) {
80 " is not an Element node.");
86 " has more content than expected.");
90 dynamic_cast<const xmlpp::TextNode*
>(
element->get_children().front());
96 return text->get_content();
103 std::vector<xmlpp::Element*>
elements;
104 const Node::NodeList
nodelist = current_node_->get_children();
105 Node::NodeList::const_iterator
it;
107 xmlpp::Element*
element =
dynamic_cast<xmlpp::Element*
>(*it);
113 throw ValueError(
"Index exceeds number of elements in node: "
114 + current_node_->get_name());
116 return elements.at(index)->get_name();
125 if (
nodeset.size() < index + 1) {
129 xmlpp::Element*
element =
dynamic_cast<xmlpp::Element*
>(
nodeset.at(index));
133 " is not an Element node.");
For failed casts that shouldn't.
A class for extracting information from a given XML parser.
virtual InfileTree * GetEngineFromQuery(std::string query, int index)
every derived infile must return a new instance initialized by a query.
InfileTree(XMLParser &parser)
constructor given a parser
virtual int NMatches(std::string query)
investigates the current status and returns the number of elements matching a query
virtual std::string GetElementName(int index=0)
investigates the current status and returns a string representing the name of a given index
InfileTree * SubTree(std::string query, int index=0)
populates a child infile based on a query and index
virtual std::string GetString(std::string query, int index=0)
investigates the current status and returns a string representing the content of a query at a given i...
For failed retrieval/insertion of key-based data into/from data structures.
For values that are too big, too small, etc.
A helper class to hold xml file data and provide automatic validation.
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
xmlpp::Node::NodeSet NodeSet
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters
xmlpp::Node::const_NodeList const_NodeList