本文整理汇总了C++中variant::get_object方法的典型用法代码示例。如果您正苦于以下问题:C++ variant::get_object方法的具体用法?C++ variant::get_object怎么用?C++ variant::get_object使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类variant
的用法示例。
在下文中一共展示了variant::get_object方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: from_variant
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: to_stream
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: from_variant
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: to_stream
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: from_variant
void from_variant( const variant& var, mutable_variant_object& vo )
{
vo = var.get_object();
}
示例6: from_variant
void from_variant( const variant& var, mutable_variant_object& vo, uint32_t max_depth )
{
vo = var.get_object();
}