本文整理汇总了C++中STObject::getSerializer方法的典型用法代码示例。如果您正苦于以下问题:C++ STObject::getSerializer方法的具体用法?C++ STObject::getSerializer怎么用?C++ STObject::getSerializer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类STObject
的用法示例。
在下文中一共展示了STObject::getSerializer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testSerialization
void testSerialization ()
{
testcase ("serialization");
unexpected (sfGeneric.isUseful (), "sfGeneric must not be useful");
SField const& sfTestVL = SField::getField (STI_VL, 255);
SField const& sfTestH256 = SField::getField (STI_HASH256, 255);
SField const& sfTestU32 = SField::getField (STI_UINT32, 255);
SField const& sfTestObject = SField::getField (STI_OBJECT, 255);
SOTemplate elements;
elements.push_back (SOElement (sfFlags, SOE_REQUIRED));
elements.push_back (SOElement (sfTestVL, SOE_REQUIRED));
elements.push_back (SOElement (sfTestH256, SOE_OPTIONAL));
elements.push_back (SOElement (sfTestU32, SOE_REQUIRED));
STObject object1 (elements, sfTestObject);
STObject object2 (object1);
unexpected (object1.getSerializer () != object2.getSerializer (),
"STObject error 1");
unexpected (object1.isFieldPresent (sfTestH256) ||
!object1.isFieldPresent (sfTestVL), "STObject error");
object1.makeFieldPresent (sfTestH256);
unexpected (!object1.isFieldPresent (sfTestH256), "STObject Error 2");
unexpected (object1.getFieldH256 (sfTestH256) != uint256 (),
"STObject error 3");
if (object1.getSerializer () == object2.getSerializer ())
{
WriteLog (lsINFO, STObject) << "O1: " << object1.getJson (0);
WriteLog (lsINFO, STObject) << "O2: " << object2.getJson (0);
fail ("STObject error 4");
}
else
{
pass ();
}
object1.makeFieldAbsent (sfTestH256);
unexpected (object1.isFieldPresent (sfTestH256), "STObject error 5");
unexpected (object1.getFlags () != 0, "STObject error 6");
unexpected (object1.getSerializer () != object2.getSerializer (),
"STObject error 7");
STObject copy (object1);
unexpected (object1.isFieldPresent (sfTestH256), "STObject error 8");
unexpected (copy.isFieldPresent (sfTestH256), "STObject error 9");
unexpected (object1.getSerializer () != copy.getSerializer (),
"STObject error 10");
copy.setFieldU32 (sfTestU32, 1);
unexpected (object1.getSerializer () == copy.getSerializer (),
"STObject error 11");
for (int i = 0; i < 1000; i++)
{
Blob j (i, 2);
object1.setFieldVL (sfTestVL, j);
Serializer s;
object1.add (s);
SerialIter it (s.slice());
STObject object3 (elements, it, sfTestObject);
unexpected (object1.getFieldVL (sfTestVL) != j, "STObject error");
unexpected (object3.getFieldVL (sfTestVL) != j, "STObject error");
}
}