本文整理汇总了C++中JSON_FAIL_MESSAGE函数的典型用法代码示例。如果您正苦于以下问题:C++ JSON_FAIL_MESSAGE函数的具体用法?C++ JSON_FAIL_MESSAGE怎么用?C++ JSON_FAIL_MESSAGE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了JSON_FAIL_MESSAGE函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
Value::UInt64
Value::asUInt64() const
{
switch ( type_ )
{
case nullValue:
return 0;
case intValue:
JSON_ASSERT_MESSAGE( value_.int_ >= 0, "Negative integer can not be converted to UInt64" );
return value_.int_;
case uintValue:
return value_.uint_;
case realValue:
JSON_ASSERT_MESSAGE( value_.real_ >= 0 && value_.real_ <= maxUInt64, "Real out of UInt64 range" );
return UInt( value_.real_ );
case booleanValue:
return value_.bool_ ? 1 : 0;
case stringValue:
case arrayValue:
case objectValue:
JSON_FAIL_MESSAGE( "Type is not convertible to UInt64" );
default:
JSON_ASSERT_UNREACHABLE;
}
return 0; // unreachable;
}
示例2: switch
Value::Int
Value::asInt() const
{
switch ( type_ )
{
case nullValue:
return 0;
case intValue:
JSON_ASSERT_MESSAGE( value_.int_ >= minInt && value_.int_ <= maxInt, "unsigned integer out of signed int range" );
return Int(value_.int_);
case uintValue:
#ifdef MODIFY_FUNCTION_SIGN
// do nothing
#else
JSON_ASSERT_MESSAGE(value_.uint_ <= UInt(maxInt), "unsigned integer out of signed int range");
#endif
return Int(value_.uint_);
case realValue:
JSON_ASSERT_MESSAGE( value_.real_ >= minInt && value_.real_ <= maxInt, "Real out of signed integer range" );
return Int( value_.real_ );
case booleanValue:
return value_.bool_ ? 1 : 0;
case stringValue:
case arrayValue:
case objectValue:
JSON_FAIL_MESSAGE( "Type is not convertible to int" );
default:
JSON_ASSERT_UNREACHABLE;
}
return 0; // unreachable;
}
示例3: switch
String Value::asString() const {
switch (type()) {
case nullValue:
return "";
case stringValue: {
if (value_.string_ == nullptr)
return "";
unsigned this_len;
char const* this_str;
decodePrefixedString(this->isAllocated(), this->value_.string_, &this_len,
&this_str);
return String(this_str, this_len);
}
case booleanValue:
return value_.bool_ ? "true" : "false";
case intValue:
return valueToString(value_.int_);
case uintValue:
return valueToString(value_.uint_);
case realValue:
return valueToString(value_.real_);
default:
JSON_FAIL_MESSAGE("Type is not convertible to string");
}
}
示例4: switch
bool Value::asBool() const {
switch (type_) {
case booleanValue:
return value_.bool_;
case nullValue:
return false;
case intValue:
return value_.int_ ? true : false;
case uintValue:
return value_.uint_ ? true : false;
case realValue:
// This is kind of strange. Not recommended.
return (value_.real_ != 0.0) ? true : false;
default:
break;
}
JSON_FAIL_MESSAGE("Value is not convertible to bool.");
}
示例5: switch
std::string
Value::asString() const
{
switch ( type_ )
{
case nullValue:
return "";
case stringValue:
return value_.string_ ? value_.string_ : "";
case booleanValue:
return value_.bool_ ? "true" : "false";
case intValue:
case uintValue:
case realValue:
case arrayValue:
case objectValue:
JSON_FAIL_MESSAGE( "Type is not convertible to string" );
default:
JSON_ASSERT_UNREACHABLE;
}
return ""; // unreachable
}