-
+ 15120F9DC1C9B37D40991756AB600EB8737AF58C4D0C7A80879403C45B1A1935D71EDEC46A6CC5298D7AF4C2C93BAAC1AF00C80C4335F752E4D1F49D9E61B457
bitcoin/src/json/json_spirit_utils.h
(0 . 0)(1 . 61)
7549 #ifndef JSON_SPIRIT_UTILS
7550 #define JSON_SPIRIT_UTILS
7551
7552 // Copyright John W. Wilkinson 2007 - 2009.
7553 // Distributed under the MIT License, see accompanying file LICENSE.txt
7554
7555 // json spirit version 4.03
7556
7557 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
7558 # pragma once
7559 #endif
7560
7561 #include "json_spirit_value.h"
7562 #include <map>
7563
7564 namespace json_spirit
7565 {
7566 template< class Obj_t, class Map_t >
7567 void obj_to_map( const Obj_t& obj, Map_t& mp_obj )
7568 {
7569 mp_obj.clear();
7570
7571 for( typename Obj_t::const_iterator i = obj.begin(); i != obj.end(); ++i )
7572 {
7573 mp_obj[ i->name_ ] = i->value_;
7574 }
7575 }
7576
7577 template< class Obj_t, class Map_t >
7578 void map_to_obj( const Map_t& mp_obj, Obj_t& obj )
7579 {
7580 obj.clear();
7581
7582 for( typename Map_t::const_iterator i = mp_obj.begin(); i != mp_obj.end(); ++i )
7583 {
7584 obj.push_back( typename Obj_t::value_type( i->first, i->second ) );
7585 }
7586 }
7587
7588 typedef std::map< std::string, Value > Mapped_obj;
7589
7590 #ifndef BOOST_NO_STD_WSTRING
7591 typedef std::map< std::wstring, wValue > wMapped_obj;
7592 #endif
7593
7594 template< class Object_type, class String_type >
7595 const typename Object_type::value_type::Value_type& find_value( const Object_type& obj, const String_type& name )
7596 {
7597 for( typename Object_type::const_iterator i = obj.begin(); i != obj.end(); ++i )
7598 {
7599 if( i->name_ == name )
7600 {
7601 return i->value_;
7602 }
7603 }
7604
7605 return Object_type::value_type::Value_type::null;
7606 }
7607 }
7608
7609 #endif