36 return (node_stack_.back().node_);
52 pugi::xml_parse_result result =
impl_->document_.load_file(file_name.c_str(), pugi::parse_minimal);
54 true == result, std::string(
"Parsing of '") + file_name +
"' failed: " + result.description());
55 impl_->node_stack_.push_back(
impl_->document_);
63 pugi::xml_parse_result result =
impl_->document_.load(input_stream, pugi::parse_minimal);
64 ARILES_ASSERT(
true == result, std::string(
"Parsing failed: ") + result.description());
65 impl_->node_stack_.push_back(
impl_->document_);
72 for (pugi::xml_node_iterator it =
impl_->getRawNode().begin(); it !=
impl_->getRawNode().end();
75 for (pugi::xml_attribute attribute =
impl_->getRawNode().first_attribute(); attribute;
76 attribute = attribute.next_attribute(), ++size)
84 const pugi::xml_node child =
impl_->getRawNode().child(child_name.c_str());
88 impl_->node_stack_.push_back(child);
93 const pugi::xml_attribute attribute =
impl_->getRawNode().attribute(child_name.c_str());
96 pugi::xml_node new_child =
impl_->getRawNode().append_child(child_name.c_str());
97 new_child.text() = attribute.value();
98 impl_->node_stack_.push_back(new_child);
111 impl_->node_stack_.pop_back();
117 const pugi::xml_node node =
impl_->getRawNode();
119 for (pugi::xml_node_iterator it = node.begin(); it != node.end(); ++it)
121 child_names.push_back(it->name());
129 std::size_t size = 0;
130 const pugi::xml_node node =
impl_->getRawNode();
131 for (pugi::xml_node child = node.child(
"item"); child; child = child.next_sibling(
"item"), ++size)
143 for (pugi::xml_node child =
impl_->getRawNode(); child;
144 child = child.next_sibling(child.name()), ++size)
155 ARILES_ASSERT(
true ==
impl_->node_stack_.back().isArray(),
"Internal error: expected array.");
157 impl_->node_stack_.back().index_ <
impl_->node_stack_.back().size_,
158 "Internal error: array has more elements than expected.");
159 impl_->node_stack_.back().node_ =
impl_->getRawNode().next_sibling(
impl_->getRawNode().name());
160 ++
impl_->node_stack_.back().index_;
166 impl_->node_stack_.pop_back();
173 if (
true == name.empty())
190 void Reader::readElement(std::string &element)
192 element =
impl_->getRawNode().text().as_string();
196 #define ARILES_BASIC_TYPE(type) \ 197 void Reader::readElement(type &element) \ 199 ARILES_ASSERT(false == impl_->getRawNode().text().empty(), "Empty integer elements are not allowed."); \ 200 element = boost::lexical_cast<type>(impl_->getRawNode().text().as_string()); \ 205 #undef ARILES_BASIC_TYPE
#define ARILES_TRACE_FUNCTION
pugi::xml_node & getRawNode()
Get current node.
void endRoot(const std::string &name)
std::size_t getMapSize(const bool)
bool descend(const std::string &child_name)
Descend to the entry with the given name.
Reader(const std::string &file_name)
Constructor.
ARILES_MACRO_SUBSTITUTE(ARILES_BASIC_SIGNED_INTEGER_TYPES_LIST) ARILES_MACRO_SUBSTITUTE(ARILES_BASIC_UNSIGNED_INTEGER_TYPES_LIST) ARILES_MACRO_SUBSTITUTE(ARILES_BASIC_REAL_TYPES_LIST) void Reader
bool getMapEntryNames(std::vector< std::string > &child_names)
ariles::Node< pugi::xml_node > NodeWrapper
pugi::xml_document document_
bool startRoot(const std::string &name)
void ascend()
Ascend from the current entry to its parent.
#define ARILES_BASIC_NUMERIC_TYPES_LIST
#define ARILES_VISIBILITY_ATTRIBUTE
std::vector< NodeWrapper > node_stack_
ARILES_SHARED_PTR< impl::Reader > ImplPtr