Scarab  v2.4.7
Project 8 C++ Utility Library
param_base.hh
Go to the documentation of this file.
1 /*
2  * param_base.hh
3  *
4  * Created on: Jan 14, 2014
5  * Author: nsoblath
6  */
7 
8 #ifndef SCARAB_PARAM_BASE_HH_
9 #define SCARAB_PARAM_BASE_HH_
10 
11 #include "error.hh"
12 
13 #include <memory>
14 #include <sstream>
15 #include <string>
16 
17 namespace scarab
18 {
19  class param_value;
20  class param_array;
21  class param_node;
22 
23  class param;
24  typedef std::unique_ptr< param > param_ptr_t;
25 
27  {
28  public:
29  param();
30  param( const param& orig );
31  param( param&& orig );
32  virtual ~param();
33 
34  param& operator=( const param& rhs );
35  param& operator=( param&& );
36 
37  virtual param_ptr_t clone() const;
38  virtual param_ptr_t move_clone();
39 
40  virtual bool is_null() const;
41  virtual bool is_value() const;
42  virtual bool is_array() const;
43  virtual bool is_node() const;
44 
45  virtual bool has_subset( const param& a_subset ) const;
46 
47  param_value& as_value();
48  param_array& as_array();
49  param_node& as_node();
50 
51  const param_value& as_value() const;
52  const param_array& as_array() const;
53  const param_node& as_node() const;
54 
56  const param_value& operator()() const;
58  param_value& operator()();
59 
62  const param& operator[]( unsigned a_index ) const;
65  param& operator[]( unsigned a_index );
66 
69  const param& operator[]( const std::string& a_name ) const;
72  param& operator[]( const std::string& a_name );
73 
77  std::string get_value( const std::string& a_name, const std::string& a_default ) const;
78  std::string get_value( const std::string& a_name, const char* a_default ) const;
82  template< typename XValType >
83  XValType get_value( const std::string& a_name, XValType a_default ) const;
84 
88  std::string get_value( unsigned a_index, const std::string& a_default ) const;
89  std::string get_value( unsigned a_index, const char* a_default ) const;
93  template< typename XValType >
94  XValType get_value( unsigned a_index, XValType a_default ) const;
95 
96  void merge( const param& a_param );
97 
98  virtual std::string to_string() const;
99 
100  static unsigned s_indent_level;
101  };
102 
103  SCARAB_API std::ostream& operator<<(std::ostream& out, const param& value);
104 
105 } /* namespace scarab */
106 
107 #endif /* SCARAB_PARAM_BASE_HH_ */
#define SCARAB_API
Definition: scarab_api.hh:24
static unsigned s_indent_level
Definition: param_base.hh:100
SCARAB_API std::ostream & operator<<(std::ostream &out, const param_array &a_value)
Definition: param_array.cc:167
std::unique_ptr< param > param_ptr_t
Definition: param_base.hh:23
std::string to_string(std::uint64_t x)
Definition: date.h:7722