Scarab  v3.4.0
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 "param.hh"
12 
13 #include "scarab_api.hh"
14 
15 #include "factory.hh"
16 
17 #include <memory>
18 #include <string>
19 
20 namespace scarab
21 {
22 
23 #define REGISTER_PARAM_INPUT_CODEC(codec_class, encoding) \
24  static registrar< param_input_codec, codec_class > s_param_input_codec##codec_class##_registrar( encoding );
25 
27  {
28  public:
30  virtual ~param_input_codec();
31 
32  virtual param_ptr_t read_file( const std::string& a_filename, const param_node& a_options = param_node() ) = 0;
33  virtual param_ptr_t read_string( const std::string& a_string, const param_node& a_options = param_node() ) = 0;
34  };
35 
36 
38  {
39  public:
41  virtual ~param_output_codec();
42 
43  virtual bool write_file( const param& a_param, const std::string& a_filename, const param_node& a_options = param_node() ) = 0;
44  virtual bool write_string( const param& a_param, std::string& a_string, const param_node& a_options = param_node() ) = 0;
45  };
46 
47 #define REGISTER_PARAM_OUTPUT_CODEC(codec_class, encoding) \
48  static registrar< param_output_codec, codec_class > s_param_output_codec##codec_class##_registrar( encoding );
49 
50 
52  {
53  public:
56 
57  public:
58  param_ptr_t read_file( const std::string& a_filename, const param_node& a_options = param_node() );
59  param_ptr_t read_string( const std::string& a_string, const param_node& a_options = param_node() );
60 
61  public:
62  bool write_file( const param& a_param, const std::string& a_filename, const param_node& a_options = param_node() );
63  bool write_string( const param& a_param, std::string& a_string, const param_node& a_options = param_node() );
64  };
65 
66 
67 
68 } /* namespace scarab */
69 
70 #endif /* SCARAB_PARAM_CODEC_HH_ */
#define SCARAB_API
Definition: scarab_api.hh:24
std::unique_ptr< param > param_ptr_t
Definition: param_base.hh:23