本文整理汇总了C++中StringBuffer::Put方法的典型用法代码示例。如果您正苦于以下问题:C++ StringBuffer::Put方法的具体用法?C++ StringBuffer::Put怎么用?C++ StringBuffer::Put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringBuffer
的用法示例。
在下文中一共展示了StringBuffer::Put方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST(StringBuffer, Clear) {
StringBuffer buffer;
buffer.Put('A');
buffer.Put('B');
buffer.Put('C');
buffer.Clear();
EXPECT_EQ(0u, buffer.GetSize());
EXPECT_STREQ("", buffer.GetString());
}
示例2: y
TEST(StringBuffer, MoveConstructor) {
StringBuffer x;
x.Put('A');
x.Put('B');
x.Put('C');
x.Put('D');
EXPECT_EQ(4u, x.GetSize());
EXPECT_STREQ("ABCD", x.GetString());
// StringBuffer y(x); // does not compile (!is_copy_constructible)
StringBuffer y(std::move(x));
EXPECT_EQ(0u, x.GetSize());
EXPECT_EQ(4u, y.GetSize());
EXPECT_STREQ("ABCD", y.GetString());
// StringBuffer z = y; // does not compile (!is_copy_assignable)
StringBuffer z = std::move(y);
EXPECT_EQ(0u, y.GetSize());
EXPECT_EQ(4u, z.GetSize());
EXPECT_STREQ("ABCD", z.GetString());
}
示例3: serialize
StringBuffer* OpflexMessage::serialize() {
StringBuffer* sb = new StringBuffer();
Writer<StringBuffer> writer(*sb);
writer.StartObject();
switch (type) {
case REQUEST:
writer.String("method");
writer.String(method.c_str());
writer.String("params");
serializePayload(writer);
break;
case RESPONSE:
writer.String("result");
serializePayload(writer);
writer.String("error");
writer.Null();
break;
case ERROR_RESPONSE:
writer.String("result");
writer.Null();
writer.String("error");
serializePayload(writer);
break;
}
writer.String("id");
if (id == NULL)
writer.String(method.c_str());
else
id->Accept(writer);
writer.EndObject();
// we delimit our frames with a nul byte
sb->Put('\0');
return sb;
}
示例4:
TEST_F(RapidJson, StringBuffer) {
StringBuffer sb;
for (int i = 0; i < 32 * 1024 * 1024; i++)
sb.Put(i & 0x7f);
}