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


C++ JSON_ASSERT函数代码示例

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


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


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