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


C++ ConstValueIterator::IsArray方法代码示例

本文整理汇总了C++中value::ConstValueIterator::IsArray方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstValueIterator::IsArray方法的具体用法?C++ ConstValueIterator::IsArray怎么用?C++ ConstValueIterator::IsArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在value::ConstValueIterator的用法示例。


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

示例1: iterateArray

void iterateArray(Value::ConstValueIterator& itr,
		Value::ConstValueIterator& itrEnd, StringBuffer *buffer,
		Writer<StringBuffer> *writer, stringstream& ss) {
	for (; itr != itrEnd; itr++) {
		if (itr->IsObject()) {
			Value::ConstMemberIterator itr_ = itr->MemberBegin();
			Value::ConstMemberIterator itrEnd_ = itr->MemberEnd();
			iterateObject(itr_, itrEnd_, buffer, writer, ss);
		} else if (itr->IsArray()) {
			Value::ConstValueIterator itr_ = itr->Begin();
			Value::ConstValueIterator itrEnd_ = itr->End();
			iterateArray(itr_, itrEnd_, buffer, writer, ss);
		} else if (itr->IsBool()) {
			ss << DELIM << itr->GetBool();
		} else if (itr->IsInt()) {
			ss << DELIM << itr->GetInt();
		} else if (itr->IsInt64()) {
			ss << DELIM << itr->GetInt64();
		} else if (itr->IsDouble()) {
			ss << DELIM << itr->GetDouble();
		} else if (itr->IsString()) {
			ss << DELIM << "\"" << itr->GetString() << "\"";
		} else {
			throw runtime_error(string("Case missing from tokenizer"));
		}
	}
}
开发者ID:manosk,项目名称:jsonToCSV,代码行数:27,代码来源:convertJSON.cpp

示例2: if

/* ****************************************************************************
*
* parseContextAttributeCompoundValue - 
*/
std::string parseContextAttributeCompoundValue
(
  const Value::ConstValueIterator&   node,
  ContextAttribute*                  caP,
  orion::CompoundValueNode*          parent
)  
{
  if (node->IsObject())
  {
    int counter  = 0;

    for (Value::ConstMemberIterator iter = node->MemberBegin(); iter != node->MemberEnd(); ++iter)
    {
      std::string                nodeType = jsonParseTypeNames[iter->value.GetType()];
      orion::CompoundValueNode*  cvnP     = new orion::CompoundValueNode();

      cvnP->valueType  = stringToCompoundType(nodeType);

      cvnP->name       = iter->name.GetString();
      cvnP->container  = parent;
      cvnP->rootP      = parent->rootP;
      cvnP->level      = parent->level + 1;
      cvnP->siblingNo  = counter;
      cvnP->path       = parent->path + cvnP->name;

      if (nodeType == "String")
      {
        cvnP->stringValue       = iter->value.GetString();
      }
      else if (nodeType == "Number")
      {
        cvnP->numberValue = iter->value.GetDouble();
      }
      else if ((nodeType == "True") || (nodeType == "False"))
      {
        cvnP->boolValue   = (nodeType == "True")? true : false;
      }
      else if (nodeType == "Null")
      {
        cvnP->valueType = orion::ValueTypeNone;
      }
      else if (nodeType == "Object")
      {
        cvnP->path += "/";
        cvnP->valueType = orion::ValueTypeObject;
      }
      else if (nodeType == "Array")
      {
        cvnP->path += "/";
        cvnP->valueType = orion::ValueTypeVector;
      }

      parent->childV.push_back(cvnP);
        
      //
      // Recursive call if Object or Array
      //
      if ((nodeType == "Object") || (nodeType == "Array"))
      {
        parseContextAttributeCompoundValue(iter, caP, cvnP);
      }

      ++counter;
    }
  }
  else if (node->IsArray())
  {
    int counter  = 0;

    for (Value::ConstValueIterator iter = node->Begin(); iter != node->End(); ++iter)
    {
      std::string                nodeType  = jsonParseTypeNames[iter->GetType()];
      orion::CompoundValueNode*  cvnP      = new orion::CompoundValueNode();
      char                       itemNo[4];

      snprintf(itemNo, sizeof(itemNo), "%03d", counter);

      cvnP->valueType  = stringToCompoundType(nodeType);
      cvnP->container  = parent;
      cvnP->rootP      = parent->rootP;
      cvnP->level      = parent->level + 1;
      cvnP->siblingNo  = counter;
      cvnP->path       = parent->path + "[" + itemNo + "]";


      if (nodeType == "String")
      {
        cvnP->stringValue       = iter->GetString();
      }
      else if (nodeType == "Number")
      {
        cvnP->numberValue = iter->GetDouble();
      }
      else if ((nodeType == "True") || (nodeType == "False"))
      {
        cvnP->boolValue   = (nodeType == "True")? true : false;
//.........这里部分代码省略.........
开发者ID:Fiware,项目名称:context.Orion,代码行数:101,代码来源:parseContextAttributeCompoundValue.cpp

示例3: if

std::vector<SlotType>
MtgJsonAllSetsData::getBoosterSlots( const std::string& code ) const
{
    std::vector<SlotType> boosterSlots;

    if( mBoosterSetCodes.count(code) == 0 )
    {
        mLogger->warn( "No booster member in set {}, returning empty booster slots", code );
        return boosterSlots;
    }

    // In parse() this was vetted to be safe and yield an Array-type value.
    const Value& boosterValue = mDoc[code]["booster"];

    mLogger->debug( "{:-^40}", "assembling booster slots" );
    for( Value::ConstValueIterator iter = boosterValue.Begin(); iter != boosterValue.End(); ++iter )
    {
        if( iter->IsArray() )
        {
            // create a set of any strings in the array
            std::set<std::string> slotArraySet;
            for( unsigned i = 0; i < iter->Size(); ++i )
            {
                const Value& val = (*iter)[i];
                if( val.IsString() )
                {
                    slotArraySet.insert( val.GetString() );
                    mLogger->debug( "booster slot array[{}]: {}", i, val.GetString() );
                }
                else
                {
                    mLogger->warn( "Non-string in booster slot array, ignoring!" );
                }
            }
            const std::set<std::string> rareMythicRareSlot { "rare", "mythic rare" };
            if( slotArraySet == rareMythicRareSlot )
                boosterSlots.push_back( SLOT_RARE_OR_MYTHIC_RARE );
            else
                mLogger->warn( "Unrecognized booster slot array, ignoring!" );
        }
        else if( iter->IsString() )
        {
            std::string slotStr( iter->GetString() );
            mLogger->debug( "booster slot string: {}", slotStr );
            if( slotStr == "common" )
                boosterSlots.push_back( SLOT_COMMON );
            else if( slotStr == "uncommon" )
                boosterSlots.push_back( SLOT_UNCOMMON );
            else if( slotStr == "rare" )
                boosterSlots.push_back( SLOT_RARE );
            else if( slotStr == "timeshifted purple" )
                boosterSlots.push_back( SLOT_TIMESHIFTED_PURPLE );
            else if( slotStr == "land" )      { /* do nothing */ }
            else if( slotStr == "marketing" ) { /* do nothing */ }
            else
                mLogger->warn( "Unrecognized booster slot type {}, ignoring!", slotStr );
        }
        else
        {
            mLogger->warn( "Non-string booster slot type, ignoring!" );
        }
    }
    return boosterSlots;
}
开发者ID:mildmongrel,项目名称:thicket,代码行数:64,代码来源:MtgJsonAllSetsData.cpp


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