本文整理汇总了C++中Document::MemberCount方法的典型用法代码示例。如果您正苦于以下问题:C++ Document::MemberCount方法的具体用法?C++ Document::MemberCount怎么用?C++ Document::MemberCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Document
的用法示例。
在下文中一共展示了Document::MemberCount方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: isw
TEST(IStreamWrapper, fstream)
{ fstream fs;
ASSERT_TRUE(Open(fs, "utf8bom.json"));
IStreamWrapper isw(fs);
EncodedInputStream<UTF8<>, IStreamWrapper> eis(isw);
Document d;
EXPECT_TRUE(!d.ParseStream(eis).HasParseError());
EXPECT_TRUE(d.IsObject());
EXPECT_EQ(5, d.MemberCount());
}
示例4:
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);
}