void from_variant( const variant& var,  bts::blockchain::withdraw_condition& vo )
   {
      using namespace bts::blockchain;
      auto obj = var.get_object();
      from_variant( obj["asset_id"], vo.asset_id );
      from_variant( obj["delegate_id"], vo.delegate_id );
      from_variant( obj["type"], vo.type );

      switch( (withdraw_condition_types) vo.type )
      {
         case withdraw_signature_type:
            vo.data = fc::raw::pack( obj["data"].as<withdraw_with_signature>() );
            break;
         case withdraw_multi_sig_type:
            vo.data = fc::raw::pack( obj["data"].as<withdraw_with_multi_sig>() );
            break;
         case withdraw_password_type:
            vo.data = fc::raw::pack( obj["data"].as<withdraw_with_password>() );
            break;
         case withdraw_option_type:
            vo.data = fc::raw::pack( obj["data"].as<withdraw_option>() );
            break;
         case withdraw_by_name_type:
            vo.data = fc::raw::pack( obj["data"].as<withdraw_by_name>() );
            break;
         case withdraw_null_type:
            break;
      }
   }
示例#2
0
   void to_stream( T& os, const variant& v, json::output_formatting format )
   {
      switch( v.get_type() )
      {
         case variant::null_type:
              os << "null";
              return;
         case variant::int64_type:
         {
              int64_t i = v.as_int64();
              if( format == json::stringify_large_ints_and_doubles &&
                  i > 0xffffffff )
                 os << '"'<<v.as_string()<<'"';
              else
                 os << i;

              return;
         }
         case variant::uint64_type:
         {
              uint64_t i = v.as_uint64();
              if( format == json::stringify_large_ints_and_doubles &&
                  i > 0xffffffff )
                 os << '"'<<v.as_string()<<'"';
              else
                 os << i;

              return;
         }
         case variant::double_type:
              if (format == json::stringify_large_ints_and_doubles)
                 os << '"'<<v.as_string()<<'"';
              else
                 os << v.as_string();
              return;
         case variant::bool_type:
              os << v.as_string();
              return;
         case variant::string_type:
              escape_string( v.get_string(), os );
              return;
         case variant::blob_type:
              escape_string( v.as_string(), os );
              return;
         case variant::array_type:
           {
              const variants&  a = v.get_array();
              to_stream( os, a, format );
              return;
           }
         case variant::object_type:
           {
              const variant_object& o =  v.get_object();
              to_stream(os, o, format );
              return;
           }
      }
   }
示例#3
0
 void from_variant( const variant& v, exception& ll, uint32_t max_depth )
 {
    FC_ASSERT( max_depth > 0, "Recursion depth exceeded!" );
    auto obj = v.get_object();
    if( obj.contains( "stack" ) )
       ll.my->_elog =  obj["stack"].as<log_messages>( max_depth - 1 );
    if( obj.contains( "code" ) )
       ll.my->_code = obj["code"].as_int64();
    if( obj.contains( "name" ) )
       ll.my->_name = obj["name"].as_string();
    if( obj.contains( "message" ) )
       ll.my->_what = obj["message"].as_string();
 }
示例#4
0
文件: json.cpp 项目: bitshares/fc
 void to_stream( T& os, const variant& v, json::output_formatting format, uint32_t max_depth )
 {
    FC_ASSERT( max_depth > 0, "Too many nested objects!" );
    switch( v.get_type() )
    {
       case variant::null_type:
            os << "null";
            return;
       case variant::int64_type:
            if( format == json::stringify_large_ints_and_doubles &&
                ( v.as_int64() > INT32_MAX || v.as_int64() < INT32_MIN ) )
               os << '"'<<v.as_string()<<'"';
            else
               os << v.as_int64();
            return;
       case variant::uint64_type:
            if( format == json::stringify_large_ints_and_doubles &&
                v.as_uint64() > 0xffffffff )
               os << '"'<<v.as_string()<<'"';
            else
               os << v.as_uint64();
            return;
       case variant::double_type:
            if (format == json::stringify_large_ints_and_doubles)
               os << '"'<<v.as_string()<<'"';
            else
               os << v.as_string();
            return;
       case variant::bool_type:
            os << v.as_string();
            return;
       case variant::string_type:
            escape_string( v.get_string(), os );
            return;
       case variant::blob_type:
            escape_string( v.as_string(), os );
            return;
       case variant::array_type:
            to_stream( os, v.get_array(), format, max_depth - 1 );
            return;
       case variant::object_type:
            to_stream(os, v.get_object(), format, max_depth - 1 );
            return;
       default:
          FC_THROW_EXCEPTION( fc::invalid_arg_exception, "Unsupported variant type: ${type}", ( "type", v.get_type() ) );
    }
 }
示例#5
0
 void from_variant( const variant& var,  mutable_variant_object& vo )
 {
    vo = var.get_object();
 }
示例#6
0
 void from_variant( const variant& var, mutable_variant_object& vo, uint32_t max_depth )
 {
    vo = var.get_object();
 }