raw
experimental-genesis    1 //  /****************************\
experimental-genesis 2 // * EXPERIMENTAL BRANCH. *
experimental-genesis 3 // * FOR LABORATORY USE ONLY. *
experimental-genesis 4 // ********************************
experimental-genesis 5 // ************
experimental-genesis 6 // **************
experimental-genesis 7 // ****************
experimental-genesis 8 // **** **** ****
experimental-genesis 9 // *** *** ***
experimental-genesis 10 // *** *** ***
experimental-genesis 11 // *** * * **
experimental-genesis 12 // ******** ********
experimental-genesis 13 // ******* ******
experimental-genesis 14 // *** **
experimental-genesis 15 // * ******* **
experimental-genesis 16 // ** * * * * *
experimental-genesis 17 // ** * * ***
experimental-genesis 18 // **** * * * * ****
experimental-genesis 19 // **** *** * * ** ***
experimental-genesis 20 // **** ********* ******
experimental-genesis 21 // ******* ***** *******
experimental-genesis 22 // ********* ****** **
experimental-genesis 23 // ** ****** ******
experimental-genesis 24 // ** ******* **
experimental-genesis 25 // ** ******* ***
experimental-genesis 26 // **** ******** ************
experimental-genesis 27 // ************ ************
experimental-genesis 28 // ******** *******
experimental-genesis 29 // ****** ****
experimental-genesis 30 // *** ***
experimental-genesis 31 // ********************************
experimental-genesis 32 #ifndef JSON_SPIRIT_UTILS
experimental-genesis 33 #define JSON_SPIRIT_UTILS
experimental-genesis 34
experimental-genesis 35 // Copyright John W. Wilkinson 2007 - 2009.
experimental-genesis 36 // Distributed under the MIT License, see accompanying file LICENSE.txt
experimental-genesis 37
experimental-genesis 38 // json spirit version 4.03
experimental-genesis 39
experimental-genesis 40 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
experimental-genesis 41 # pragma once
experimental-genesis 42 #endif
experimental-genesis 43
experimental-genesis 44 #include "json_spirit_value.h"
experimental-genesis 45 #include <map>
experimental-genesis 46
experimental-genesis 47 namespace json_spirit
experimental-genesis 48 {
experimental-genesis 49 template< class Obj_t, class Map_t >
experimental-genesis 50 void obj_to_map( const Obj_t& obj, Map_t& mp_obj )
experimental-genesis 51 {
experimental-genesis 52 mp_obj.clear();
experimental-genesis 53
experimental-genesis 54 for( typename Obj_t::const_iterator i = obj.begin(); i != obj.end(); ++i )
experimental-genesis 55 {
experimental-genesis 56 mp_obj[ i->name_ ] = i->value_;
experimental-genesis 57 }
experimental-genesis 58 }
experimental-genesis 59
experimental-genesis 60 template< class Obj_t, class Map_t >
experimental-genesis 61 void map_to_obj( const Map_t& mp_obj, Obj_t& obj )
experimental-genesis 62 {
experimental-genesis 63 obj.clear();
experimental-genesis 64
experimental-genesis 65 for( typename Map_t::const_iterator i = mp_obj.begin(); i != mp_obj.end(); ++i )
experimental-genesis 66 {
experimental-genesis 67 obj.push_back( typename Obj_t::value_type( i->first, i->second ) );
experimental-genesis 68 }
experimental-genesis 69 }
experimental-genesis 70
experimental-genesis 71 typedef std::map< std::string, Value > Mapped_obj;
experimental-genesis 72
experimental-genesis 73 #ifndef BOOST_NO_STD_WSTRING
experimental-genesis 74 typedef std::map< std::wstring, wValue > wMapped_obj;
experimental-genesis 75 #endif
experimental-genesis 76
experimental-genesis 77 template< class Object_type, class String_type >
experimental-genesis 78 const typename Object_type::value_type::Value_type& find_value( const Object_type& obj, const String_type& name )
experimental-genesis 79 {
experimental-genesis 80 for( typename Object_type::const_iterator i = obj.begin(); i != obj.end(); ++i )
experimental-genesis 81 {
experimental-genesis 82 if( i->name_ == name )
experimental-genesis 83 {
experimental-genesis 84 return i->value_;
experimental-genesis 85 }
experimental-genesis 86 }
experimental-genesis 87
experimental-genesis 88 return Object_type::value_type::Value_type::null;
experimental-genesis 89 }
experimental-genesis 90 }
experimental-genesis 91
experimental-genesis 92 #endif