Merge remote branch 'refs/remotes/svn/trunk' into svn
[bitcoinplatinum.git] / json / json_spirit_utils.h
blob553e3b96a4e95f960a307e5a9a174f3f1a055b97
1 #ifndef JSON_SPIRIT_UTILS
2 #define JSON_SPIRIT_UTILS
4 // Copyright John W. Wilkinson 2007 - 2009.
5 // Distributed under the MIT License, see accompanying file LICENSE.txt
7 // json spirit version 4.03
9 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
10 # pragma once
11 #endif
13 #include "json_spirit_value.h"
14 #include <map>
16 namespace json_spirit
18 template< class Obj_t, class Map_t >
19 void obj_to_map( const Obj_t& obj, Map_t& mp_obj )
21 mp_obj.clear();
23 for( typename Obj_t::const_iterator i = obj.begin(); i != obj.end(); ++i )
25 mp_obj[ i->name_ ] = i->value_;
29 template< class Obj_t, class Map_t >
30 void map_to_obj( const Map_t& mp_obj, Obj_t& obj )
32 obj.clear();
34 for( typename Map_t::const_iterator i = mp_obj.begin(); i != mp_obj.end(); ++i )
36 obj.push_back( typename Obj_t::value_type( i->first, i->second ) );
40 typedef std::map< std::string, Value > Mapped_obj;
42 #ifndef BOOST_NO_STD_WSTRING
43 typedef std::map< std::wstring, wValue > wMapped_obj;
44 #endif
46 template< class Object_type, class String_type >
47 const typename Object_type::value_type::Value_type& find_value( const Object_type& obj, const String_type& name )
49 for( typename Object_type::const_iterator i = obj.begin(); i != obj.end(); ++i )
51 if( i->name_ == name )
53 return i->value_;
57 return Object_type::value_type::Value_type::null;
61 #endif