1#ifndef JSON_SPIRIT_VALUE
2#define JSON_SPIRIT_VALUE
9#if defined(_MSC_VER) && (_MSC_VER >= 1020)
11# pragma warning(disable: 4505)
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 );
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() );
130 template<
class Config >
148#if defined( JSON_SPIRIT_VALUE_ENABLED ) || defined( JSON_SPIRIT_WVALUE_ENABLED )
149 template<
class String >
160 obj.push_back(
Pair_type( name , value ) );
162 return obj.back().value_;
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;
213 return obj[ name ] = value;
216 static const String_type& get_name(
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 >
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 >
368 return static_cast< Value_type >( v_.which() );
371 template<
class Config >
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 >
467 return is_uint64() ?
static_cast< double >( get_uint64() )
468 :
static_cast< double >( get_int64() );
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;
504 return ( name_ == lhs.
name_ ) && ( value_ == lhs.
value_ );
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";
Definition: json_spirit_value.h:106
Variant operator()(const Cont< T, A > &cont) const
Definition: json_spirit_value.h:110
Variant operator()(int i) const
Definition: json_spirit_value.h:115
Variant operator()(const T &t) const
Definition: json_spirit_value.h:121
Definition: json_spirit_value.h:42
boost::uint64_t get_uint64() const
Definition: json_spirit_value.h:450
Value_impl & operator=(const Value_impl &lhs)
Definition: json_spirit_value.h:341
T get_value() const
Definition: json_spirit_value.h:582
Config Config_type
Definition: json_spirit_value.h:45
Value_impl()
Definition: json_spirit_value.h:261
Config::String_type String_type
Definition: json_spirit_value.h:46
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
Config::Array_type Array
Definition: json_spirit_value.h:48
const Object & get_obj() const
Definition: json_spirit_value.h:405
double get_real() const
Definition: json_spirit_value.h:463
Value_impl(const Value_impl &other)
static const Value_impl null
Definition: json_spirit_value.h:94
Config::Object_type Object
Definition: json_spirit_value.h:47
bool is_null() const
Definition: json_spirit_value.h:378
const Array & get_array() const
Definition: json_spirit_value.h:413
const String_type & get_str() const
Definition: json_spirit_value.h:397
bool is_uint64() const
Definition: json_spirit_value.h:372
bool get_bool() const
Definition: json_spirit_value.h:421
String_type::const_pointer Const_str_ptr
Definition: json_spirit_value.h:49
void check_type(const Value_type vtype) const
Definition: json_spirit_value.h:384
bool operator==(const Value_impl &lhs) const
Definition: json_spirit_value.h:351
Value_type type() const
Definition: json_spirit_value.h:361
boost::int64_t get_int64() const
Definition: json_spirit_value.h:437
Variant v_
Definition: json_spirit_value.h:103
int get_int() const
Definition: json_spirit_value.h:429
Definition: pch_boost.h:50
int get_value(const Value &value, Type_to_type< int >)
Definition: json_spirit_value.h:532
bool get_value(const Value &value, Type_to_type< bool >)
Definition: json_spirit_value.h:574
Definition: json_spirit_error_position.h:16
Config::Value_type Value
Definition: json_spirit_value.h:182
Config::Pair_type Pair
Definition: json_spirit_value.h:183
static std::string value_type_to_string(const Value_type vtype)
Definition: json_spirit_value.h:587
Config::Object_type Object
Definition: json_spirit_value.h:184
Config_vector< std::string > Config
Definition: json_spirit_value.h:180
String_type to_str(const char *c_str)
Definition: json_spirit_value.h:510
bool operator==(const Null &, const Null &)
Definition: json_spirit_value.h:252
Value_type
Definition: json_spirit_value.h:33
@ null_type
Definition: json_spirit_value.h:33
@ obj_type
Definition: json_spirit_value.h:33
@ array_type
Definition: json_spirit_value.h:33
@ int_type
Definition: json_spirit_value.h:33
@ str_type
Definition: json_spirit_value.h:33
@ bool_type
Definition: json_spirit_value.h:33
@ real_type
Definition: json_spirit_value.h:33
Config::Array_type Array
Definition: json_spirit_value.h:185
#define T(string_literal)
Definition: secure_crt.cpp:77
Definition: json_spirit_value.h:151
std::vector< Pair_type > Object_type
Definition: json_spirit_value.h:156
static Value_type & add(Object_type &obj, const String_type &name, const Value_type &value)
Definition: json_spirit_value.h:158
String String_type
Definition: json_spirit_value.h:152
Value_impl< Config_vector > Value_type
Definition: json_spirit_value.h:153
static const Value_type & get_value(const Pair_type &pair)
Definition: json_spirit_value.h:170
Pair_impl< Config_vector > Pair_type
Definition: json_spirit_value.h:154
std::vector< Value_type > Array_type
Definition: json_spirit_value.h:155
static const String_type & get_name(const Pair_type &pair)
Definition: json_spirit_value.h:165
Definition: json_spirit_value.h:37
Definition: json_spirit_value.h:132
bool operator==(const Pair_impl &lhs) const
Definition: json_spirit_value.h:500
Config::String_type String_type
Definition: json_spirit_value.h:133
Value_type value_
Definition: json_spirit_value.h:145
Config::Value_type Value_type
Definition: json_spirit_value.h:134
String_type name_
Definition: json_spirit_value.h:144
Pair_impl()
Definition: json_spirit_value.h:136
Definition: json_spirit_value.h:528
long long int64_t
Definition: wposix_types.h:48
unsigned long long uint64_t
Definition: wposix_types.h:57