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


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

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


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

示例1: parseAttributeValue

/* ****************************************************************************
*
* parseAttributeValue - 
*/
std::string parseAttributeValue(ConnectionInfo* ciP, ContextAttribute* caP)
{
  Document    document;
  OrionError  oe;

  document.Parse(ciP->payload);

  if (document.HasParseError())
  {
    alarmMgr.badInput(clientIp, "JSON parse error");
    oe.reasonPhrase = ERROR_STRING_PARSERROR;
    oe.details      = "Errors found in incoming JSON buffer";
    ciP->httpStatusCode = SccBadRequest;;
    return oe.render(ciP, "");
  }


  if (!document.IsObject() && !document.IsArray())
  {
    alarmMgr.badInput(clientIp, "JSON parse error");
    oe.fill(SccBadRequest, "Neither JSON Object nor JSON Array for attribute::value");
    ciP->httpStatusCode = SccBadRequest;;

    return oe.render(ciP, "");
  }

  caP->valueType  = (document.IsObject())? orion::ValueTypeObject : orion::ValueTypeVector;
  parseContextAttributeCompoundValueStandAlone(document, caP, caP->valueType);

  return "OK";
}
开发者ID:PascaleBorscia,项目名称:fiware-orion,代码行数:35,代码来源:parseAttributeValue.cpp

示例2: a

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

    Document a(&allocator);
    a.Parse("[\"one\", \"two\", \"three\"]");
    EXPECT_FALSE(a.HasParseError());
    EXPECT_TRUE(a.IsArray());
    EXPECT_EQ(3u, a.Size());
    EXPECT_EQ(&a.GetAllocator(), &allocator);

    // Document b; b = a; // does not compile (!is_copy_assignable)
    Document b;
    b = std::move(a);
    EXPECT_TRUE(a.IsNull());
    EXPECT_TRUE(b.IsArray());
    EXPECT_EQ(3u, b.Size());
    EXPECT_EQ(&a.GetAllocator(), (void*)0);
    EXPECT_EQ(&b.GetAllocator(), &allocator);

    b.Parse("{\"Foo\": \"Bar\", \"Baz\": 42}");
    EXPECT_FALSE(b.HasParseError());
    EXPECT_TRUE(b.IsObject());
    EXPECT_EQ(2u, b.MemberCount());

    // Document c; c = a; // does not compile (see static_assert)
    Document c;
    c = std::move(b);
    EXPECT_TRUE(b.IsNull());
    EXPECT_TRUE(c.IsObject());
    EXPECT_EQ(2u, c.MemberCount());
    EXPECT_EQ(&b.GetAllocator(), (void*)0);
    EXPECT_EQ(&c.GetAllocator(), &allocator);
}
开发者ID:Longhui,项目名称:mysql-5.7.9-readcode,代码行数:35,代码来源:documenttest.cpp

示例3: loadPins

void PiIO::loadPins()
{
  // fullPath = CCFileUtils::sharedFileUtils()->fullPathForFilename("pins.json");
//http://rapidjson.org/md_doc_stream.html#FileReadStream

  cout << "load pins" << endl;

  FILE* fp = fopen("pins.json", "r"); // non-Windows use "r"
  char readBuffer[65536];
  FileReadStream is(fp, readBuffer, sizeof(readBuffer));
  Document document;
  document.ParseStream(is);
  fclose(fp);

  assert(document.HasMember("pins"));
  assert(document.IsObject());

  const Value& data = document["pins"];
  //const Value& data = document.FindMember("pins");//.value;
  int size = data.Size();
  size = size - 1;
  cout << "Size is " << size << endl;
  for (int i = size; i >= 0; i--){ // Uses SizeType instead of size_t
    int wpi = -1;
    if(data[i].HasMember("wpi")){
      wpi = data[i]["wpi"].GetInt();
    }
    pins[i].startup(data[i]["pin"].GetInt(), data[i]["name"].GetString(), wpi, i);
  }
  cout << getInfoString() << endl;
}
开发者ID:thepoho,项目名称:pi_tester,代码行数:31,代码来源:pi_io.cpp

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

示例5: a

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

    Document a(&allocator);
    a.Parse("[\"one\", \"two\", \"three\"]");
    EXPECT_FALSE(a.HasParseError());
    EXPECT_TRUE(a.IsArray());
    EXPECT_EQ(3u, a.Size());
    EXPECT_EQ(&a.GetAllocator(), &allocator);

    // Document b(a); // does not compile (!is_copy_constructible)
    Document b(std::move(a));
    EXPECT_TRUE(a.IsNull());
    EXPECT_TRUE(b.IsArray());
    EXPECT_EQ(3u, b.Size());
    EXPECT_THROW(a.GetAllocator(), AssertException);
    EXPECT_EQ(&b.GetAllocator(), &allocator);

    b.Parse("{\"Foo\": \"Bar\", \"Baz\": 42}");
    EXPECT_FALSE(b.HasParseError());
    EXPECT_TRUE(b.IsObject());
    EXPECT_EQ(2u, b.MemberCount());

    // Document c = a; // does not compile (!is_copy_constructible)
    Document c = std::move(b);
    EXPECT_TRUE(b.IsNull());
    EXPECT_TRUE(c.IsObject());
    EXPECT_EQ(2u, c.MemberCount());
    EXPECT_THROW(b.GetAllocator(), AssertException);
    EXPECT_EQ(&c.GetAllocator(), &allocator);
}
开发者ID:amandatta16,项目名称:rapidjson,代码行数:33,代码来源:documenttest.cpp

示例6:

TEST_F(RapidJson, SIMD_SUFFIX(DocumentParseLength_MemoryPoolAllocator)) {
    for (size_t i = 0; i < kTrialCount; i++) {
        Document doc;
        doc.Parse(json_, length_);
        ASSERT_TRUE(doc.IsObject());
    }
}
开发者ID:0x1997,项目名称:rapidjson,代码行数:7,代码来源:rapidjsontest.cpp

示例7: OnPackage

void CubeSession::OnPackage(Package *&pack)
{
	if (!pack || pack->Header.DataLength == 0) return;
	pack->Data[pack->Header.DataLength - 1] = '\0';
	log_debug("on package (fd = %u): %s", static_cast<unsigned int>(fd), pack->Data);

	Document doc;
	doc.Parse(pack->Data);
	//  {"command": "cmd...", arg1: argv1, arg2: argv2, ...}
	do
	{
		if (!doc.IsObject())
		{
			SendError(SESSIONERROR_PROTOCOL_MISMATCH);
			break;
		}

		if (checkObj(doc, 1, "command", "str"))
		{
			handleCommand(doc);
		}
		else
		{
			SendError(SESSIONERROR_PROTOCOL_MISMATCH);
			break;
		}
	} while (false);

	delete pack;
	pack = NULL;
}
开发者ID:DerekDick,项目名称:MagicCube,代码行数:31,代码来源:CubeSession.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: is

/**
 * Constructor.
 * Initialised empty, optionally loading from a file or serialised string.
 * @param file The location of a file containing options, or nullptr if not present.
 * @param json_string The serialised JSON string to load, or nullptr if not present.
 *                    Will take precedence over the contents of the specified
 *                    file, if any.
 */
Options::Options(const char *file, const char *json_string) {
    Document *d = new Document();

    if (json_string) {
        d->Parse<0>(json_string);
    }

    if (file) {
        FILE *fp = fopen(file, "rb");
        if (fp) {
            if (!json_string) {
                char buffer[BUFSIZ];
                FileReadStream is(fp, buffer, sizeof(buffer));
                d->ParseStream<0, UTF8<>, FileReadStream>(is);
            }

            fclose(fp);
            m_file = std::string(file);
        }
    }

    if (!d->IsObject()) {
        d->SetObject();
        m_family_inst = nullptr;
    } else {
        Value *fi = LGetValue(d, FAMILY_DEFAULT);
        if (fi && !fi->IsObject()) {
            fi->SetObject();
        }
        m_family_inst = fi;
    }

    m_doc = d;
    m_family = FAMILY_DEFAULT;
}
开发者ID:picopter,项目名称:picopterx,代码行数:43,代码来源:opts.cpp

示例10: deserialize

void HostNamePartialControllerData::deserialize(Document& d) {
    if (d.IsObject()) {
        if (d.HasMember("data")) {
            Message::Value& v = d["data"];
            if (v.IsString()) data = std::string(v.GetString());
        }
    }
}
开发者ID:aspros18,项目名称:RemoteControlCar,代码行数:8,代码来源:HostNamePartialControllerData.cpp

示例11: s

TEST_F(RapidJson, SIMD_SUFFIX(DocumentParseStdString_MemoryPoolAllocator)) {
    const std::string s(json_, length_);
    for (size_t i = 0; i < kTrialCount; i++) {
        Document doc;
        doc.Parse(s);
        ASSERT_TRUE(doc.IsObject());
    }
}
开发者ID:0x1997,项目名称:rapidjson,代码行数:8,代码来源:rapidjsontest.cpp

示例12: memcpy

TEST_F(RapidJson, SIMD_SUFFIX(DocumentParseIterativeInsitu_MemoryPoolAllocator)) {
    for (size_t i = 0; i < kTrialCount; i++) {
        memcpy(temp_, json_, length_ + 1);
        Document doc;
        doc.ParseInsitu<kParseIterativeFlag>(temp_);
        ASSERT_TRUE(doc.IsObject());
    }
}
开发者ID:0x1997,项目名称:rapidjson,代码行数:8,代码来源:rapidjsontest.cpp

示例13: ms

TEST_F(RapidJson, SIMD_SUFFIX(DocumentParseEncodedInputStream_MemoryStream)) {
    for (size_t i = 0; i < kTrialCount; i++) {
        MemoryStream ms(json_, length_);
        EncodedInputStream<UTF8<>, MemoryStream> is(ms);
        Document doc;
        doc.ParseStream<0, UTF8<> >(is);
        ASSERT_TRUE(doc.IsObject());
    }
}
开发者ID:0x1997,项目名称:rapidjson,代码行数:9,代码来源:rapidjsontest.cpp

示例14: init

void GBlurProcessor::init(const char* json) {
  // Read json string to set properties
  using namespace rapidjson;
  Document document;
  document.Parse(json);
  assert(document.IsObject());
  assert(document.HasMember("level"));
  level = document["level"].GetInt();
}
开发者ID:AndreySheka,项目名称:NaCl,代码行数:9,代码来源:processor_gblur.cpp

示例15: init

void SobelProcessor::init(const char* json) {
  // Read json string to set properties
  using namespace rapidjson;
  Document document;
  document.Parse(json);
  assert(document.IsObject());
  assert(document.HasMember("ksize"));
  ksize = document["ksize"].GetInt();
}
开发者ID:AndreySheka,项目名称:NaCl,代码行数:9,代码来源:processor_sobel.cpp


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