本文整理汇总了C++中fc::variant类的典型用法代码示例。如果您正苦于以下问题:C++ variant类的具体用法?C++ variant怎么用?C++ variant使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了variant类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: from_variant
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());
}
开发者ID:BitMoneta,项目名称:fc,代码行数:7,代码来源:variant.hpp
示例2: from_variant
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() );
}
开发者ID:FollowMyVote,项目名称:fc,代码行数:7,代码来源:variant.hpp
示例3: review_answer
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 );
}
}
开发者ID:dbarobin,项目名称:steem,代码行数:31,代码来源:database_fixture.cpp
示例4: from_variant
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
}
开发者ID:hoseadevops,项目名称:bitshares-core,代码行数:15,代码来源:ext.hpp
示例5: from_variant
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()) ) }
开发者ID:grzegorzs,项目名称:bitshares_toolkit,代码行数:7,代码来源:operation_factory.hpp
示例6: check_id_equal
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 );
}
}
开发者ID:dbarobin,项目名称:steem,代码行数:21,代码来源:database_fixture.cpp
示例7: processUpdatedObject
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()));
}
}
开发者ID:sfinder,项目名称:graphene,代码行数:43,代码来源:ChainDataModel.cpp
示例8: from_variant
void from_variant( const fc::variant& var, graphene::chain::public_key_type& vo )
{
vo = graphene::chain::public_key_type( var.as_string() );
}
开发者ID:0dayZh,项目名称:graphene,代码行数:4,代码来源:types.cpp
示例9: from_variant
inline void from_variant( const fc::variant& var, steemit::chain::asset& vo ) { vo = steemit::chain::asset::from_string( var.as_string() ); }
开发者ID:Bitcoinsulting,项目名称:steem,代码行数:1,代码来源:asset.hpp
示例10: from_variant
void from_variant( const fc::variant& var, graphene::chain::extended_private_key_type& vo )
{
vo = graphene::chain::extended_private_key_type( var.as_string() );
}
开发者ID:8001800,项目名称:graphene,代码行数:4,代码来源:types.cpp
示例11: from_variant
void from_variant(const fc::variant& v, eosio::chain::name& check) { check = v.get_string(); }
开发者ID:108518,项目名称:eos,代码行数:1,代码来源:name.cpp
示例12: sub
double sub( fc::variant a, fc::variant b ) { return a.as_double()-b.as_double(); }
开发者ID:BitMoneta,项目名称:fc,代码行数:1,代码来源:api.cpp
示例13: add
double add( fc::variant a, fc::variant b ) { return a.as_double()+b.as_double(); }
开发者ID:BitMoneta,项目名称:fc,代码行数:1,代码来源:api.cpp
示例14: from_variant
void from_variant( const fc::variant& v, fc::time_point_sec& t ) {
t = fc::time_point::from_iso_string(v.as_string());
}
开发者ID:VicHao,项目名称:fc,代码行数:3,代码来源:time.cpp
示例15: from_variant
void from_variant( const fc::variant& var, bts::blockchain::public_key_type& vo )
{
vo = bts::blockchain::public_key_type( var.as_string() );
}
开发者ID:AlexChien,项目名称:bitshares,代码行数:4,代码来源:types.cpp
示例16: from_variant
inline void from_variant(const fc::variant& var, eosio::chain::asset& vo) {
vo = eosio::chain::asset::from_string(var.get_string());
}
开发者ID:milk57618,项目名称:eos,代码行数:3,代码来源:asset.hpp
注:本文中的fc::variant类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论