1 #ifndef JSON_SPIRIT_VALUE 2 #define JSON_SPIRIT_VALUE 9 #if defined(_MSC_VER) && (_MSC_VER >= 1020) 11 # pragma warning(disable: 4505) // Unreferenced function has been removed. 20 #include <boost/config.hpp> 21 #include <boost/cstdint.hpp> 22 #include <boost/shared_ptr.hpp> 23 #include <boost/variant.hpp> 26 #define JSON_SPIRIT_VALUE_ENABLED 39 template<
class Config >
62 template<
class Iter >
65 template< BOOST_VARIANT_ENUM_PARAMS(
typename T ) >
66 Value_impl(
const boost::variant< BOOST_VARIANT_ENUM_PARAMS(
T) >& variant );
76 bool is_uint64()
const;
79 const String_type&
get_str()
const;
80 const Object& get_obj()
const;
81 const Array& get_array()
const;
82 bool get_bool()
const;
86 double get_real()
const;
98 void check_type(
const Value_type vtype )
const;
100 typedef boost::variant< boost::recursive_wrapper< Object >, boost::recursive_wrapper< Array >,
109 template<
typename T,
typename A,
template<
typename,
typename >
class Cont >
112 return Array( cont.begin(), cont.end() );
117 return static_cast< boost::int64_t
>( i );
130 template<
class Config >
140 Pair_impl(
const String_type& name,
const Value_type& value );
148 #if defined( JSON_SPIRIT_VALUE_ENABLED ) || defined( JSON_SPIRIT_WVALUE_ENABLED ) 149 template<
class String >
158 static Value_type&
add( Object_type& obj,
const String_type& name,
const Value_type& value )
160 obj.push_back( Pair_type( name , value ) );
162 return obj.back().value_;
165 static const String_type&
get_name(
const Pair_type& pair )
170 static const Value_type&
get_value(
const Pair_type& pair )
179 #ifdef JSON_SPIRIT_VALUE_ENABLED 190 #if defined( JSON_SPIRIT_WVALUE_ENABLED ) && !defined( BOOST_NO_STD_WSTRING ) 194 typedef wConfig::Pair_type wPair;
195 typedef wConfig::Object_type wObject;
196 typedef wConfig::Array_type wArray;
201 #if defined( JSON_SPIRIT_MVALUE_ENABLED ) || defined( JSON_SPIRIT_WMVALUE_ENABLED ) 202 template<
class String >
205 typedef String String_type;
207 typedef std::vector< Value_type > Array_type;
208 typedef std::map< String_type, Value_type > Object_type;
209 typedef std::pair< const String_type, Value_type > Pair_type;
211 static Value_type& add( Object_type& obj,
const String_type& name,
const Value_type& value )
213 return obj[ name ] = value;
216 static const String_type& get_name(
const Pair_type& pair )
221 static const Value_type&
get_value(
const Pair_type& pair )
230 #ifdef JSON_SPIRIT_MVALUE_ENABLED 231 typedef Config_map< std::string > mConfig;
234 typedef mConfig::Object_type mObject;
235 typedef mConfig::Array_type mArray;
240 #if defined( JSON_SPIRIT_WMVALUE_ENABLED ) && !defined( BOOST_NO_STD_WSTRING ) 241 typedef Config_map< std::wstring > wmConfig;
244 typedef wmConfig::Object_type wmObject;
245 typedef wmConfig::Array_type wmArray;
257 template<
class Config >
260 template<
class Config >
266 template<
class Config >
268 :
v_( String_type( value ) )
272 template<
class Config >
278 template<
class Config >
284 template<
class Config >
290 template<
class Config >
296 template<
class Config >
302 template<
class Config >
308 template<
class Config >
314 template<
class Config >
320 template<
class Config >
326 template<
class Config >
327 template<
class Iter >
329 :
v_( Array( first, last ) )
333 template<
class Config >
334 template< BOOST_VARIANT_ENUM_PARAMS(
typename T ) >
340 template<
class Config >
350 template<
class Config >
353 if(
this == &lhs )
return true;
355 if(
type() != lhs.
type() )
return false;
360 template<
class Config >
371 template<
class Config >
374 return v_.which() == null_type + 1;
377 template<
class Config >
383 template<
class Config >
386 if(
type() != vtype )
388 std::ostringstream os;
392 throw std::runtime_error( os.str() );
396 template<
class Config >
401 return *boost::get< String_type >( &
v_ );
404 template<
class Config >
409 return *boost::get< Object >( &
v_ );
412 template<
class Config >
417 return *boost::get< Array >( &
v_ );
420 template<
class Config >
425 return boost::get< bool >(
v_ );
428 template<
class Config >
433 return static_cast< int >(
get_int64() );
436 template<
class Config >
446 return boost::get< boost::int64_t >(
v_ );
449 template<
class Config >
459 return boost::get< boost::uint64_t >(
v_ );
462 template<
class Config >
473 return boost::get< double >(
v_ );
476 template<
class Config >
481 return *boost::get< Object >( &
v_ );
484 template<
class Config >
489 return *boost::get< Array >( &
v_ );
492 template<
class Config >
499 template<
class Config >
502 if(
this == &lhs )
return true;
509 template <
class String_type >
514 for(
const char* p = c_str; *p != 0; ++p )
526 template<
typename T >
531 template<
class Value >
537 template<
class Value >
543 template<
class Value >
549 template<
class Value >
555 template<
class Value >
561 template<
class Value >
567 template<
class Value >
573 template<
class Value >
580 template<
class Config >
581 template<
typename T >
602 return "unknown type";
boost::variant< boost::recursive_wrapper< Object >, boost::recursive_wrapper< Array >, String_type, bool, boost::int64_t, double, Null, boost::uint64_t > Variant
Definition: json_spirit_value.h:101
void check_type(const Value_type vtype) const
Definition: json_spirit_value.h:384
bool get_value(const Value &value, Type_to_type< bool >)
Definition: json_spirit_value.h:574
Variant v_
Definition: json_spirit_value.h:103
Value_impl< Config_vector > Value_type
Definition: json_spirit_value.h:153
Definition: pch_boost.h:50
Pair_impl< Config_vector > Pair_type
Definition: json_spirit_value.h:154
boost::int64_t get_int64() const
Definition: json_spirit_value.h:437
static const Value_impl null
Definition: json_spirit_value.h:94
int get_int() const
Definition: json_spirit_value.h:429
Config_vector< std::string > Config
Definition: json_spirit_value.h:180
Variant operator()(const T &t) const
Definition: json_spirit_value.h:121
Definition: json_spirit_error_position.h:15
bool is_uint64() const
Definition: json_spirit_value.h:372
static std::string value_type_to_string(const Value_type vtype)
Definition: json_spirit_value.h:587
std::vector< Pair_type > Object_type
Definition: json_spirit_value.h:156
Definition: json_spirit_value.h:37
std::vector< Value_type > Array_type
Definition: json_spirit_value.h:155
const Array & get_array() const
Definition: json_spirit_value.h:413
Value_type type() const
Definition: json_spirit_value.h:361
Config::Value_type Value_type
Definition: json_spirit_value.h:134
Config::Object_type Object
Definition: json_spirit_value.h:184
Definition: json_spirit_value.h:41
Definition: json_spirit_value.h:150
bool is_null() const
Definition: json_spirit_value.h:378
Value_type value_
Definition: json_spirit_value.h:145
Definition: json_spirit_value.h:33
const Object & get_obj() const
Definition: json_spirit_value.h:405
Config::String_type String_type
Definition: json_spirit_value.h:46
Config Config_type
Definition: json_spirit_value.h:45
String_type::const_pointer Const_str_ptr
Definition: json_spirit_value.h:49
bool operator==(const Null &, const Null &)
Definition: json_spirit_value.h:252
unsigned long long uint64_t
Definition: wposix_types.h:57
Config::Value_type Value
Definition: json_spirit_value.h:182
Definition: json_spirit_value.h:527
Value_type
Definition: json_spirit_value.h:33
Config::Object_type Object
Definition: json_spirit_value.h:47
bool operator==(const Pair_impl &lhs) const
Definition: json_spirit_value.h:500
Definition: json_spirit_value.h:105
int get_value(const Value &value, Type_to_type< int >)
Definition: json_spirit_value.h:532
String_type name_
Definition: json_spirit_value.h:144
Definition: json_spirit_value.h:33
Definition: json_spirit_value.h:33
static Value_type & add(Object_type &obj, const String_type &name, const Value_type &value)
Definition: json_spirit_value.h:158
Config::Array_type Array
Definition: json_spirit_value.h:185
Config::String_type String_type
Definition: json_spirit_value.h:133
bool get_bool() const
Definition: json_spirit_value.h:421
String_type to_str(const char *c_str)
Definition: json_spirit_value.h:510
#define T(string_literal)
Definition: secure_crt.cpp:77
Definition: json_spirit_value.h:33
T get_value() const
Definition: json_spirit_value.h:582
double get_real() const
Definition: json_spirit_value.h:463
const String_type & get_str() const
Definition: json_spirit_value.h:397
Config::Array_type Array
Definition: json_spirit_value.h:48
Definition: json_spirit_value.h:33
String String_type
Definition: json_spirit_value.h:152
Value_impl()
Definition: json_spirit_value.h:261
Pair_impl()
Definition: json_spirit_value.h:136
Variant operator()(const Cont< T, A > &cont) const
Definition: json_spirit_value.h:110
static const Value_type & get_value(const Pair_type &pair)
Definition: json_spirit_value.h:170
static const String_type & get_name(const Pair_type &pair)
Definition: json_spirit_value.h:165
Definition: json_spirit_value.h:33
Definition: json_spirit_value.h:131
Definition: json_spirit_value.h:33
Value_impl & operator=(const Value_impl &lhs)
Definition: json_spirit_value.h:341
std::string get_str(std::string::const_iterator begin, std::string::const_iterator end)
Definition: json_spirit_reader_template.h:176
bool operator==(const Value_impl &lhs) const
Definition: json_spirit_value.h:351
boost::uint64_t get_uint64() const
Definition: json_spirit_value.h:450
Config::Pair_type Pair
Definition: json_spirit_value.h:183
Variant operator()(int i) const
Definition: json_spirit_value.h:115
long long int64_t
Definition: wposix_types.h:48