当前位置: 首页>>代码示例>>C++>>正文


C++ JSON_ASSERT_MESSAGE函数代码示例

本文整理汇总了C++中JSON_ASSERT_MESSAGE函数的典型用法代码示例。如果您正苦于以下问题:C++ JSON_ASSERT_MESSAGE函数的具体用法?C++ JSON_ASSERT_MESSAGE怎么用?C++ JSON_ASSERT_MESSAGE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了JSON_ASSERT_MESSAGE函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: switch

Value::UInt
Value::asUInt () const
{
    switch ( type_ )
    {
    case nullValue:
        return 0;

    case intValue:
        JSON_ASSERT_MESSAGE ( value_.int_ >= 0, "Negative integer can not be converted to unsigned integer" );
        return value_.int_;

    case uintValue:
        return value_.uint_;

    case realValue:
        JSON_ASSERT_MESSAGE ( value_.real_ >= 0  &&  value_.real_ <= maxUInt,  "Real out of unsigned integer range" );
        return UInt ( value_.real_ );

    case booleanValue:
        return value_.bool_ ? 1 : 0;

    case stringValue:
        return beast::lexicalCastThrow <unsigned int> (value_.string_);

    case arrayValue:
    case objectValue:
        JSON_ASSERT_MESSAGE ( false, "Type is not convertible to uint" );

    default:
        JSON_ASSERT_UNREACHABLE;
    }

    return 0; // unreachable;
}
开发者ID:CFQuantum,项目名称:CFQuantumd,代码行数:35,代码来源:json_value.cpp

示例2: switch

Value::Int 
Value::asInt() const
{
   switch ( type_ )
   {
   case nullValue:
      return 0;
   case intValue:
      return value_.int_;
   case uintValue:
      JSON_ASSERT_MESSAGE( value_.uint_ < (unsigned)maxInt, "integer out of signed integer range" );
      return 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:
       return value_.string_ ? atoi(value_.string_) : 0;
   case arrayValue:
   case objectValue:
       return 0;
   default:
      JSON_ASSERT_UNREACHABLE;
   }
   return 0; // unreachable;
}
开发者ID:GreatFireWall,项目名称:cocos2dx-better,代码行数:27,代码来源:json_value.cpp

示例3: switch

Value::UInt 
Value::asUInt() const
{
   switch ( type_ )
   {
   case nullValue:
      return 0;
   case intValue:
      JSON_ASSERT_MESSAGE( value_.int_ >= 0, "Negative integer can not be converted to unsigned integer" );
      return value_.int_;
   case uintValue:
      return value_.uint_;
   case realValue:
      JSON_ASSERT_MESSAGE( value_.real_ >= 0  &&  value_.real_ <= maxUInt,  "Real out of unsigned integer range" );
      return UInt( value_.real_ );
   /* begin ---------- insert by ÂÀ³¿¹â 2011/7/10 ---------  */
   case int64Value:
	  JSON_ASSERT_MESSAGE( value_.int64_ >= 0  &&  value_.int64_ <= maxUInt, "long long out of signed integer range" );
	  return Int( value_.int64_);
   case uint64Value:
	  JSON_ASSERT_MESSAGE( value_.uint64_ >= 0  &&  value_.uint64_ <= maxUInt, "unsigned long long out of signed integer range" );
	  return Int( value_.uint64_);
   /* end ---------- insert by ÂÀ³¿¹â 2011/7/10 ---------  */
   case booleanValue:
      return value_.bool_ ? 1 : 0;
   case stringValue:
   case arrayValue:
   case objectValue:
      JSON_ASSERT_MESSAGE( false, "Type is not convertible to uint" );
   default:
      JSON_ASSERT_UNREACHABLE;
   }
   return 0; // unreachable;
}
开发者ID:Maysscui,项目名称:weibo-sdk-util,代码行数:34,代码来源:json_value.cpp

示例4: switch

Value::Int64
Value::asInt64() const
{
   switch ( type_ )
   {
   case nullValue:
      return 0;
   case intValue:
      return value_.int_;
   case uintValue:
      JSON_ASSERT_MESSAGE( value_.uint_ <= UInt64(maxInt64), "unsigned integer out of Int64 range" );
      return value_.uint_;
   case realValue:
      JSON_ASSERT_MESSAGE( value_.real_ >= minInt64  &&  value_.real_ <= maxInt64, "Real out of Int64 range" );
      return Int( value_.real_ );
   case booleanValue:
      return value_.bool_ ? 1 : 0;
   case stringValue:
   case arrayValue:
   case objectValue:
      JSON_ASSERT_MESSAGE( false, "Type is not convertible to Int64" );
   default:
      JSON_ASSERT_UNREACHABLE;
   }
   return 0; // unreachable;
}
开发者ID:jjiezheng,项目名称:game-platform-core-native,代码行数:26,代码来源:json_value.cpp

示例5: 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;
}
开发者ID:herryRiver,项目名称:sdl_core_v3.6_wince,代码行数:31,代码来源:json_value.cpp

示例6: initBasic

Value::Value(const char* value) {
  initBasic(stringValue, true);
  JSON_ASSERT_MESSAGE(value != nullptr,
                      "Null Value Passed to Value Constructor");
  value_.string_ = duplicateAndPrefixStringValue(
      value, static_cast<unsigned>(strlen(value)));
}
开发者ID:mloy,项目名称:jsoncpp,代码行数:7,代码来源:json_value.cpp

示例7: 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:
	   {
		   std::stringstream ss;
		   ss << asInt();
		   return ss.str();
	   }
	   break;
   case realValue:
   case arrayValue:
   case objectValue:
      JSON_ASSERT_MESSAGE( false, "Type is not convertible to string" );
   default:
      JSON_ASSERT_UNREACHABLE;
   }
   return ""; // unreachable
}
开发者ID:ValdamireGido,项目名称:game_g,代码行数:28,代码来源:json_value.cpp

示例8: valueAllocator

 void Value::CommentInfo::setComment(const char *text) {
   if (comment_)
     valueAllocator()->releaseStringValue(comment_);
   JSON_ASSERT(text);
   JSON_ASSERT_MESSAGE(text[0] == '\0' || text[0] == '/', "Comments must start with /");
   // It seems that /**/ style comments are acceptable as well.
   comment_ = valueAllocator()->duplicateStringValue(text);
 }
开发者ID:hroskes,项目名称:cmssw,代码行数:8,代码来源:json_value.cpp

示例9: JSON_ASSERT_MESSAGE

unsigned Value::getCStringLength() const {
  JSON_ASSERT_MESSAGE(type_ == stringValue,
	                  "in Json::Value::asCString(): requires stringValue");
  if (value_.string_ == 0) return 0;
  unsigned this_len;
  char const* this_str;
  decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
  return this_len;
}
开发者ID:4ib3r,项目名称:domoticz,代码行数:9,代码来源:json_value.cpp

示例10: JSON_ASSERT_MESSAGE

void Value::removeMember(const char* key) {
  JSON_ASSERT_MESSAGE(type() == nullValue || type() == objectValue,
                      "in Json::Value::removeMember(): requires objectValue");
  if (type() == nullValue)
    return;

  CZString actualKey(key, unsigned(strlen(key)), CZString::noDuplication);
  value_.map_->erase(actualKey);
}
开发者ID:mloy,项目名称:jsoncpp,代码行数:9,代码来源:json_value.cpp

示例11: switch

Value::UInt64 Value::asUInt64() const {
  switch (type_) {
  case intValue:
    JSON_ASSERT_MESSAGE(isUInt64(), "LargestInt out of UInt64 range");
    return UInt64(value_.int_);
  case uintValue:
    return UInt64(value_.uint_);
  case realValue:
    JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt64),
                        "double out of UInt64 range");
    return UInt64(value_.real_);
  case nullValue:
    return 0;
  case booleanValue:
    return value_.bool_ ? 1 : 0;
  default:
    break;
  }
  JSON_FAIL_MESSAGE("Value is not convertible to UInt64.");
}
开发者ID:4ib3r,项目名称:domoticz,代码行数:20,代码来源:json_value.cpp

示例12: JSON_ASSERT

void Value::setComment(String comment, CommentPlacement placement) {
  if (!comment.empty() && (comment.back() == '\n')) {
    // Always discard trailing newline, to aid indentation.
    comment.pop_back();
  }
  JSON_ASSERT(!comment.empty());
  JSON_ASSERT_MESSAGE(
      comment[0] == '\0' || comment[0] == '/',
      "in Json::Value::setComment(): Comments must start with /");
  comments_.set(placement, std::move(comment));
}
开发者ID:mloy,项目名称:jsoncpp,代码行数:11,代码来源:json_value.cpp

示例13: releaseStringValue

void Value::CommentInfo::setComment(const char* text, size_t len) {
  if (comment_) {
    releaseStringValue(comment_, 0u);
    comment_ = 0;
  }
  JSON_ASSERT(text != 0);
  JSON_ASSERT_MESSAGE(
      text[0] == '\0' || text[0] == '/',
      "in Json::Value::setComment(): Comments must start with /");
  // It seems that /**/ style comments are acceptable as well.
  comment_ = duplicateStringValue(text, len);
}
开发者ID:4ib3r,项目名称:domoticz,代码行数:12,代码来源:json_value.cpp

示例14: duplicateStringValue

/** Duplicates the specified string value.
 * @param value Pointer to the string to duplicate. Must be zero-terminated if
 *              length is "unknown".
 * @param length Length of the value. if equals to unknown, then it will be
 *               computed using strlen(value).
 * @return Pointer on the duplicate instance of string.
 */
static inline char *
duplicateStringValue( const char *value,
                      unsigned int length = unknown )
{
    if ( length == unknown )
        length = (unsigned int)strlen(value);
    char *newString = static_cast<char *>( malloc( length + 1 ) );
    JSON_ASSERT_MESSAGE( newString != 0, "Failed to allocate string value buffer" );
    memcpy( newString, value, length );
    newString[length] = 0;
    return newString;
}
开发者ID:herryRiver,项目名称:sdl_core_v3.6_wince,代码行数:19,代码来源:json_value.cpp


注:本文中的JSON_ASSERT_MESSAGE函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。