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


C++ Document::HasMember方法代码示例

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


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

示例1: FetchFromWebBlocking

BOOL AchievementSet::FetchFromWebBlocking( GameID nGameID )
{
	//	Can't open file: attempt to find it on SQL server!
	PostArgs args;
	args['u'] = RAUsers::LocalUser().Username();
	args['t'] = RAUsers::LocalUser().Token();
	args['g'] = std::to_string( nGameID );
	args['h'] = g_bHardcoreModeActive ? "1" : "0";

	Document doc;
	if( RAWeb::DoBlockingRequest( RequestPatch, args, doc ) && 
		doc.HasMember( "Success" ) && 
		doc[ "Success" ].GetBool() && 
		doc.HasMember( "PatchData" ) )
	{
		const Value& PatchData = doc[ "PatchData" ];

		//const std::string& sMinVer = PatchData["MinVer"].GetString();
		//const long nMinVerRequired = strtol( sMinVer.substr( 2 ).c_str(), NULL, 10 );
		
		//const long CURRENT_VER = strtol( std::string( g_sClientVersion ).substr( 2 ).c_str(), nullptr, 10 );
		//if( CURRENT_VER < nMinVerRequired )
		//{
		//	//	Client version too old!

		//	char buffer[4096];
		//	sprintf_s( buffer, 4096, 
		//		"Client version of 0.%03d is too old for the latest patch format.\r\n"
		//		"Version 0.%03d or greater required.\r\n"
		//		"Visit " RA_HOST " for a more recent version? ",
		//		CURRENT_VER,
		//		nMinVerRequired );

		//	if( MessageBox( nullptr, buffer, "Client out of date!", MB_YESNO ) == IDYES )
		//	{
		//		sprintf_s( buffer, 4096, "http://" RA_HOST "/download.php" );

		//		ShellExecute( NULL,
		//			"open",
		//			buffer,
		//			NULL,
		//			NULL,
		//			SW_SHOWNORMAL );
		//	}
		//	else
		//	{
		//		//MessageBox( nullptr, "Cannot load achievements for this game.", "Error", MB_OK );
		//	}

		//	return FALSE;
		//}
		//else
		{
			SetCurrentDirectory( Widen( g_sHomeDir ).c_str() );
			FILE* pf = nullptr;
			fopen_s( &pf, std::string( RA_DIR_DATA + std::to_string( nGameID ) + ".txt" ).c_str(), "wb" );
			if( pf != nullptr )
			{
				FileStream fs( pf );
				Writer<FileStream> writer( fs );
				PatchData.Accept( writer );
				fclose( pf );
				return TRUE;
			}
			else
			{
				ASSERT( !"Could not open patch file for writing?" );
				RA_LOG( "Could not open patch file for writing?" );
				return FALSE;
			}
		}
	}
	else
	{
		//	Could not connect...
		PopupWindows::AchievementPopups().AddMessage( 
			MessagePopup( "Could not connect to " RA_HOST_URL "...", "Working offline...", PopupInfo ) ); //?

		return FALSE;
	}
}
开发者ID:ddugovic,项目名称:RASuite,代码行数:81,代码来源:RA_AchievementSet.cpp

示例2: parseBatchQuery

/* ****************************************************************************
*
* parseBatchQuery - 
*/
std::string parseBatchQuery(ConnectionInfo* ciP, BatchQuery* bqrP)
{
  Document document;

  document.Parse(ciP->payload);

  if (document.HasParseError())
  {
    ErrorCode ec;

    alarmMgr.badInput(clientIp, "JSON Parse Error");
    ec.fill(ERROR_STRING_PARSERROR, "Errors found in incoming JSON buffer");
    ciP->httpStatusCode = SccBadRequest;

    return ec.toJson(true);
  }

  if (!document.IsObject())
  {
    ErrorCode ec;

    alarmMgr.badInput(clientIp, "JSON Parse Error");
    ec.fill("BadRequest", "JSON Parse Error");
    ciP->httpStatusCode = SccBadRequest;

    return ec.toJson(true);
  }
  else if (document.ObjectEmpty())
  {
    ErrorCode ec;

    alarmMgr.badInput(clientIp, "Empty JSON payload");
    ec.fill("BadRequest", "empty payload");
    ciP->httpStatusCode = SccBadRequest;

    return ec.toJson(true);
  }
  else if (!document.HasMember("entities") && !document.HasMember("attributes") && !document.HasMember("scopes"))
  {
    ErrorCode ec;

    alarmMgr.badInput(clientIp, "Invalid JSON payload, no relevant fields found");
    ec.fill("BadRequest", "Invalid JSON payload, no relevant fields found");
    ciP->httpStatusCode = SccBadRequest;

    return ec.toJson(true);
  }

  for (Value::ConstMemberIterator iter = document.MemberBegin(); iter != document.MemberEnd(); ++iter)
  {
    std::string name   = iter->name.GetString();
    std::string type   = jsonParseTypeNames[iter->value.GetType()];

    if (name == "entities")
    {
      std::string r = parseEntityVector(ciP, iter, &bqrP->entities, false);  // param 4: attributes are NOT allowed in payload

      if (r != "OK")
      {
        ErrorCode ec("BadRequest", r);

        alarmMgr.badInput(clientIp, r);
        ciP->httpStatusCode = SccBadRequest;
        return ec.toJson(true);
      }
    }
    else if (name == "attributes")
    {
      std::string r = parseAttributeList(ciP, iter, &bqrP->attributeV);

      if (r != "OK")
      {
        ErrorCode ec("BadRequest", r);

        alarmMgr.badInput(clientIp, r);
        ciP->httpStatusCode = SccBadRequest;
        return ec.toJson(true);
      }
    }
    else if (name == "scopes")
    {
      std::string r = parseScopeVector(ciP, iter, &bqrP->scopeV);

      if (r != "OK")
      {
        ErrorCode ec("BadRequest", r);

        alarmMgr.badInput(clientIp, r);
        ciP->httpStatusCode = SccBadRequest;
        return ec.toJson(true);
      }
    }
    else
    {
      std::string  description = std::string("Unrecognized field in JSON payload: /") + name + "/";
      ErrorCode    ec("BadRequest", description);
//.........这里部分代码省略.........
开发者ID:LeonanCarvalho,项目名称:fiware-orion,代码行数:101,代码来源:parseBatchQuery.cpp

示例3: parse_document

  bool parse_document(const Document& document, std::vector<rectangle>& input_rectangle)
  {
    if(!document.IsObject())
    {
      return false;
    }

    // check rects array
    if(document.HasMember(RECTANGLES_KEY) && document[RECTANGLES_KEY].IsArray())
    {
      //iterate and validate each element
      const Value& rects = document[RECTANGLES_KEY];
      for (SizeType count = 0; count < rects.Size(); count++)
      {
        //check x
        origin_t x = 0;
        if(rects[count].HasMember(RECTANGLES_X) && rects[count][RECTANGLES_X].IsInt())
        {
          x = rects[count][RECTANGLES_X].GetInt();
        }
        else
        {
          print_error(RECTANGLES_X);
          return false;
        }

        //check y
        origin_t y = 0;
        if(rects[count].HasMember(RECTANGLES_Y) && rects[count][RECTANGLES_Y].IsInt())
        {
          y = rects[count][RECTANGLES_Y].GetInt();
        }
        else
        {
          print_error(RECTANGLES_Y);
          return false;
        }

        //check w
        distance_t w = 0;
        if(rects[count].HasMember(RECTANGLES_W) && rects[count][RECTANGLES_W].IsUint())
        {
          w = rects[count][RECTANGLES_W].GetUint();
        }
        else
        {
          print_error(RECTANGLES_W);
          return false;
        }

        //check h
        distance_t h = 0;
        if(rects[count].HasMember(RECTANGLES_H) && rects[count][RECTANGLES_H].IsUint())
        {
          h = rects[count][RECTANGLES_H].GetUint();
        }
        else
        {
          print_error(RECTANGLES_H);
          return false;
        }

        input_rectangle.push_back(rectangle(x, y, w, h, std::to_string(static_cast<ullong_int_t>(count+1))));
      }
    }
    else
    {
      print_error(RECTANGLES_KEY);
      return false;
    }

    return true;
  }
开发者ID:mhbelouni,项目名称:shared,代码行数:73,代码来源:rectanglebuilder.cpp


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