Scarab  v1.5.2
Project 8 C++ Utility Library
param_codec.hh
Go to the documentation of this file.
1 /*
2  * param_codec.hh
3  *
4  * Created on: Aug 10, 2016
5  * Author: obla999
6  */
7 
8 #ifndef SCARAB_PARAM_CODEC_HH_
9 #define SCARAB_PARAM_CODEC_HH_
10 
11 #include "scarab_api.hh"
12 
13 #include "factory.hh"
14 
15 #include <string>
16 
17 namespace scarab
18 {
19  class param;
20  class param_node;
21 
22 #define REGISTER_PARAM_INPUT_CODEC(codec_class, encoding) \
23  static registrar< param_input_codec, codec_class > s_param_input_codec##codec_class##_registrar( encoding );
24 
26  {
27  public:
29  virtual ~param_input_codec();
30 
31  virtual param* read_file( const std::string& a_filename, const param_node* a_options = nullptr ) = 0;
32  virtual param* read_string( const std::string& a_string, const param_node* a_options = nullptr ) = 0;
33  };
34 
35 
37  {
38  public:
40  virtual ~param_output_codec();
41 
42  virtual bool write_file( const param& a_param, const std::string& a_filename, const param_node* a_options = nullptr ) = 0;
43  virtual bool write_string( const param& a_param, std::string& a_string, const param_node* a_options = nullptr ) = 0;
44  };
45 
46 #define REGISTER_PARAM_OUTPUT_CODEC(codec_class, encoding) \
47  static registrar< param_output_codec, codec_class > s_param_output_codec##codec_class##_registrar( encoding );
48 
49 
51  {
52  public:
55 
56  public:
57  param* read_file( const std::string& a_filename, const param_node* a_options = nullptr );
58  param* read_string( const std::string& a_string, const param_node* a_options = nullptr );
59 
60  public:
61  bool write_file( const param& a_param, const std::string& a_filename, const param_node* a_options = nullptr );
62  bool write_string( const param& a_param, std::string& a_string, const param_node* a_options = nullptr );
63  };
64 
65 
66 
67 } /* namespace scarab */
68 
69 #endif /* SCARAB_PARAM_CODEC_HH_ */
#define SCARAB_API
Definition: scarab_api.hh:24