当前位置: 首页>>代码示例>>C++>>正文


C++ BString::getType方法代码示例

本文整理汇总了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;
    }
}
开发者ID:ANHcRush,项目名称:mmoserver,代码行数:35,代码来源:MessageFactory.cpp

示例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);
}
开发者ID:schizix,项目名称:mmoserver,代码行数:75,代码来源:ChatMessages.cpp


注:本文中的BString::getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。