Scarab  v3.5.3
Project 8 C++ Utility Library
param_base.cc
Go to the documentation of this file.
1 /*
2  * param_base.cc
3  *
4  * Created on: Jan 14, 2014
5  * Author: nsoblath
6  */
7 
8 #define SCARAB_API_EXPORTS
9 
10 #include <sstream>
11 using std::string;
12 using std::stringstream;
13 
14 #include "param_base.hh"
15 
16 #include "param_base_impl.hh"
17 
18 namespace scarab
19 {
20 
21  SCARAB_API unsigned param::s_indent_level = 0;
22 
24  {
25  }
26 
27  param::param( const param& )
28  {
29  }
30 
32  {
33  }
34 
36  {
37  }
38 
39  inline void param::merge( const param& a_param )
40  {
41  if( is_node() && a_param.is_node() )
42  {
43  as_node().merge( a_param.as_node() );
44  return;
45  }
46  if( is_array() && a_param.is_array() )
47  {
48  as_array().merge( a_param.as_array() );
49  return;
50  }
51  if( is_value() && a_param.is_value() )
52  {
53  as_value() = a_param.as_value();
54  return;
55  }
56  if( is_null() && a_param.is_null() ) return;
57  throw error() << "Invalid merge command with incompatible param types";
58  }
59 
60  SCARAB_API std::ostream& operator<<(std::ostream& out, const param& a_value)
61  {
62  return out << a_value.to_string();
63  }
64 
65 } /* namespace scarab */
void merge(const param_node &a_object)
Definition: param_node.cc:90
virtual bool is_value() const
#define SCARAB_API
Definition: scarab_api.hh:24
void merge(const param &a_param)
Definition: param_base.cc:39
void merge(const param_array &an_array)
Definition: param_array.cc:105
virtual ~param()
Definition: param_base.cc:35
static unsigned s_indent_level
Definition: param_base.hh:100
virtual bool is_null() const
param_value & as_value()
virtual bool is_array() const
SCARAB_API std::ostream & operator<<(std::ostream &out, const param_array &a_value)
Definition: param_array.cc:167
virtual bool is_node() const
param_node & as_node()
param_array & as_array()
virtual std::string to_string() const