예제 #1
0
파일: variant.hpp 프로젝트: BitMoneta/fc
 static inline void from_variant( const fc::variant& v, T& o ) 
 { 
     if( v.is_string() )
        o = fc::reflector<T>::from_string( v.get_string().c_str() );
     else 
        o = static_cast<T>(v.as_int64());
 }
예제 #2
0
파일: variant.hpp 프로젝트: FollowMyVote/fc
 static inline void from_variant( const fc::variant& v, T& o, uint32_t max_depth = 1 )
 { 
     if( v.is_string() )
        o = fc::reflector<T>::from_string( v.get_string().c_str() );
     else
        o = fc::reflector<T>::from_int( v.as_int64() );
 }
예제 #3
0
void json_rpc_database_fixture::review_answer( fc::variant& answer, int64_t code, bool is_warning, bool is_fail, fc::optional< fc::variant > id )
{
   fc::variant_object error;
   int64_t answer_code;

   if( is_fail )
   {
      if( id.valid() && code != JSON_RPC_INVALID_REQUEST )
      {
         BOOST_REQUIRE( answer.get_object().contains( "id" ) );
         check_id_equal( answer[ "id" ], *id );
      }

      BOOST_REQUIRE( answer.get_object().contains( "error" ) );
      BOOST_REQUIRE( answer["error"].is_object() );
      error = answer["error"].get_object();
      BOOST_REQUIRE( error.contains( "code" ) );
      BOOST_REQUIRE( error["code"].is_int64() );
      answer_code = error["code"].as_int64();
      BOOST_REQUIRE( answer_code == code );
      if( is_warning )
         BOOST_TEST_MESSAGE( error["message"].as_string() );
   }
   else
   {
      BOOST_REQUIRE( answer.get_object().contains( "result" ) );
      BOOST_REQUIRE( answer.get_object().contains( "id" ) );
      if( id.valid() )
         check_id_equal( answer[ "id" ], *id );
   }
}
예제 #4
0
void from_variant( const fc::variant& var, graphene::chain::extension<T>& value, uint32_t max_depth )
{
   value = graphene::chain::extension<T>();
   if( var.is_null() )
      return;
   if( var.is_array() )
   {
      FC_ASSERT( var.size() == 0 );
      return;
   }

   graphene_extension_from_variant_visitor<T> vtor( var.get_object(), value.value, max_depth );
   fc::reflector<T>::visit( vtor );
   FC_ASSERT( vtor.count_left == 0 );    // unrecognized extension throws here
}
                  virtual void from_variant( const fc::variant& in, bts::blockchain::operation& output )
                  { try {
                     auto obj = in.get_object();

                     FC_ASSERT( output.type == OperationType::type );
                     output.data = fc::raw::pack( obj["data"].as<OperationType>() );
                  } FC_RETHROW_EXCEPTIONS( warn, "type: ${type}", ("type",fc::get_typename<OperationType>::name()) ) }
예제 #6
0
void check_id_equal( const fc::variant& id_a, const fc::variant& id_b )
{
   BOOST_REQUIRE( id_a.get_type() == id_b.get_type() );

   switch( id_a.get_type() )
   {
      case fc::variant::int64_type:
         BOOST_REQUIRE( id_a.as_int64() == id_b.as_int64() );
         break;
      case fc::variant::uint64_type:
         BOOST_REQUIRE( id_a.as_uint64() == id_b.as_uint64() );
         break;
      case fc::variant::string_type:
         BOOST_REQUIRE( id_a.as_string() == id_b.as_string() );
         break;
      case fc::variant::null_type:
         break;
      default:
         BOOST_REQUIRE( false );
   }
}
예제 #7
0
void ChainDataModel::processUpdatedObject(const fc::variant& update)
{
   if (update.is_null())
      return;
   if (&fc::thread::current() == m_rpc_thread)
   {
      ilog("Proxying object update to app thread.");
      Q_EMIT queueExecute([this,update]{processUpdatedObject(update);});
      return;
   }

   idump((update));
   try {
   auto id = update.as<variant_object>()["id"].as<object_id_type>();
   if (id.space() == protocol_ids) {
      switch (id.type()) {
         default:
            wlog("Update procedure for ${update} is not yet implemented.", ("update", update));
            break;
      }
   } else if (id.space() == implementation_ids) {
      switch (id.type()) {
         case impl_account_balance_object_type: {
            account_balance_object balance = update.as<account_balance_object>();
            auto owner = m_accounts.find(balance.owner.instance.value);
            if (owner != m_accounts.end())
               (*owner)->update(balance);
            else
               elog("Got unexpected balance update:\n${u}\nfor an account I don't have.",
                    ("u", update));
            break;
      }

      default:
         wlog("Update procedure for ${update} is not yet implemented.", ("update", update));
         break;
      }
   } else
      wlog("Update procedure for ${update} is not yet implemented.", ("update", update));
   } catch (const fc::exception& e) {
      elog("Caught exception while updating object: ${e}", ("e", e.to_detail_string()));
   }
}
예제 #8
0
파일: types.cpp 프로젝트: 0dayZh/graphene
 void from_variant( const fc::variant& var,  graphene::chain::public_key_type& vo )
 {
     vo = graphene::chain::public_key_type( var.as_string() );
 }
예제 #9
0
파일: variant.hpp 프로젝트: FollowMyVote/fc
 static inline void from_variant( const fc::variant& v, T& o, uint32_t max_depth )
 {
    const variant_object& vo = v.get_object();
    fc::reflector<T>::visit( from_variant_visitor<T>( vo, o, max_depth ) );
 }
예제 #10
0
 inline void from_variant( const fc::variant& var,  steemit::chain::asset& vo ) { vo = steemit::chain::asset::from_string( var.as_string() ); }
예제 #11
0
파일: types.cpp 프로젝트: 8001800/graphene
 void from_variant( const fc::variant& var, graphene::chain::extended_private_key_type& vo )
 {
    vo = graphene::chain::extended_private_key_type( var.as_string() );
 }
예제 #12
0
파일: name.cpp 프로젝트: 108518/eos
 void from_variant(const fc::variant& v, eosio::chain::name& check) { check = v.get_string(); }
예제 #13
0
파일: api.cpp 프로젝트: BitMoneta/fc
 double sub( fc::variant a, fc::variant b ) { return a.as_double()-b.as_double(); }
예제 #14
0
파일: api.cpp 프로젝트: BitMoneta/fc
 double add( fc::variant a, fc::variant b ) { return a.as_double()+b.as_double(); }
예제 #15
0
파일: time.cpp 프로젝트: VicHao/fc
 void from_variant( const fc::variant& v, fc::time_point_sec& t ) {
   t = fc::time_point::from_iso_string(v.as_string());
 }
예제 #16
0
 void from_variant( const fc::variant& var,  bts::blockchain::public_key_type& vo )
 {
     vo = bts::blockchain::public_key_type( var.as_string() );
 }
예제 #17
0
파일: asset.hpp 프로젝트: milk57618/eos
inline void from_variant(const fc::variant& var, eosio::chain::asset& vo) {
   vo = eosio::chain::asset::from_string(var.get_string());
}
예제 #18
0
파일: variant.hpp 프로젝트: BitMoneta/fc
 static inline void from_variant( const fc::variant& v, T& o ) 
 { 
     const variant_object& vo = v.get_object();
     fc::reflector<T>::visit( from_variant_visitor<T>( vo, o ) );
 }