Skip to content

Commit

Permalink
added template contructor for object
Browse files Browse the repository at this point in the history
  • Loading branch information
nestal committed Jul 30, 2012
1 parent 0b2a8c0 commit bec8362
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion libgrive/src/protocol/Json.cc
Expand Up @@ -101,6 +101,17 @@ Json::Json( const bool& b ) :
BOOST_THROW_EXCEPTION( Error() << expt::ErrMsg( "cannot create json bool" ) ) ;
}

template <>
Json::Json( const Object& obj ) :
m_json( ::json_object_new_object() )
{
if ( m_json == 0 )
BOOST_THROW_EXCEPTION( Error() << expt::ErrMsg( "cannot create json object" ) ) ;

for ( Object::const_iterator i = obj.begin() ; i != obj.end() ; ++i )
Add( i->first, i->second ) ;
}

Json::Json( struct json_object *json, NotOwned ) :
m_json( json )
{
Expand Down Expand Up @@ -198,7 +209,7 @@ void Json::Add( const std::string& key, const Json& json )
{
assert( m_json != 0 ) ;
assert( json.m_json != 0 ) ;

::json_object_get( json.m_json ) ;
::json_object_object_add( m_json, key.c_str(), json.m_json ) ;
}
Expand Down

0 comments on commit bec8362

Please sign in to comment.