本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}