本文整理汇总了C++中LLMessageTemplate类的典型用法代码示例。如果您正苦于以下问题:C++ LLMessageTemplate类的具体用法?C++ LLMessageTemplate怎么用?C++ LLMessageTemplate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LLMessageTemplate类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: defaultTemplate
void LLTemplateMessageBuilderTestObject::test<17>()
// IPPort
{
LLMessageTemplate messageTemplate = defaultTemplate();
messageTemplate.addBlock(defaultBlock(MVT_IP_PORT, 2));
U16 outValue, inValue = 80;
LLTemplateMessageBuilder* builder = defaultBuilder(messageTemplate);
builder->addIPPort(_PREHASH_Test0, inValue);
LLTemplateMessageReader* reader = setReader(messageTemplate, builder);
reader->getIPPort(_PREHASH_Test0, _PREHASH_Test0, outValue);
ensure_equals("Ensure IPPort", inValue, outValue);
delete reader;
}
示例2: defaultTemplate
void LLTemplateMessageBuilderTestObject::test<14>()
// Quaternion
{
LLMessageTemplate messageTemplate = defaultTemplate();
messageTemplate.addBlock(defaultBlock(MVT_LLQuaternion, 12));
LLQuaternion outValue, inValue = LLQuaternion(1,2,3,0);
LLTemplateMessageBuilder* builder = defaultBuilder(messageTemplate);
builder->addQuat(_PREHASH_Test0, inValue);
LLTemplateMessageReader* reader = setReader(messageTemplate, builder);
reader->getQuat(_PREHASH_Test0, _PREHASH_Test0, outValue);
ensure_equals("Ensure LLQuaternion", inValue, outValue);
delete reader;
}
示例3: defaultTemplate
void LLTemplateMessageBuilderTestObject::test<28>()
// non-zero offset with S16
{
LLMessageTemplate messageTemplate = defaultTemplate();
messageTemplate.addBlock(defaultBlock(MVT_S16, 2));
S16 outValue, inValue = 90;
LLTemplateMessageBuilder* builder = defaultBuilder(messageTemplate);
builder->addS16(_PREHASH_Test0, inValue);
LLTemplateMessageReader* reader = setReader(
messageTemplate, builder, 2);
reader->getS16(_PREHASH_Test0, _PREHASH_Test0, outValue);
ensure_equals("Ensure S16", inValue, outValue);
delete reader;
}
示例4: memset
void LLTemplateMessageBuilderTestObject::test<19>()
// block name !-> binary order
{
U8 buffer1[MAX_BUFFER_SIZE];
memset(buffer1, 0, MAX_BUFFER_SIZE);
U8 buffer2[MAX_BUFFER_SIZE];
memset(buffer2, 0, MAX_BUFFER_SIZE);
U32 bufferSize1, bufferSize2;
// build template: Test0 before Test1
LLMessageTemplate messageTemplate = defaultTemplate();
messageTemplate.addBlock(createBlock(const_cast<char*>(_PREHASH_Test0), MVT_U32, 4, MBT_SINGLE));
messageTemplate.addBlock(createBlock(const_cast<char*>(_PREHASH_Test1), MVT_U32, 4, MBT_SINGLE));
// build message: 1st declared block var == 0xaaaa, 2nd declared block var == 0xbbbb
LLTemplateMessageBuilder* builder = defaultBuilder(messageTemplate, const_cast<char*>(_PREHASH_Test0));
builder->addU32(_PREHASH_Test0, 0xaaaa);
builder->nextBlock(_PREHASH_Test1);
builder->addU32(_PREHASH_Test0, 0xbbbb);
bufferSize1 = builder->buildMessage(buffer1, MAX_BUFFER_SIZE, 0);
delete builder;
// build template: Test1 before Test0
messageTemplate = defaultTemplate();
messageTemplate.addBlock(createBlock(const_cast<char*>(_PREHASH_Test1), MVT_U32, 4, MBT_SINGLE));
messageTemplate.addBlock(createBlock(const_cast<char*>(_PREHASH_Test0), MVT_U32, 4, MBT_SINGLE));
// build message: 1st declared block var == 0xaaaa, 2nd declared block var == 0xbbbb
builder = defaultBuilder(messageTemplate, const_cast<char*>(_PREHASH_Test1));
builder->addU32(_PREHASH_Test0, 0xaaaa);
builder->nextBlock(_PREHASH_Test0);
builder->addU32(_PREHASH_Test0, 0xbbbb);
bufferSize2 = builder->buildMessage(buffer2, MAX_BUFFER_SIZE, 0);
delete builder;
ensure_equals("Ensure Buffer Sizes Equal", bufferSize1, bufferSize2);
ensure_equals("Ensure Buffer Contents Equal", memcmp(buffer1, buffer2, bufferSize1), 0);
}
示例5: if
// static
LLMessageTemplate * LLTemplateParser::parseMessage(LLTemplateTokenizer & tokens)
{
LLMessageTemplate *templatep = NULL;
if(!tokens.want("{"))
{
return NULL;
}
// name first
std::string template_name = tokens.next();
// is name a legit C variable name
if (!b_variable_ok(template_name.c_str()))
{
llerrs << "Not legit variable name: " << template_name << " at " << tokens.line() << llendl;
}
// ok, now get Frequency ("High", "Medium", or "Low")
EMsgFrequency frequency = MFT_LOW;
std::string freq_string = tokens.next();
if (freq_string == "High")
{
frequency = MFT_HIGH;
}
else if (freq_string == "Medium")
{
frequency = MFT_MEDIUM;
}
else if (freq_string == "Low" || freq_string == "Fixed")
{
frequency = MFT_LOW;
}
else
{
llerrs << "Expected frequency, got " << freq_string << " at " << tokens.line() << llendl;
}
// TODO more explicit checking here pls
U32 message_number = strtoul(tokens.next().c_str(),NULL,0);
switch (frequency) {
case MFT_HIGH:
break;
case MFT_MEDIUM:
message_number = (255 << 8) | message_number;
break;
case MFT_LOW:
message_number = (255 << 24) | (255 << 16) | message_number;
break;
default:
llerrs << "Unknown frequency enum: " << frequency << llendl;
}
templatep = new LLMessageTemplate(
template_name.c_str(),
message_number,
frequency);
// Now get trust ("Trusted", "NotTrusted")
std::string trust = tokens.next();
if (trust == "Trusted")
{
templatep->setTrust(MT_TRUST);
}
else if (trust == "NotTrusted")
{
templatep->setTrust(MT_NOTRUST);
}
else
{
llerrs << "Bad trust " << trust << " at " << tokens.line() << llendl;
}
// get encoding
std::string encoding = tokens.next();
if(encoding == "Unencoded")
{
templatep->setEncoding(ME_UNENCODED);
}
else if(encoding == "Zerocoded")
{
templatep->setEncoding(ME_ZEROCODED);
}
else
{
llerrs << "Bad encoding " << encoding << " at " << tokens.line() << llendl;
}
// get deprecation
if(tokens.want("Deprecated"))
{
templatep->setDeprecation(MD_DEPRECATED);
}
else if (tokens.want("UDPDeprecated"))
{
templatep->setDeprecation(MD_UDPDEPRECATED);
}
else if (tokens.want("UDPBlackListed"))
{
//.........这里部分代码省略.........