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


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

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


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

示例1: error

TYPED_TEST(DocumentMove, MoveAssignmentParseError) {
    typedef TypeParam Allocator;
    typedef GenericDocument<UTF8<>, Allocator> Document;

    ParseResult noError;
    Document a;
    a.Parse("{ 4 = 4]");
    ParseResult error(a.GetParseError(), a.GetErrorOffset());
    EXPECT_TRUE(a.HasParseError());
    EXPECT_NE(error.Code(), noError.Code());
    EXPECT_NE(error.Offset(), noError.Offset());

    Document b;
    b = std::move(a);
    EXPECT_FALSE(a.HasParseError());
    EXPECT_TRUE(b.HasParseError());
    EXPECT_EQ(a.GetParseError(), noError.Code());
    EXPECT_EQ(b.GetParseError(), error.Code());
    EXPECT_EQ(a.GetErrorOffset(), noError.Offset());
    EXPECT_EQ(b.GetErrorOffset(), error.Offset());

    Document c;
    c = std::move(b);
    EXPECT_FALSE(b.HasParseError());
    EXPECT_TRUE(c.HasParseError());
    EXPECT_EQ(b.GetParseError(), noError.Code());
    EXPECT_EQ(c.GetParseError(), error.Code());
    EXPECT_EQ(b.GetErrorOffset(), noError.Offset());
    EXPECT_EQ(c.GetErrorOffset(), error.Offset());
}
开发者ID:Longhui,项目名称:mysql-5.7.9-readcode,代码行数:30,代码来源:documenttest.cpp

示例2: InitSession

bool ZatData::InitSession()
{
  string jsonString = HttpGet(zattooServer + "/zapi/v2/session", true);
  Document doc;
  doc.Parse(jsonString.c_str());
  if (doc.GetParseError() || !doc["success"].GetBool())
  {
    XBMC->Log(LOG_ERROR, "Initialize session failed.");
    return false;
  }

  if (!doc["session"]["loggedin"].GetBool())
  {
    XBMC->Log(LOG_DEBUG, "Need to login.");

    string uuid = GetUUID();
    if (uuid.empty())
    {
      return false;
    }

    SendHello(uuid);
    //Ignore if hello fails

    if (!Login())
    {
      return false;
    }
    jsonString = HttpGet(zattooServer + "/zapi/v2/session", true);
    doc.Parse(jsonString.c_str());
    if (doc.GetParseError() || !doc["success"].GetBool()
        || !doc["session"]["loggedin"].GetBool())
    {
      XBMC->Log(LOG_ERROR, "Initialize session failed.");
      return false;
    }
  }

  const Value& session = doc["session"];

  countryCode = session["aliased_country_code"].GetString();
  recallEnabled = streamType == "dash" && session["recall_eligible"].GetBool();
  recordingEnabled = session["recording_eligible"].GetBool();
  if (recallEnabled)
  {
    maxRecallSeconds = session["recall_seconds"].GetInt();
  }
  if (updateThread == NULL)
  {
    updateThread = new UpdateThread(this);
  }
  powerHash = session["power_guide_hash"].GetString();
  return true;
}
开发者ID:vdrtuxnet,项目名称:pvr.zattoo,代码行数:54,代码来源:ZatData.cpp

示例3: initialiseProblemJSON

 EReturn Initialiser::initialiseProblemJSON(PlanningProblem_ptr problem,
     const std::string& constraints)
 {
   {
     Document document;
     if (!document.Parse<0>(constraints.c_str()).HasParseError())
     {
       if (ok(problem->reinitialise(document, problem)))
       {
         // Everythinh is fine
       }
       else
       {
         INDICATE_FAILURE
         ;
         return FAILURE;
       }
     }
     else
     {
       ERROR(
           "Can't parse constraints from JSON string!\n"<<document.GetParseError() <<"\n"<<constraints.substr(document.GetErrorOffset(),50));
       return FAILURE;
     }
   }
   return SUCCESS;
 }
开发者ID:fml927,项目名称:exotica,代码行数:27,代码来源:Initialiser.cpp

示例4: GetChannelStreamUrl

string ZatData::GetChannelStreamUrl(int uniqueId)
{

  ZatChannel *channel = FindChannel(uniqueId);
  //XBMC->QueueNotification(QUEUE_INFO, "Getting URL for channel %s", XBMC->UnknownToUTF8(channel->name.c_str()));

  ostringstream dataStream;
  dataStream << "cid=" << channel->cid << "&stream_type=" << streamType
      << "&format=json";

  if (recallEnabled)
  {
    dataStream << "&timeshift=" << maxRecallSeconds;
  }

  string jsonString = HttpPost(zattooServer + "/zapi/watch", dataStream.str());

  Document doc;
  doc.Parse(jsonString.c_str());
  if (doc.GetParseError() || !doc["success"].GetBool())
  {
    return "";
  }
  string url = doc["stream"]["url"].GetString();
  return url;

}
开发者ID:vdrtuxnet,项目名称:pvr.zattoo,代码行数:27,代码来源:ZatData.cpp

示例5: GetRecordingsAmount

int ZatData::GetRecordingsAmount(bool future)
{
  string jsonString = HttpGetCached(zattooServer + "/zapi/playlist", 60);

  time_t current_time;
  time(&current_time);

  Document doc;
  doc.Parse(jsonString.c_str());
  if (doc.GetParseError() || !doc["success"].GetBool())
  {
    return 0;
  }

  const Value& recordings = doc["recordings"];

  int count = 0;
  for (Value::ConstValueIterator itr = recordings.Begin();
      itr != recordings.End(); ++itr)
  {
    const Value& recording = (*itr);
    time_t startTime = StringToTime(recording["start"].GetString());
    if (future == (startTime > current_time))
    {
      count++;
    }
  }
  return count;
}
开发者ID:vdrtuxnet,项目名称:pvr.zattoo,代码行数:29,代码来源:ZatData.cpp

示例6: onGetRankResponse

void RankScene::onGetRankResponse(HttpClient * sender, HttpResponse *response) {
	if (!response) return;

	if (!response->isSucceed()) {
		log("response failed");
		log("error buffer: %s", response->getErrorBuffer());
		return;
	}

	string res = Global::toString(response->getResponseData());
	Document d;
	d.Parse<0>(res.c_str());

	if (d.HasParseError()) {
		CCLOG("GetParseError %s\n", d.GetParseError());
	}

	if (d.IsObject() && d.HasMember("result") && d.HasMember("info")) {
		bool result = d["result"].GetBool();
		if (!result) {
			CCLOG("Failed to login: %s\n", d["info"].GetString());
		}
		else {
			setRankBoard(d["info"].GetString());
		}
	}
}
开发者ID:zhangsht,项目名称:cocos2d,代码行数:27,代码来源:RankScene.cpp

示例7: LoadFromFile

	bool FileUtil::LoadFromFile(const Serializable::Ptr &source, const std::string &filePath)
	{
		using namespace rapidjson;

		std::ifstream stream(filePath);
		if (stream)
		{
			std::stringstream buffer;
			buffer << stream.rdbuf();

			Document dom;
			dom.Parse(buffer.str().c_str());

			if (dom.HasParseError())
			{
				LOGE << "Error parsing json file " << filePath << ": " << dom.GetParseError();
				return false;
			}

			if (!source->Load(&dom))
			{
				LOGE << "Serialization failed!";
				return false;
			}

			LOGD << filePath << " successfully deserialized!";
			return true;
		}
		return false;
	}
开发者ID:bobbyzhu,项目名称:fury3d,代码行数:30,代码来源:FileUtil.cpp

示例8: onLoginResponse

void LoginScene::onLoginResponse(HttpClient * sender, HttpResponse *response)
{
	if (!response) return;

	if (!response->isSucceed()) {
		log("response failed");
		log("error buffer: %s", response->getErrorBuffer());
		return;
	}

	string res = Global::toString(response->getResponseData());
	Document d;
	d.Parse<0>(res.c_str());

	if (d.HasParseError()) {
		CCLOG("GetParseError %s\n", d.GetParseError());
	}

	if (d.IsObject() && d.HasMember("result") && d.HasMember("info")) {
		bool result = d["result"].GetBool();
		if (result) {
			Global::saveStatus(response->getResponseHeader(), textField->getString());
			Director::getInstance()->replaceScene(TransitionFade::create(1, GameScene::createScene()));
		}
		else {
			CCLOG("Failed to login: %s\n", d["info"].GetString());
		}
	}
}
开发者ID:zhuangqh,项目名称:Cocos2d-x-Development,代码行数:29,代码来源:LoginScene.cpp

示例9:

TEST(Document, UnchangedOnParseError) {
    Document doc;
    doc.SetArray().PushBack(0, doc.GetAllocator());

    ParseResult err = doc.Parse("{]");
    EXPECT_TRUE(doc.HasParseError());
    EXPECT_EQ(err.Code(), doc.GetParseError());
    EXPECT_EQ(err.Offset(), doc.GetErrorOffset());
    EXPECT_TRUE(doc.IsArray());
    EXPECT_EQ(doc.Size(), 1u);

    err = doc.Parse("{}");
    EXPECT_FALSE(doc.HasParseError());
    EXPECT_FALSE(err.IsError());
    EXPECT_EQ(err.Code(), doc.GetParseError());
    EXPECT_EQ(err.Offset(), doc.GetErrorOffset());
    EXPECT_TRUE(doc.IsObject());
    EXPECT_EQ(doc.MemberCount(), 0u);
}
开发者ID:amandatta16,项目名称:rapidjson,代码行数:19,代码来源:documenttest.cpp

示例10: Record

bool ZatData::Record(int programId)
{
  ostringstream dataStream;
  dataStream << "program_id=" << programId;

  string jsonString = HttpPost(zattooServer + "/zapi/playlist/program",
      dataStream.str());
  Document doc;
  doc.Parse(jsonString.c_str());
  return !doc.GetParseError() && doc["success"].GetBool();
}
开发者ID:vdrtuxnet,项目名称:pvr.zattoo,代码行数:11,代码来源:ZatData.cpp

示例11: DeleteRecording

bool ZatData::DeleteRecording(string recordingId)
{
  ostringstream dataStream;
  dataStream << "recording_id=" << recordingId << "";

  string jsonString = HttpPost(zattooServer + "/zapi/playlist/remove",
      dataStream.str());

  Document doc;
  doc.Parse(jsonString.c_str());
  return !doc.GetParseError() && doc["success"].GetBool();
}
开发者ID:vdrtuxnet,项目名称:pvr.zattoo,代码行数:12,代码来源:ZatData.cpp

示例12: PostReq

int Dynamo::PostReq(const std::string &op, const string &req) {

//	logdebug("req: \n%s", req.c_str());
//
//	char *ueReq = curl_easy_escape(curl, req.data(), (int) req.length());
//
//	if (NULL == ueReq) {
//		snprintf(lastErr, sizeof(lastErr), "curl_easy_escape failed");
//		return -1;
//	}
//
//	std::string data = ueReq;
//	curl_free (ueReq);

	if (0 != UpdateHead(op, req)) {
		return -1;
	}

//	logdebug("\ncommand=%s\nrequest=\n%s", op.c_str(), req.c_str());

	curl_easy_setopt(curl, CURLOPT_POSTFIELDS, req.c_str());
//	curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, data.length());

	strRsp.clear();

	CURLcode code = curl_easy_perform(curl);
	if (CURLE_OK != code) {
		snprintf(lastErr, sizeof(lastErr), "%s", curl_easy_strerror(code));
		return -1;
	}
//	logdebug("\ncommand=%s\nresponse=\n%s", op.c_str(), strRsp.c_str());

    Document d;
    d.Parse<0>(strRsp.c_str());
    if (d.HasParseError()) {
    	snprintf(lastErr, sizeof(lastErr), "json doc parse failed, %u", d.GetParseError());
    	return -1;
    }

    rsp.SetNull();
    allocator.Clear();
    rsp.CopyFrom(d, allocator);

    if (rsp.HasMember("__type")) {
		snprintf(lastErr, sizeof(lastErr), "dynamo return error: %s", rsp.FindMember("__type")->value.GetString());
		return -1;
    }

	return 0;
}
开发者ID:jiabinruan,项目名称:gowithcool,代码行数:50,代码来源:Dynamo.cpp

示例13: load_effect

bgfx_effect* effect_manager::load_effect(std::string name)
{
	std::string full_name = name;
	if (full_name.length() < 5 || (full_name.compare(full_name.length() - 5, 5, ".json") != 0)) {
		full_name = full_name + ".json";
	}
	std::string path;
	osd_subst_env(path, util::string_format("%s" PATH_SEPARATOR "effects" PATH_SEPARATOR, m_options.bgfx_path()));
	path += full_name;

	bx::CrtFileReader reader;
	if (!bx::open(&reader, path.c_str()))
	{
		printf("Unable to open effect file %s\n", path.c_str());
		return nullptr;
	}

	int32_t size (bx::getSize(&reader));

	char* data = new char[size + 1];
	bx::read(&reader, reinterpret_cast<void*>(data), size);
	bx::close(&reader);
	data[size] = 0;

	Document document;
	document.Parse<kParseCommentsFlag>(data);

	delete [] data;

	if (document.HasParseError()) {
		std::string error(GetParseError_En(document.GetParseError()));
		printf("Unable to parse effect %s. Errors returned:\n", path.c_str());
		printf("%s\n", error.c_str());
		return nullptr;
	}

	bgfx_effect* effect = effect_reader::read_from_value(document, "Effect '" + name + "': ", m_shaders);

	if (effect == nullptr) {
		printf("Unable to load effect %s\n", path.c_str());
		return nullptr;
	}

	m_effects[name] = effect;

	return effect;
}
开发者ID:qwijibo,项目名称:mame,代码行数:47,代码来源:effectmanager.cpp

示例14: Export

bool Export(const char* data, const char* outFile)
{
	Document document;
	document.Parse(data);

	if (document.HasParseError()) {
		ParseErrorCode err = document.GetParseError();
		printf("pares error! %d %d", err, document.GetErrorOffset());
		return false;
	}

	if (!document.IsObject())
	{
		printf("error, not a object");
		return false;
	}

	InitializeSdkObjects();

	const Value& skel = document["Skeleton"];
	if (!skel.IsNull())
	{
		ExportBones(skel);
	}

	const Value& mesh = document["Mesh"];
	if (!mesh.IsNull())
	{
		for (uint32_t i = 0; i < mesh.Size(); i++)
		{
			ExportFbxMesh(mesh[i]);
		}
	}

	const Value& anim = document["Animation"];
	if (!anim.IsNull())
	{
		for (uint32_t i = 0; i < anim.Size(); i++)
		{
			ExportAnimation(anim[i]);
		}
	}
	
	SaveFbxFile(outFile);

	return true;
}
开发者ID:garudaxc,项目名称:UnityToFbx,代码行数:47,代码来源:fbxExport.cpp

示例15: Init

bool EpicCompiler::Init(char* JsonPath, EpicCompilerConfig Conf[])
{
	// 读入Compiler.json文件
	char json[MAX_SIZE] = { 0 };
	FILE* fp = NULL;
	fopen_s(&fp, JsonPath, "r");
	if (fp == NULL)
		return false;
	fseek(fp, 0, SEEK_END);
	int size = ftell(fp);
	if (size == -1)
		return false;
	rewind(fp);
	fread(json, size, 1, fp); fclose(fp); fclose(fp);
	
	// 把JSON解析至DOM
	Document document;  // Default template parameter uses UTF8 and MemoryPoolAllocator.
	if (document.Parse(json).HasParseError())
	{
		//MessageBoxA(NULL, GetParseError_En(document.GetParseError()), (LPCSTR)(unsigned)document.GetErrorOffset(), MB_ICONWARNING + MB_OK);
		cout << GetParseError_En(document.GetParseError()) << endl;
		return false;
	}

	//读入Json数组
	{
		const Value& a = document["Compilers"]; // 使用引用来让连续访问非常方便和非常快
		assert(a.IsArray());
		for (SizeType i = 0; i < a.Size(); i++) // rapidjson 使用 SizeType 而不是 size_t.
		{
			assert(a[i].IsObject());
			assert(a[i].HasMember("Name"));
			assert(a[i].HasMember("Path"));
			assert(a[i].HasMember("Description"));
			assert(a[i].HasMember("Arguments"));
			assert(a[i]["Name"].IsString());
			assert(a[i]["Path"].IsString());
			assert(a[i]["Description"].IsString());
			assert(a[i]["Arguments"].IsString());
			strcpy_s(Conf[i].name, a[i]["Name"].GetString());
			strcpy_s(Conf[i].path, a[i]["Path"].GetString());
			strcpy_s(Conf[i].desc, a[i]["Description"].GetString());
			strcpy_s(Conf[i].argu, a[i]["Arguments"].GetString());
		}
	}
	return true;
}
开发者ID:Military-Doctor,项目名称:EPIC_Core,代码行数:47,代码来源:Epic_Compiler.cpp


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