本文整理汇总了C++中variant::as_int64方法的典型用法代码示例。如果您正苦于以下问题:C++ variant::as_int64方法的具体用法?C++ variant::as_int64怎么用?C++ variant::as_int64使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类variant
的用法示例。
在下文中一共展示了variant::as_int64方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
variant operator / ( const variant& a, const variant& b )
{
if( a.is_double() || b.is_double() ) return a.as_double() / b.as_double();
if( a.is_int64() || b.is_int64() ) return a.as_int64() / b.as_int64();
if( a.is_uint64() || b.is_uint64() ) return a.as_uint64() / b.as_uint64();
if( a.is_array() && b.is_array() )
{
const variants& aa = a.get_array();
const variants& ba = b.get_array();
variants result;
result.reserve( std::max(aa.size(),ba.size()) );
auto num = std::max(aa.size(),ba.size());
for( unsigned i = 0; i < num; ++i )
{
if( aa.size() > i && ba.size() > i )
result[i] = aa[i] / ba[i];
else if( aa.size() > i )
result[i] = aa[i];
else
result[i] = ba[i];
}
return result;
}
FC_ASSERT( false, "invalid operation ${a} / ${b}", ("a",a)("b",b) );
}
示例2:
variant operator <= ( const variant& a, const variant& b )
{
if( a.is_string() || b.is_string() ) return a.as_string() <= b.as_string();
if( a.is_double() || b.is_double() ) return a.as_double() <= b.as_double();
if( a.is_int64() || b.is_int64() ) return a.as_int64() <= b.as_int64();
if( a.is_uint64() || b.is_uint64() ) return a.as_uint64() <= b.as_uint64();
FC_ASSERT( false, "Invalid operation" );
}
示例3: 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() ) );
}
}
示例4: 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;
}
}
}
示例5: from_variant
void from_variant( const variant& vo, chainbase::oid<T>& var )
{
var._id = vo.as_int64();
}
示例6: from_variant
void from_variant( const variant& var, int64_t& vo )
{
vo = var.as_int64();
}
示例7: from_variant
void from_variant( const variant& input_variant, microseconds& output_microseconds )
{
output_microseconds = microseconds(input_variant.as_int64());
}