本文整理汇总了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";
}
示例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);
}
示例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;
}
示例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());
}
}
}
示例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);
}
示例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());
}
}
示例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;
}
示例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());
}
}
}
示例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;
}
示例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());
}
}
}
示例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());
}
}
示例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());
}
}
示例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());
}
}
示例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();
}
示例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();
}