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


C++ TSTRING::resize方法代码示例

本文整理汇总了C++中TSTRING::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ TSTRING::resize方法的具体用法?C++ TSTRING::resize怎么用?C++ TSTRING::resize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TSTRING的用法示例。


在下文中一共展示了TSTRING::resize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: util_RemoveLastPathElement

//////////////////////////////////////////////////////////////////////////////////
// Function name    : util_RemoveLastPathElement
// Description      :
//      effectively pops off a path element from the end, except for the root dir, where it does nothing
//      it removes any slashes before and after the element
//      ///root//foo/    -> leaves "///root" ("foo"  is strElem)
//      ///root          -> leaves ""        ("root" is strElem)
//      //               -> leaves ""        (""     is strElem)
//
// Return type      : void
// Argument         :  TSTRING& strPath
// Argument         : TSTRING& strElem
/////////////////////////////////////////////////////////////////////////////////
void util_RemoveLastPathElement(TSTRING& strPath, TSTRING& strElem)
{

    // remove all trailing separators
    util_RemoveTrailingSeps(strPath);

    // find the last separator
    TSTRING::size_type lastSep = strPath.rfind(TW_SLASH);

    // if separator was found, take all chars after it
    if (lastSep != TSTRING::npos)
    {
        strElem = strPath.substr(lastSep + 1);
        strPath.resize(lastSep + 1);
    }
    else // no seps in name, take whole string
    {
        // last element
        strElem = strPath;
        strPath.erase();
    }

    // remove all trailing separators
    util_RemoveTrailingSeps(strPath);
}
开发者ID:Tripwire,项目名称:tripwire-open-source,代码行数:38,代码来源:unixfsservices.cpp

示例2: AsString

TSTRING cChecksumSignature::AsString() const
{
    TSTRING ret;
    char *ps_signature;
    char buf[100];
    uint32 local[2];
    local[0] = (uint32)(mChecksum >> 32); // note we put the MSB first
    local[1] = (uint32)(mChecksum);

    ps_signature = pltob64(local, buf, 2);
        //ps_signature holds base64 representation of mCRC
#ifdef _UNICODE
    ret.resize(strlen(ps_signature));
    mbstowcs((TCHAR*)ret.data(), ps_signature, strlen(ps_signature));
#else
    ret.append(ps_signature);
#endif
    return ret;
}
开发者ID:faical-yannick-congo,项目名称:tripwire-open-source,代码行数:19,代码来源:signature.cpp

示例3: util_TrailingSep

/////////////////////////////////////////////////////////////////////////
// Function name    : util_TrailingSep
// Description      : ensure that a path ( fLeaveSep ? "has" : "does not have" ) a trailing slash
//
// Return type      : bool : was there a trailing slash?
// Argument         : TSTRING& str
// Argument         : bool fLeaveSep
/////////////////////////////////////////////////////////////////////////////////
bool util_TrailingSep(TSTRING& str, bool fLeaveSep)
{
    bool fWasSep = false;

    // if there's a trailing sep
    if (!str.empty() && str[str.size() - 1] == TW_SLASH)
    {
        if (!fLeaveSep)
            str.resize(str.size() - 1);
        fWasSep = true;
    }
    else // else no trailing sep
    {
        if (fLeaveSep)
            str += TW_SLASH;
        fWasSep = false;
    }

    return (fWasSep);
}
开发者ID:Tripwire,项目名称:tripwire-open-source,代码行数:28,代码来源:unixfsservices.cpp

示例4: AsStringHex

///////////////////////////////////////////////////////////////////////////////
// AsString -- Returns a TSTRING that holds the base64 representation of 
//  mCRC
TSTRING cCRC32Signature::AsString() const
{
    if (cArchiveSigGen::Hex())
        return AsStringHex();
    
    TSTRING ret;
    char *ps_signature;
    char buf[100];
    uint32 local = mCRCInfo.crc;

    ps_signature = pltob64(&local, buf, 1);
    //ps_signature holds base64 representation of mCRCInfo.crc
#ifdef _UNICODE
    ret.resize(strlen(ps_signature));
    mbstowcs((TCHAR*)ret.data(), ps_signature, strlen(ps_signature));
#else
    ret.append(ps_signature);
#endif
    return ret;
}
开发者ID:faical-yannick-congo,项目名称:tripwire-open-source,代码行数:23,代码来源:signature.cpp

示例5: main

int main(int argc, char* argv[])
{
    // Get application path
    g_ApplicationExePath.append(argv[0]);

    // Calculate INI file path
    g_ApplicationIniPath = g_ApplicationExePath;
    g_ApplicationIniPath.resize(g_ApplicationIniPath.find_last_of(_T('.')));
    g_ApplicationIniPath.append(_T(".ini"));

    if (! InitInstance())
        return 255;

    Emulator_Start();

    // The main loop
    Uint32 ticksLast;
    Uint32 ticksLastFps = SDL_GetTicks();
    int frames = 0;
    while (!g_okQuit)
    {
        ticksLast = SDL_GetTicks();  // Time at frame start
        SDL_Event evt;
        while (SDL_PollEvent(&evt))
        {
            if (evt.type == SDL_QUIT)
            {
                g_okQuit = TRUE;
                break;
            }
            else
            {
                if (evt.type == SDL_KEYDOWN || evt.type == SDL_KEYUP ||
                        evt.type == SDL_JOYBUTTONDOWN || evt.type == SDL_JOYBUTTONUP)
                {
                    Main_OnKeyJoyEvent(evt);
                }
            }
        }

        if (g_okEmulatorRunning)
        {
            Emulator_SystemFrame();

            Main_DrawScreen();

            frames++;
        }

        // Delay
        Uint32 ticksNew = SDL_GetTicks();
        Uint32 ticksElapsed = ticksNew - ticksLast;
        g_LastDelay = 0;
        if (ticksElapsed < FRAME_TICKS)
        {
            g_LastDelay = FRAME_TICKS - ticksElapsed;
            SDL_Delay(FRAME_TICKS - ticksElapsed);
        }
        ticksLast = ticksNew;

        if (ticksLast - ticksLastFps > 1000)  //DEBUG: FPS calculation
        {
            g_LastFps = frames;
            frames = 0;
            ticksLastFps += 1000;
        }
    }

    Emulator_Stop();

    DoneInstance();

    return 0;
}
开发者ID:fixelsan,项目名称:ukncbtl,代码行数:74,代码来源:UKNCBTL.cpp


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