Flow123d
JS_before_hm-2115-gf629a871a
|
Go to the documentation of this file. 1 #ifndef JSON_SPIRIT_VALUE
2 #define JSON_SPIRIT_VALUE
9 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
19 #include <boost/config.hpp>
20 #include <boost/cstdint.hpp>
21 #include <boost/shared_ptr.hpp>
22 #include <boost/variant.hpp>
27 #define JSON_SPIRIT_MVALUE_ENABLED
36 template<
class Config >
44 typedef typename Config::Object_type
Object;
45 typedef typename Config::Array_type
Array;
59 template<
class Iter >
62 template< BOOST_VARIANT_ENUM_PARAMS(
typename T ) >
63 Value_impl(
const boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >& variant );
88 template<
typename T > T
get_value()
const;
97 typedef boost::variant< boost::recursive_wrapper< Object >, boost::recursive_wrapper< Array >,
106 template<
typename T,
typename A,
template<
typename,
typename >
class Cont >
109 return Array( cont.begin(), cont.end() );
114 return static_cast< boost::int64_t
>( i );
127 template<
class Config >
145 #if defined( JSON_SPIRIT_VALUE_ENABLED ) || defined( JSON_SPIRIT_WVALUE_ENABLED )
146 template<
class String >
149 typedef String String_type;
157 obj.push_back( Pair_type( name ,
value ) );
159 return obj.back().value_;
162 static String_type get_name(
const Pair_type& pair )
176 #ifdef JSON_SPIRIT_VALUE_ENABLED
177 typedef Config_vector< std::string > Config;
180 typedef Config::Pair_type Pair;
181 typedef Config::Object_type Object;
182 typedef Config::Array_type Array;
187 #if defined( JSON_SPIRIT_WVALUE_ENABLED ) && !defined( BOOST_NO_STD_WSTRING )
188 typedef Config_vector< std::wstring > wConfig;
191 typedef wConfig::Pair_type wPair;
192 typedef wConfig::Object_type wObject;
193 typedef wConfig::Array_type wArray;
198 #if defined( JSON_SPIRIT_MVALUE_ENABLED ) || defined( JSON_SPIRIT_WMVALUE_ENABLED )
199 template<
class String >
210 return obj[ name ] =
value;
227 #ifdef JSON_SPIRIT_MVALUE_ENABLED
237 #if defined( JSON_SPIRIT_WMVALUE_ENABLED ) && !defined( BOOST_NO_STD_WSTRING )
241 typedef wmConfig::Object_type wmObject;
242 typedef wmConfig::Array_type wmArray;
254 template<
class Config >
257 template<
class Config >
263 template<
class Config >
269 template<
class Config >
275 template<
class Config >
281 template<
class Config >
287 template<
class Config >
293 template<
class Config >
295 : v_( static_cast<
boost::int64_t >(
value ) )
299 template<
class Config >
305 template<
class Config >
311 template<
class Config >
317 template<
class Config >
323 template<
class Config >
324 template<
class Iter >
326 : v_(
Array( first, last ) )
330 template<
class Config >
331 template< BOOST_VARIANT_ENUM_PARAMS(
typename T ) >
337 template<
class Config >
347 template<
class Config >
350 if(
this == &lhs )
return true;
352 if( type() != lhs.
type() )
return false;
357 template<
class Config >
365 return static_cast< Value_type >( v_.which() );
368 template<
class Config >
374 template<
class Config >
380 template<
class Config >
383 if( type() != vtype )
385 std::ostringstream os;
387 os <<
"value type is " << type() <<
" not " << vtype;
389 throw std::runtime_error( os.str() );
393 template<
class Config >
398 return *boost::get< String_type >( &v_ );
401 template<
class Config >
406 return *boost::get< Object >( &v_ );
409 template<
class Config >
414 return *boost::get< Array >( &v_ );
417 template<
class Config >
422 return boost::get< bool >( v_ );
425 template<
class Config >
430 return static_cast< int >( get_int64() );
433 template<
class Config >
440 return static_cast< boost::int64_t
>( get_uint64() );
443 return boost::get< boost::int64_t >( v_ );
446 template<
class Config >
453 return static_cast< boost::uint64_t
>( get_int64() );
456 return boost::get< boost::uint64_t >( v_ );
459 template<
class Config >
464 return is_uint64() ?
static_cast< double >( get_uint64() )
465 :
static_cast< double >( get_int64() );
470 return boost::get< double >( v_ );
473 template<
class Config >
478 return *boost::get< Object >( &v_ );
481 template<
class Config >
486 return *boost::get< Array >( &v_ );
489 template<
class Config >
496 template<
class Config >
499 if(
this == &lhs )
return true;
501 return ( name_ == lhs.
name_ ) && ( value_ == lhs.
value_ );
506 template <
class String_type >
511 for(
const char* p = c_str; *p != 0; ++p )
523 template<
typename T >
528 template<
class Value >
531 return value.get_int();
534 template<
class Value >
537 return value.get_int64();
540 template<
class Value >
543 return value.get_uint64();
546 template<
class Value >
549 return value.get_real();
552 template<
class Value >
555 return value.get_str();
558 template<
class Value >
561 return value.get_array();
564 template<
class Value >
567 return value.get_obj();
570 template<
class Value >
573 return value.get_bool();
577 template<
class Config >
578 template<
typename T >
std::pair< String_type, Value_type > Pair_type
bool get_value(const Value &value, Type_to_type< bool >)
mConfig::Object_type mObject
void swap(nlohmann::json &j1, nlohmann::json &j2) noexcept(is_nothrow_move_constructible< nlohmann::json >::value and is_nothrow_move_assignable< nlohmann::json >::value)
exchanges the values of two JSON objects
General iterator template. Provides iterator over objects of type Object in some container.
static const Value_impl null
String_type to_str(const char *c_str)
bool operator==(const Value_impl &lhs) const
Config::Object_type Object
const Array & get_array() const
bool operator==(const Pair_impl &lhs) const
Config::String_type String_type
void check_type(const Value_type vtype) const
const Object & get_obj() const
static constexpr bool value
boost::uint64_t get_uint64() const
Config::String_type String_type
std::vector< Value_type > Array_type
static Value_type & add(Object_type &obj, const String_type &name, const Value_type &value)
static Value_type get_value(const Pair_type &pair)
Value_impl< Config_map > Value_type
Config::Value_type Value_type
boost::int64_t get_int64() const
const String_type & get_str() const
Variant operator()(const Cont< T, A > &cont) const
std::map< String_type, Value_type > Object_type
String_type::const_pointer Const_str_ptr
int get_value(const Value &value, Type_to_type< int >)
mConfig::Value_type mValue
Variant operator()(const T &t) const
boost::variant< boost::recursive_wrapper< Object >, boost::recursive_wrapper< Array >, String_type, bool, boost::int64_t, double, Null, boost::uint64_t > Variant
Value_impl & operator=(const Value_impl &lhs)
bool operator==(const Null &, const Null &)
Variant operator()(int i) const
Config_map< std::string > mConfig
static String_type get_name(const Pair_type &pair)
mConfig::Array_type mArray