36 explicit Writer(
const std::string &file_name)
39 output_stream_ = &config_ofs_;
40 node_stack_.push_back(document_);
44 explicit Writer(std::ostream &output_stream)
46 output_stream_ = &output_stream;
47 node_stack_.push_back(document_);
58 return (node_stack_.back().node_);
85 impl_->document_.save(*
impl_->output_stream_,
" ", pugi::format_indent);
86 impl_->output_stream_->flush();
92 impl_->node_stack_.push_back(
impl_->getRawNode().append_child(map_name.c_str()));
97 impl_->node_stack_.pop_back();
106 impl_->node_stack_.push_back(
impl_->getRawNode().append_child(
"item"));
112 impl_->node_stack_.pop_back();
113 ARILES_ASSERT(
true ==
impl_->node_stack_.back().isArray(),
"Internal error: expected array.");
115 impl_->node_stack_.back().index_ <
impl_->node_stack_.back().size_,
116 "Internal error: array has more elements than expected.");
117 ++
impl_->node_stack_.back().index_;
118 if (
impl_->node_stack_.back().index_ <
impl_->node_stack_.back().size_)
120 impl_->node_stack_.push_back(
impl_->getRawNode().append_child(
"item"));
126 impl_->node_stack_.pop_back();
133 if (
true == name.empty())
150 void Writer::writeElement(
const std::string &element)
152 impl_->getRawNode().text() = element.c_str();
156 #define ARILES_BASIC_TYPE(type) \ 157 void Writer::writeElement(const type &element) \ 159 impl_->getRawNode().text() = (boost::lexical_cast<std::string>(element)).c_str(); \ 164 #undef ARILES_BASIC_TYPE Writer(const std::string &file_name)
#define ARILES_TRACE_FUNCTION
pugi::xml_document document_
std::ofstream config_ofs_
output file stream
ARILES_MACRO_SUBSTITUTE(ARILES_BASIC_INTEGER_TYPES_LIST) ARILES_MACRO_SUBSTITUTE(ARILES_BASIC_REAL_TYPES_LIST) void Writer
void startArray(const std::size_t size, const bool=false)
void endRoot(const std::string &name)
Writer(std::ostream &output_stream)
std::vector< NodeWrapper > node_stack_
Writer(const std::string &file_name)
void descend(const std::string &map_name)
Starts a nested map in the configuration file.
void flush()
Flush the configuration to the output.
static void openFile(std::ofstream &config_ofs, const std::string &file_name)
open configuration file
std::ostream * output_stream_
output stream
void startRoot(const std::string &name)
pugi::xml_node & getRawNode()
Get current node.
ariles::Node< pugi::xml_node > NodeWrapper
#define ARILES_BASIC_NUMERIC_TYPES_LIST
#define ARILES_VISIBILITY_ATTRIBUTE
ARILES_SHARED_PTR< impl::Writer > ImplPtr