Scarab  v3.4.4
Project 8 C++ Utility Library
param_value.cc
Go to the documentation of this file.
1 /*
2  * param_value.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_value.hh"
15 
16 #include "param_base_impl.hh"
17 
18 //#include "logger.hh"
19 //LOGGER( dlog, "param_value" )
20 
21 namespace scarab
22 {
23 
25  param(),
26  f_value( false )
27  {
28  //LWARN( dlog, "param_value constructor: default (bool)" );
29  }
30 
31  param_value::param_value( bool a_value ) :
32  param(),
33  f_value( a_value )
34  {
35  f_value = a_value;
36  //LWARN( dlog, "param_value constructor: bool --> bool" );
37  }
38 
39  param_value::param_value( uint8_t a_value ) :
40  param(),
41  f_value( uint64_t(a_value) )
42  {
43  //LWARN( dlog, "param_value constructor: uint8 --> uint" );
44  }
45 
46  param_value::param_value( uint16_t a_value ) :
47  param(),
48  f_value( uint64_t(a_value) )
49  {
50  //LWARN( dlog, "param_value constructor: uint16 --> uint" );
51  }
52 
53  param_value::param_value( uint32_t a_value ) :
54  param(),
55  f_value( uint64_t(a_value) )
56  {
57  //LWARN( dlog, "param_value constructor: uint32 --> uint" );
58  }
59 
60  param_value::param_value( uint64_t a_value ) :
61  param(),
62  f_value( uint64_t(a_value) )
63  {
64  //LWARN( dlog, "param_value constructor: uint64 --> uint" );
65  }
66 
67  param_value::param_value( int8_t a_value ) :
68  param(),
69  f_value( int64_t(a_value) )
70  {
71  //LWARN( dlog, "param_value constructor: int8 --> int" );
72  }
73 
74  param_value::param_value( int16_t a_value ) :
75  param(),
76  f_value( int64_t(a_value) )
77  {
78  //LWARN( dlog, "param_value constructor: int16 --> int" );
79  }
80 
81 
82  param_value::param_value( int32_t a_value ) :
83  param(),
84  f_value( int64_t(a_value) )
85  {
86  //LWARN( dlog, "param_value constructor: int32 --> int" );
87  }
88 
89  param_value::param_value( int64_t a_value ) :
90  param(),
91  f_value( a_value )
92  {
93  //LWARN( dlog, "param_value constructor: int64 --> int" );
94  }
95 
96  param_value::param_value( float a_value ) :
97  param(),
98  f_value( double(a_value) )
99  {
100  //LWARN( dlog, "param_value constructor: float --> double" );
101  }
102 
103  param_value::param_value( double a_value ) :
104  param(),
105  f_value( a_value )
106  {
107  //LWARN( dlog, "param_value constructor: double --> double" );
108  }
109 
110  param_value::param_value( const char* a_value ) :
111  param(),
112  f_value( string() )
113  {
114  //LWARN( dlog, "param_value constructor: char* --> k_string" );
115  string t_value( a_value );
116  if( t_value.size() > 1 && t_value.front() == '\'' && t_value.back() == '\'' )
117  {
118  f_value = t_value.substr( 1, t_value.size() - 2 );
119  }
120  else
121  {
122  f_value = t_value;
123  }
124  }
125 
126  param_value::param_value( const string& a_value ) :
127  param(),
128  f_value( a_value )
129  {
130  //LWARN( dlog, "param_value constructor: string --> k_string" );
131  if( a_value.size() > 1 && a_value.front() == '\'' && a_value.back() == '\'' )
132  {
133  f_value = a_value.substr( 1, a_value.size() - 2 );
134  }
135  else
136  {
137  f_value = a_value;
138  }
139  }
140 
142  param( orig ),
143  f_value( orig.f_value )
144  {
145  //LWARN( dlog, "param_value copy constructor: " << type() );
146  }
147 
149  param( std::move( orig ) ),
150  f_value( std::move( orig.f_value ) )
151  {
152  }
153 
155  {
156  }
157 
159  {
160  if( &rhs == this ) return *this;
161 
162  f_value = rhs.f_value;
163 
164  return *this;
165  }
166 
168  {
169  if( &rhs == this ) return *this;
170 
171  f_value = std::move( rhs.f_value );
172 
173  return *this;
174  }
175 
176  bool param_value::has_subset( const param& a_subset ) const
177  {
178  if( ! a_subset.is_value() ) return false;
179  return true;
180  }
181 
182  SCARAB_API std::ostream& operator<<(std::ostream& out, const param_value& a_value)
183  {
184  return out << a_value.as_string();
185  }
186 
187 } /* namespace scarab */
virtual bool is_value() const
#define SCARAB_API
Definition: scarab_api.hh:24
STL namespace.
boost::variant< bool, uint64_t, int64_t, double, std::string > f_value
Definition: param_value.hh:96
virtual bool has_subset(const param &a_subset) const
Definition: param_value.cc:176
SCARAB_API std::ostream & operator<<(std::ostream &out, const param_array &a_value)
Definition: param_array.cc:167
virtual ~param_value()
Definition: param_value.cc:154
std::string as_string() const
Definition: param_value.hh:534
param_value & operator=(const param_value &rhs)
Definition: param_value.cc:158