本文整理汇总了C++中Package::encode方法的典型用法代码示例。如果您正苦于以下问题:C++ Package::encode方法的具体用法?C++ Package::encode怎么用?C++ Package::encode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Package
的用法示例。
在下文中一共展示了Package::encode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
TEST_TAG(Package);
string coded;
auto formats = {Format::Block, Format::Stream};
for (auto format = formats.begin(); format != formats.end(); ++format)
{
auto checksums = {true, false};
for (auto cs = checksums.begin(); cs != checksums.end(); ++cs)
{
string cs_s = (*cs ? "checksum" : "no checksum");
Package pkg;
pkg.format(*format);
pkg.checksum(*cs);
pkg.encode(coded);
L("coded(" << to_s(*format) << ", " << cs_s << "): " << toHex(coded));
string alternating;
for (int i = 0; i < 50; ++i)
alternating.append("\xd8" "a");
vector<string> plains = {"", "abc", "a" "\xd8" "b" "\xd9" "c", "\xd8" "\xd9" "\xd8" "\xd9" "\xd8" "\xd9" "\xd8", string(100, '0'), string(100, 0xd9), alternating};
for (auto plain = plains.begin(); plain != plains.end(); ++plain)
{
pkg.content(*plain);
L("plain: " << toHex(*plain));
pkg.encode(coded);
L("coded(" << to_s(*format) << ", " << cs_s << "): length: " << coded.size() << ", hex: " << toHex(coded));
{
Package pkg2;
TEST_OK(pkg2.decode(coded));
string plain2;
TEST_OK(pkg2.getContent(plain2));
TEST_EQ(*plain, plain2);
}
}
}
}
return 0;
}