• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ JSON_ASSERT函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: JSON_ASSERT

void
Value::resize ( UInt newSize )
{
    JSON_ASSERT ( type_ == nullValue  ||  type_ == arrayValue );

    if ( type_ == nullValue )
        *this = Value ( arrayValue );

#ifndef JSON_VALUE_USE_INTERNAL_MAP
    UInt oldSize = size ();

    if ( newSize == 0 )
        clear ();
    else if ( newSize > oldSize )
        (*this)[ newSize - 1 ];
    else
    {
        for ( UInt index = newSize; index < oldSize; ++index )
            value_.map_->erase ( index );

        assert ( size () == newSize );
    }

#else
    value_.array_->resize ( newSize );
#endif
}
开发者ID:12w21,项目名称:rippled,代码行数:27,代码来源:json_value.cpp


示例2: JSON_ASSERT

Value
Value::removeMember( const char* key )
{
   JSON_ASSERT( type_ == nullValue  ||  type_ == objectValue );
   if ( type_ == nullValue )
      return null;
#ifndef JSON_VALUE_USE_INTERNAL_MAP
   CZString actualKey( key, CZString::noDuplication );
   ObjectValues::iterator it = value_.map_->find( actualKey );
   if ( it == value_.map_->end() )
      return null;
   Value old(it->second);
   value_.map_->erase(it);
   return old;
#else
   Value *value = value_.map_->find( key );
   if (value){
      Value old(*value);
      value_.map_.remove( key );
      return old;
   } else {
      return null;
   }
#endif
}
开发者ID:paulreimer,项目名称:LegoSequencer,代码行数:25,代码来源:json_value.cpp


示例3: ungetc

 void ungetc()
 {
     if (m_last_ch != -1)
     {
         JSON_ASSERT(!m_ungot);
         m_ungot = true;
     }
 }
开发者ID:Bulliby,项目名称:Reactive,代码行数:8,代码来源:parser.hpp


示例4: valueToString

std::string valueToString( UInt value )
{
   char buffer[32];
   char *current = buffer + sizeof(buffer);
   uintToString( value, current );
   JSON_ASSERT( current >= buffer );
   return current;
}
开发者ID:0xffffffff,项目名称:rtbkit,代码行数:8,代码来源:json_writer.cpp


示例5: JSON_ASSERT

Json& Json::Add(const std::string& key, const Json& value){
	if(key.size() > 0 && value._kind != kNull){
		if(_kind != kObject) 
			JSON_ASSERT("json of object expected");
		((Object*) _data)->insert(make_pair(key, new Json(value)));
	}
	return *this;
}
开发者ID:JackWyj,项目名称:Json-Parser,代码行数:8,代码来源:Json.cpp


示例6: 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


示例7: myrealloc

void * JSONMemory::json_realloc(void * ptr, size_t siz){
	if (myrealloc){
		#ifdef JSON_DEBUG  //in debug mode, see if the malloc was successful
			void * result = myrealloc(ptr, siz);
			JSON_ASSERT(result, JSON_TEXT("out of memory"));
			return result;
		#else
			return myrealloc(ptr, (unsigned long)siz);
		#endif
	}
	#ifdef JSON_DEBUG  //in debug mode, see if the malloc was successful
		void * result = realloc(ptr, siz);
		JSON_ASSERT(result, JSON_TEXT("out of memory"));
		return result;
	#else
		return realloc(ptr, siz);
	#endif
}
开发者ID:Seldom,项目名称:miranda-ng,代码行数:18,代码来源:JSONMemory.cpp


示例8: JSON_CHECK_INTERNAL

    JSONNode::json_iterator JSONNode::find_nocase(const json_string & name_t){
	   JSON_CHECK_INTERNAL();
	   JSON_ASSERT(type() == JSON_NODE, JSON_TEXT("finding a non-iteratable node"));
	   makeUniqueInternal();
	   if (JSONNode ** res = internal -> at_nocase(name_t)){
		  return ptr_to_json_iterator(res);
	   }
	   return end();
    }
开发者ID:AlternatingCt,项目名称:ethanon,代码行数:9,代码来源:JSONIterators.cpp


示例9: NextChar

Json* Json::Parser::ParseFalse(){
	std::string sbool;
	for(int i = 0; i < 4; i++)
		sbool += NextChar();
	if(sbool != "false"){
		JSON_ASSERT("expect \"false\" ");
		return NULL;
	}
	else return new Json(false, kFalse);
}
开发者ID:JackWyj,项目名称:Json-Parser,代码行数:10,代码来源:Json.cpp


示例10: 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


示例11: JSON_ASSERT

bool Value::CZString::operator==(const CZString& other) const {
  if (!cstr_) return index_ == other.index_;
  //return strcmp(cstr_, other.cstr_) == 0;
  // Assume both are strings.
  unsigned this_len = this->storage_.length_;
  unsigned other_len = other.storage_.length_;
  if (this_len != other_len) return false;
  JSON_ASSERT(this->cstr_ && other.cstr_);
  int comp = memcmp(this->cstr_, other.cstr_, this_len);
  return comp == 0;
}
开发者ID:4ib3r,项目名称:domoticz,代码行数:11,代码来源:json_value.cpp


示例12: 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


示例13: watchman_watch_list

struct watchman_watch_list *
watchman_watch_list(struct watchman_connection *conn,
                    struct watchman_error *error)
{
    struct watchman_watch_list *res = NULL;
    struct watchman_watch_list *result = NULL;
    if (watchman_send_simple_command(conn, error, "watch-list", NULL)) {
        return NULL;
    }

    json_t *obj = watchman_read(conn, error);
    if (!obj) {
        return NULL;
    }
    JSON_ASSERT(json_is_object, obj, "Got bogus value from watch-list %s");
    json_t *roots = json_object_get(obj, "roots");
    JSON_ASSERT(json_is_array, roots, "Got bogus value from watch-list %s");

    res = malloc(sizeof(*res));
    int nr = json_array_size(roots);
    res->nr = 0;
    res->roots = calloc(nr, sizeof(*res->roots));
    int i;
    for (i = 0; i < nr; ++i) {
        json_t *root = json_array_get(roots, i);
        JSON_ASSERT(json_is_string, root,
                    "Got non-string root from watch-list %s");
        res->nr++;
        res->roots[i] = strdup(json_string_value(root));
    }
    result = res;
    res = NULL;
done:
    if (res) {
        watchman_free_watch_list(res);
    }
    json_decref(obj);
    return result;
}
开发者ID:alex-tools,项目名称:libwatchman,代码行数:39,代码来源:watchman.c


示例14: while

char Json::Parser::NextChar(bool skip){
	
	while (true)
	{
		read_pos++;
		if(read_pos >= buf.size()) JSON_ASSERT("unexpected end of input");
		ch = buf[read_pos];
		if (skip && (' ' == ch || '\t' == ch || '\n' == ch || '\r' == ch)) { ; }
		else break;
	}

	return ch;
}
开发者ID:JackWyj,项目名称:Json-Parser,代码行数:13,代码来源:Json.cpp


示例15: type

bool Value::operator<(const Value& other) const {
  int typeDelta = type() - other.type();
  if (typeDelta)
    return typeDelta < 0 ? true : false;
  switch (type()) {
  case nullValue:
    return false;
  case intValue:
    return value_.int_ < other.value_.int_;
  case uintValue:
    return value_.uint_ < other.value_.uint_;
  case realValue:
    return value_.real_ < other.value_.real_;
  case booleanValue:
    return value_.bool_ < other.value_.bool_;
  case stringValue: {
    if ((value_.string_ == nullptr) || (other.value_.string_ == nullptr)) {
      if (other.value_.string_)
        return true;
      else
        return false;
    }
    unsigned this_len;
    unsigned other_len;
    char const* this_str;
    char const* other_str;
    decodePrefixedString(this->isAllocated(), this->value_.string_, &this_len,
                         &this_str);
    decodePrefixedString(other.isAllocated(), other.value_.string_, &other_len,
                         &other_str);
    unsigned min_len = std::min<unsigned>(this_len, other_len);
    JSON_ASSERT(this_str && other_str);
    int comp = memcmp(this_str, other_str, min_len);
    if (comp < 0)
      return true;
    if (comp > 0)
      return false;
    return (this_len < other_len);
  }
  case arrayValue:
  case objectValue: {
    int delta = int(value_.map_->size() - other.value_.map_->size());
    if (delta)
      return delta < 0;
    return (*value_.map_) < (*other.value_.map_);
  }
  default:
    JSON_ASSERT_UNREACHABLE;
  }
  return false; // unreachable
}
开发者ID:mloy,项目名称:jsoncpp,代码行数:51,代码来源:json_value.cpp


示例16: pushValue

void
StyledStreamWriter::writeArrayValue( const Value &value )
{
   unsigned size = value.size();
   if ( size == 0 )
      pushValue( "[]" );
   else
   {
      bool isArrayMultiLine = isMultineArray( value );
      if ( isArrayMultiLine )
      {
         writeWithIndent( "[" );
         indent();
         bool hasChildValue = !childValues_.empty();
         unsigned index =0;
         while ( true )
         {
            const Value &childValue = value[index];
            writeCommentBeforeValue( childValue );
            if ( hasChildValue )
               writeWithIndent( childValues_[index] );
            else
            {
           writeIndent();
               writeValue( childValue );
            }
            if ( ++index == size )
            {
               writeCommentAfterValueOnSameLine( childValue );
               break;
            }
            *document_ << ",";
            writeCommentAfterValueOnSameLine( childValue );
         }
         unindent();
         writeWithIndent( "]" );
      }
      else // output on a single line
      {
         JSON_ASSERT( childValues_.size() == size );
         *document_ << "[ ";
         for ( unsigned index =0; index < size; ++index )
         {
            if ( index > 0 )
               *document_ << ", ";
            *document_ << childValues_[index];
         }
         *document_ << " ]";
      }
   }
}
开发者ID:0xffffffff,项目名称:rtbkit,代码行数:51,代码来源:json_writer.cpp


示例17: JSON_ASSERT

  const Value &Value::operator[](const char *key) const {
    JSON_ASSERT(type_ == nullValue || type_ == objectValue);
    if (type_ == nullValue)
      return null;
#ifndef JSON_VALUE_USE_INTERNAL_MAP
    CZString actualKey(key, CZString::noDuplication);
    ObjectValues::const_iterator it = value_.map_->find(actualKey);
    if (it == value_.map_->end())
      return null;
    return (*it).second;
#else
    const Value *value = value_.map_->find(key);
    return value ? *value : null;
#endif
  }
开发者ID:hroskes,项目名称:cmssw,代码行数:15,代码来源:json_value.cpp


示例18: JSON_ASSERT

void
Value::clear ()
{
    JSON_ASSERT ( type_ == nullValue  ||  type_ == arrayValue  || type_ == objectValue );

    switch ( type_ )
    {
    case arrayValue:
    case objectValue:
        value_.map_->clear ();
        break;

    default:
        break;
    }
}
开发者ID:CFQuantum,项目名称:CFQuantumd,代码行数:16,代码来源:json_value.cpp


示例19: JSON_ASSERT

Value Value::removeMemberByQuery(const string& key, const string& value) {
    JSON_ASSERT( type_ == nullValue  ||  type_ == arrayValue );
    if ( type_ == nullValue )
        return null;
    
    for(ObjectValues::iterator it = value_.map_->begin(); it != value_.map_->end(); it++) {
        Value& sub = it->second;
        if(sub.isMember(key)) {
            if(sub[key].asString() == value) {
                Value old(it->second);
                value_.map_->erase(it);
                return old;
            }
        }
    }
    return null;
}
开发者ID:GreatFireWall,项目名称:cocos2dx-better,代码行数:17,代码来源:json_value.cpp


示例20: JSON_ASSERT_MESSAGE

void Value::resize(ArrayIndex newSize) {
  JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == arrayValue,
                      "in Json::Value::resize(): requires arrayValue");
  if (type_ == nullValue)
    *this = Value(arrayValue);
  ArrayIndex oldSize = size();
  if (newSize == 0)
    clear();
  else if (newSize > oldSize)
    (*this)[newSize - 1];
  else {
    for (ArrayIndex index = newSize; index < oldSize; ++index) {
      value_.map_->erase(index);
    }
    JSON_ASSERT(size() == newSize);
  }
}
开发者ID:4ib3r,项目名称:domoticz,代码行数:17,代码来源:json_value.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ JSON_ASSERT_MESSAGE函数代码示例发布时间:2022-05-30
下一篇:
C++ JSIOCGNAME函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap