14 #include <msgpack.hpp> 28 void operator=(
const Writer &);
44 explicit Writer(
const std::string &file_name)
47 output_stream_ = &config_ofs_;
48 packer_ = new ::msgpack::packer<std::ostream>(*output_stream_);
50 nameless_counter_ = 0;
54 explicit Writer(std::ostream &output_stream)
56 output_stream_ = &output_stream;
57 packer_ = new ::msgpack::packer<std::ostream>(*output_stream_);
59 nameless_counter_ = 0;
93 impl_->packer_->pack(map_name);
100 impl_->packer_->pack_map(num_entries);
107 impl_->output_stream_->flush();
114 ARILES_ASSERT(size <= std::numeric_limits<uint32_t>::max(),
"Vector is too long.");
116 impl_->packer_->pack_array(size);
123 if (
true == name.empty())
126 0 ==
impl_->nameless_counter_,
127 "Multiple nameless root entries are not supported, specify root names explicitly.");
128 ++
impl_->nameless_counter_;
129 impl_->packer_->pack_map(1);
134 impl_->packer_->pack_map(1);
146 #define ARILES_BASIC_TYPE(type) \ 147 void Writer::writeElement(const type &element) \ 149 ARILES_TRACE_FUNCTION; \ 150 impl_->packer_->pack(element); \ 155 #undef ARILES_BASIC_TYPE #define ARILES_TRACE_FUNCTION
Writer(const std::string &file_name)
void flush()
Flush the configuration to the output.
ARILES_MACRO_SUBSTITUTE(ARILES_BASIC_INTEGER_TYPES_LIST) ARILES_MACRO_SUBSTITUTE(ARILES_BASIC_REAL_TYPES_LIST) void Writer
std::ofstream config_ofs_
output file stream
#define ARILES_BASIC_TYPES_LIST
void startMap(const std::size_t num_entries)
Starts a nested map in the configuration file.
std::ostream * output_stream_
output stream
static void openFile(std::ofstream &config_ofs, const std::string &file_name)
open configuration file
void startArray(const std::size_t size, const bool=false)
class ARILES_VISIBILITY_ATTRIBUTE Writer
::msgpack::packer< std::ostream > * packer_
void endRoot(const std::string &name)
Writer(std::ostream &output_stream)
void descend(const std::string &map_name)
Starts a nested map in the configuration file.
#define ARILES_VISIBILITY_ATTRIBUTE
void startRoot(const std::string &name)
ARILES_SHARED_PTR< impl::Writer > ImplPtr
#define ARILES_TRACE_ENTRY(entry_name)
Writer(const std::string &file_name)
Constructor.
std::size_t nameless_counter_