Ariles
writer.h
Go to the documentation of this file.
1 /**
2  @file
3  @author Alexander Sherikov
4 
5  @copyright 2014-2017 INRIA. Licensed under the Apache License, Version 2.0.
6  (see @ref LICENSE or http://www.apache.org/licenses/LICENSE-2.0)
7 
8  @copyright 2017-2018 Alexander Sherikov, Licensed under the Apache License, Version 2.0.
9  (see @ref LICENSE or http://www.apache.org/licenses/LICENSE-2.0)
10 
11  @brief
12 */
13 
14 #pragma once
15 
16 namespace ariles2
17 {
18  namespace ns_msgpack
19  {
20  namespace impl
21  {
22  class Writer;
23  }
24 
25 
26  /**
27  * @brief Configuration writer class
28  */
29  class Writer : public serialization::PIMPLVisitor<write::Visitor, impl::Writer>
30  {
31  public:
32  /**
33  * @brief Constructor
34  *
35  * @param[in] file_name
36  */
37  explicit Writer(const std::string &file_name);
38 
39 
40  /**
41  * @brief Constructor
42  *
43  * @param[out] output_stream
44  */
45  explicit Writer(std::ostream &output_stream);
46 
47 
48  void startMap(const Parameters &, const std::size_t num_entries);
49  void startMapEntry(const std::string &map_name);
50 
51 
52  bool startIteratedMap(const std::size_t /*num_entries*/, const Parameters &)
53  {
54  return (false);
55  }
56 
57 
58  void flush();
59 
60 
61  void startArray(const std::size_t size, const bool /*compact*/ = false);
62 
63 
64  void startRoot(const std::string &name, const Parameters &);
65  void endRoot(const std::string &name);
66 
67 
68 #define ARILES2_BASIC_TYPE(type) void writeElement(const type &element, const Parameters &param);
69 
71 
72 #undef ARILES2_BASIC_TYPE
73  };
74  } // namespace ns_msgpack
75 } // namespace ariles2
Configuration writer class.
Definition: writer.h:30
bool startIteratedMap(const std::size_t, const Parameters &)
Definition: writer.h:52
void startMapEntry(const std::string &map_name)
Starts a nested map in the configuration file.
Definition: writer.cpp:76
void startArray(const std::size_t size, const bool=false)
Definition: writer.cpp:91
void startMap(const Parameters &, const std::size_t num_entries)
Starts a nested map in the configuration file.
Definition: writer.cpp:70
void startRoot(const std::string &name, const Parameters &)
Definition: writer.cpp:100
void flush()
Flush the configuration to the output.
Definition: writer.cpp:84
Writer(const std::string &file_name)
Constructor.
Definition: writer.cpp:58
void endRoot(const std::string &name)
Definition: writer.cpp:119
t_Parameters Parameters
Definition: common.h:49
#define ARILES2_BASIC_TYPES_LIST
Definition: helpers.h:72
#define CPPUT_MACRO_SUBSTITUTE(macro)
Definition: misc.h:21
GenericWriter< NameValuePair > Writer
Definition: writer.h:252
Definition: basic.h:17