本文整理汇总了C++中Message::AddTag方法的典型用法代码示例。如果您正苦于以下问题:C++ Message::AddTag方法的具体用法?C++ Message::AddTag怎么用?C++ Message::AddTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message
的用法示例。
在下文中一共展示了Message::AddTag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
// This program exercises the Message class.
int main(void)
{
Message m1;
m1.AddFloat("va", 1.0f);
printf("m1=" UINT32_FORMAT_SPEC "\n", m1.FlattenedSize());
m1.AddInt32("co", 32);
printf("m2=" UINT32_FORMAT_SPEC "\n", m1.FlattenedSize());
printSep("Testing Replace*() with okayToAdd...");
Message butter;
butter.ReplaceInt8(true, "int8", 8);
butter.ReplaceInt16(true, "int16", 16);
butter.ReplaceInt32(true, "int32", 32);
butter.ReplaceInt64(true, "int64", 64);
butter.ReplaceFloat(true, "float", 3.14f);
butter.ReplaceDouble(true, "double", 6.28);
butter.ReplacePoint(true, "point", Point(5,4));
butter.ReplaceRect(true, "rect", Rect(5,6,7,8));
butter.ReplacePointer(true, "pointer", &butter);
butter.PrintToStream();
butter.ReplaceInt16(true, "int16", 0, 17);
butter.ReplaceInt16(true, "int16", 1, 18);
butter.ReplaceInt8(true, "int8", 25, 25); // should work the same as AddInt8("int8", 25);
butter.AddTag("Tag", RefCountableRef(GetMessageFromPool(6666)()));
butter.AddTag("Tag", RefCountableRef(GetMessageFromPool(7777)()));
butter.PrintToStream();
printf("(butter==m1) == %i\n", butter == m1);
printf("(butter==butter) == %i\n", butter == butter);
printSep("Testing Add*()...");
Message msg(COMMAND_HELLO);
TEST(msg.AddString("Friesner", "Jeremy"));
TEST(msg.AddString("Friesner", "Joanna"));
TEST(msg.AddString("Friesner", "Joellen"));
TEST(msg.AddString("Chicken", "Soup"));
TEST(msg.AddString("Chicken", "Vegetable"));
TEST(msg.AddString("Chicken", "Lips"));
TEST(msg.AddString("Fred", "Flintstone"));
TEST(msg.AddString("Buddha", "Bark"));
TEST(msg.AddPoint("point12", Point(1,2)));
TEST(msg.AddPoint("point12", Point(2,1)));
TEST(msg.AddRect("rect1234", Rect(1,2,3,4)));
TEST(msg.AddRect("rect2345", Rect(2,3,4,5)));
TEST(msg.AddData("Data", B_RAW_TYPE, "ABCDEFGHIJKLMNOPQRS", 12));
TEST(msg.AddData("Data", B_RAW_TYPE, "Mouse", 3));
Message subMessage(1);
TEST(subMessage.AddString("I am a", "sub message!"));
TEST(subMessage.AddInt32("My age is", 32));
Message subsubMessage(2);
TEST(subsubMessage.AddBool("Wow, that's deep!", true));
TEST(subsubMessage.AddMessage("This is actually okay to do!", subsubMessage));
TEST(subMessage.AddMessage("subsubMessage", subsubMessage));
TEST(msg.AddMessage("subMessage", subMessage));
{for (int i=0; i<10; i++) TEST(msg.AddInt8("TestInt8", i)); }
{for (int i=0; i<10; i++) TEST(msg.AddInt16("TestInt16", i)); }
{for (int i=0; i<10; i++) TEST(msg.AddInt32("TestInt32", i)); }
{for (int i=0; i<10; i++) TEST(msg.AddInt64("TestInt64", i)); }
{for (int i=0; i<10; i++) TEST(msg.AddDouble("TestDouble", i));}
{for (int i=0; i<10; i++) TEST(msg.AddFloat("TestFloat", i)); }
{for (int i=0; i<10; i++) TEST(msg.AddBool("TestBool", i)); }
printf("Finished message:\n");
msg.PrintToStream();
printSep("Testing RemoveName, RemoveData, Replace*()...");
TEST(msg.RemoveData("TestInt8", 5));
TEST(msg.RemoveName("Buddha"));
TEST(msg.RemoveData("Fred", 0));
TEST(msg.RemoveData("Friesner", 1));
NEGATIVETEST(msg.RemoveData("Glorp", 0));
NEGATIVETEST(msg.RemoveData("Chicken", 5));
TEST(msg.ReplaceString(false, "Friesner", 0, "Jorge"));
TEST(msg.ReplaceString(false, "Chicken", 1, "Feet"));
TEST(msg.ReplaceString(false, "Chicken", 2, "Breast"));
NEGATIVETEST(msg.ReplaceString(false, "Chicken", 3, "Soul"));
TEST(msg.ReplaceDouble(true, "TestDouble", 2, 222.222));
TEST(msg.ReplaceFloat(true, "TestFloat", 3, 333.333));
NEGATIVETEST(msg.ReplaceFloat(false, "RootBeerFloat", 0, 444.444f));
TEST(msg.ReplaceBool(false, "TestBool", 5));
TEST(msg.ReplaceRect(false, "rect2345", Rect(2,3,4,5)));
Message eqMsg = msg;
printf("EQMSG=msg == %i\n", eqMsg==msg);
printf("Replaced message:\n");
msg.PrintToStream();
printSep("Testing the Find() commands...");
String strResult;
TEST(msg.FindString("Friesner", strResult));
printf("Friesner(0) = %s\n", strResult.Cstr());
//.........这里部分代码省略.........