本文整理汇总了C++中BString::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ BString::getType方法的具体用法?C++ BString::getType怎么用?C++ BString::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BString
的用法示例。
在下文中一共展示了BString::getType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addString
void MessageFactory::addString(const BString& data)
{
// Make sure we've called StartMessage()
assert(mCurrentMessage && "Must call StartMessage before adding data");
// Adjust start bounds if necessary.
_adjustHeapStartBounds(data.getDataLength());
// Insert our data and move our end pointer.
switch(data.getType())
{
case BSTRType_UTF8:
case BSTRType_ANSI:
{
// First insert the string length
*((uint16*)mCurrentMessageEnd) = data.getLength();
mCurrentMessageEnd += 2;
memcpy(mCurrentMessageEnd, data.getAnsi(), data.getLength());
mCurrentMessageEnd += data.getLength();
}
break;
case BSTRType_Unicode16:
{
// First insert the string length
*((uint32*)mCurrentMessageEnd) = data.getLength();
mCurrentMessageEnd += 4;
memcpy(mCurrentMessageEnd, data.getUnicode16(), data.getLength() * 2);
mCurrentMessageEnd += data.getLength() * 2;
}
break;
}
}
示例2: sendSystemMessageProper
void ChatMessageLib::sendSystemMessageProper(Player* playerObject,uint8 system, BString customMessage,BString mainFile,BString mainVar,BString toFile,BString toVar,BString toCustom,int32 di,BString ttFile,BString ttVar,BString ttCustom,uint64 ttId,uint64 toId,uint64 tuId,BString tuFile,BString tuVar,BString tuCustom) const
{
gMessageFactory->StartMessage();
gMessageFactory->addUint32(opChatSystemMessage);
if(system)
system = 2;
gMessageFactory->addUint8(system);
if(customMessage.getType() != BSTRType_Unicode16)
customMessage.convert(BSTRType_Unicode16);
if(toCustom.getType() != BSTRType_Unicode16)
toCustom.convert(BSTRType_Unicode16);
if(tuCustom.getType() != BSTRType_Unicode16)
tuCustom.convert(BSTRType_Unicode16);
if(ttCustom.getType() != BSTRType_Unicode16)
ttCustom.convert(BSTRType_Unicode16);
// simple message
if(customMessage.getLength())
{
gMessageFactory->addString(customMessage.getUnicode16());
gMessageFactory->addUint32(0);
}
// templated message
else
{
gMessageFactory->addUint32(0);
uint32 realSize = mainFile.getLength() + mainVar.getLength() + toFile.getLength() + toVar.getLength() + ttFile.getLength() + ttVar.getLength()+ tuFile.getLength() + tuVar.getLength();
gMessageFactory->addUint32(42 + ((uint32)ceil(((double)realSize) / 2.0)) + toCustom.getLength() + ttCustom.getLength()+ tuCustom.getLength());
if(realSize % 2)
gMessageFactory->addUint16(1);
else
gMessageFactory->addUint16(0);
gMessageFactory->addUint8(1);
gMessageFactory->addUint32(0xFFFFFFFF);
gMessageFactory->addString(mainFile);
gMessageFactory->addUint32(0);
gMessageFactory->addString(mainVar);
gMessageFactory->addUint64(tuId);
gMessageFactory->addString(tuFile);
gMessageFactory->addUint32(0);
gMessageFactory->addString(tuVar);
gMessageFactory->addString(tuCustom.getUnicode16());
gMessageFactory->addUint64(ttId);
gMessageFactory->addString(ttFile);
gMessageFactory->addUint32(0);
gMessageFactory->addString(ttVar);
gMessageFactory->addString(ttCustom.getUnicode16());
gMessageFactory->addUint64(toId);
gMessageFactory->addString(toFile);
gMessageFactory->addUint32(0);
gMessageFactory->addString(toVar);
gMessageFactory->addString(toCustom.getUnicode16());
gMessageFactory->addInt32(di);
gMessageFactory->addUint32(0);
gMessageFactory->addUint8(0);
if(realSize % 2)
gMessageFactory->addUint8(0);
}
(playerObject->getClient())->SendChannelA(gMessageFactory->EndMessage(), playerObject->getClient()->getAccountId(), CR_Client, 5);
}