17 #include <rapidjson/prettywriter.h>
18 #include <rapidjson/stringbuffer.h>
23 namespace ns_rapidjson
31 template <
class... t_Args>
44 namespace ns_rapidjson
60 ::rapidjson::StringBuffer buffer;
61 ::rapidjson::PrettyWriter<::rapidjson::StringBuffer> writer(buffer);
62 impl_->document_.Accept(writer);
63 *
impl_->output_stream_ << buffer.GetString() << std::endl;
64 impl_->output_stream_->flush();
70 impl_->getRawNode().SetObject();
77 ::rapidjson::Value key(map_name.c_str(),
impl_->document_.GetAllocator());
78 ::rapidjson::Value value;
79 impl_->getRawNode().AddMember(key, value,
impl_->document_.GetAllocator());
83 const ::rapidjson::Value::MemberIterator child = --(
impl_->getRawNode().MemberEnd());
84 impl_->emplace(&(child->value));
96 impl_->getRawNode().SetArray();
97 impl_->getRawNode().Reserve(size,
impl_->document_.GetAllocator());
98 for (std::size_t i = 0; i < size; ++i)
100 ::rapidjson::Value value;
101 impl_->getRawNode().PushBack(value,
impl_->document_.GetAllocator());
103 impl_->emplace(0, size);
111 "Internal error: array has more elements than expected.");
134 impl_->getRawNode().SetString(element.c_str(),
impl_->document_.GetAllocator());
139 impl_->getRawNode().SetBool(element);
145 if (param.fallback_to_string_floats_)
147 impl_->getRawNode().SetString(
148 boost::lexical_cast<std::string>(element).c_str(),
impl_->document_.GetAllocator());
152 impl_->getRawNode().SetDouble(element);
160 if (param.fallback_to_string_floats_)
162 impl_->getRawNode().SetString(
163 boost::lexical_cast<std::string>(element).c_str(),
impl_->document_.GetAllocator());
167 impl_->getRawNode().SetDouble(element);
173 #define ARILES2_BASIC_TYPE(type) \
174 void Writer::writeElement(const type &element, const Parameters &) \
176 impl_->getRawNode().SetInt64(element); \
181 #undef ARILES2_BASIC_TYPE
184 #define ARILES2_BASIC_TYPE(type) \
185 void Writer::writeElement(const type &element, const Parameters &) \
187 impl_->getRawNode().SetUint64(element); \
192 #undef ARILES2_BASIC_TYPE
::rapidjson::Document document_
instance of the parser
void startMap(const Parameters &, const std::size_t)
Starts a nested map in the configuration file.
void startArray(const std::size_t size, const bool=false)
void flush()
Flush the configuration to the output.
void startMapEntry(const std::string &map_name)
Starts a nested map in the configuration file.
Writer(const std::string &file_name)
std::shared_ptr< impl::Writer > ImplPtr
FileVisitorImplementation(const std::string &file_name)
void writeElement(const std::complex< t_Scalar > &entry, const Parameters ¶m)
#define CPPUT_ASSERT(condition,...)
#define ARILES2_BASIC_UNSIGNED_INTEGER_TYPES_LIST
#define ARILES2_BASIC_SIGNED_INTEGER_TYPES_LIST
#define CPPUT_MACRO_SUBSTITUTE(macro)
visitor::Parameters Parameters
#define CPPUT_TRACE_FUNCTION