本文整理汇总了C++中tstring类的典型用法代码示例。如果您正苦于以下问题:C++ tstring类的具体用法?C++ tstring怎么用?C++ tstring使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了tstring类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetFileName
tstring GetFileName(tstring s)
{
tstring::size_type n = s.find(_T('.'));
if(n == tstring::npos)return s;
return s.substr(0,n);
};
示例2: GetInfoString
//
// Query any given "\StringFileInfo\lang-charset\<str>" version info string.
// lang indicates the language translation, may be 0 to signify file default.
// String version. Throws exception on failure. [VH 2005-04-03]
//
tstring TModuleVersionInfo::GetInfoString(const tstring& str, uint lang)
{LPCTSTR v = _T(""); E = GetInfoString(str.c_str (), v, lang); return v;}
示例3: UnserializeParameter
static void UnserializeParameter(const tstring& sHandle, const tstring& sValue, CBaseEntity* pEntity)
{
CSaveData oSaveDataValues;
CSaveData* pSaveData = CBaseEntity::FindSaveDataValuesByHandle(pEntity->GetClassName(), sHandle.c_str(), &oSaveDataValues);
TAssert(pSaveData && pSaveData->m_pszHandle);
if (!pSaveData || !pSaveData->m_pszHandle)
{
TError("Unknown handle '" + sHandle + "'\n");
return;
}
if (!pSaveData->m_pfnUnserializeString)
return;
pSaveData->m_pfnUnserializeString(sValue, pSaveData, pEntity);
}
示例4: GetFileDirectorySizes
/////////////////////////////////////////////////////////////////////
//
// Function:
//
// Description:
//
/////////////////////////////////////////////////////////////////////
BOOL CAMigrateBOINCData::GetFileDirectorySizes( tstring strDirectory, ULONGLONG& ullFileSize, ULONGLONG& ullDirectorySize )
{
WIN32_FIND_DATA ffData;
HANDLE hFind;
tstring csPathMask;
tstring csFullPath;
tstring csNewFullPath;
if ( _T("\\") != strDirectory.substr(strDirectory.length() - 1, 1) )
{
strDirectory += _T("\\");
}
csPathMask = strDirectory + _T("*.*");
hFind = FindFirstFile(csPathMask.c_str(), &ffData);
if (hFind == INVALID_HANDLE_VALUE){
LogMessage(
INSTALLMESSAGE_INFO,
NULL,
NULL,
NULL,
NULL,
_T("CAMigrateBOINCData::GetFileDirectorySizes -- Invalid handle")
);
return FALSE;
}
// Calculating Sizes
while (hFind && FindNextFile(hFind, &ffData))
{
if( !(ffData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
{
csFullPath = strDirectory;
csFullPath += ffData.cFileName;
// Add current file size to the overall directory size
ullDirectorySize += ((ffData.nFileSizeHigh * MAXDWORD) + ffData.nFileSizeLow);
// If this file size is bigger than the one we know about, store it
// for later use.
if (ullFileSize < ((ffData.nFileSizeHigh * MAXDWORD) + ffData.nFileSizeLow)) {
ullFileSize = ((ffData.nFileSizeHigh * MAXDWORD) + ffData.nFileSizeLow);
}
}
else // it is a directory
{
csNewFullPath = strDirectory;
csNewFullPath += ffData.cFileName;
csNewFullPath += _T("\\");
if( (_tcscmp(ffData.cFileName, _T(".")) != 0) &&
(_tcscmp(ffData.cFileName, _T("..")) != 0) )
{
GetFileDirectorySizes(csNewFullPath, ullFileSize, ullDirectorySize);
}
}
}
FindClose(hFind);
return TRUE;
}
示例5: _T
/////////////////////////////////////////////////////////////////////
//
// Function:
//
// Description:
//
/////////////////////////////////////////////////////////////////////
BOOL CAMigrateBOINCData::MoveFiles( tstring strSourceDirectory, tstring strDestinationDirectory, ULONGLONG& ullBytesTransfered )
{
BOOL bRet = TRUE;
WIN32_FIND_DATA ffData;
HANDLE hFind;
tstring csPathMask;
tstring csFullPath;
tstring csNewFullPath;
tstring strMessage;
strMessage = _T("CAMigrateBOINCData::MoveFiles -- Directory: '");
strMessage += strSourceDirectory;
strMessage += _T("'");
LogMessage(
INSTALLMESSAGE_INFO,
NULL,
NULL,
NULL,
NULL,
strMessage.c_str()
);
// Create the destination cirectory if needed.
//
CreateDirectory(strDestinationDirectory.c_str(), NULL);
if ( _T("\\") != strSourceDirectory.substr(strSourceDirectory.length() - 1, 1) )
{
strSourceDirectory += _T("\\");
}
if ( _T("\\") != strDestinationDirectory.substr(strDestinationDirectory.length() - 1, 1) )
{
strDestinationDirectory += _T("\\");
}
csPathMask = strSourceDirectory + _T("*.*");
hFind = FindFirstFile(csPathMask.c_str(), &ffData);
if (hFind == INVALID_HANDLE_VALUE){
LogMessage(
INSTALLMESSAGE_INFO,
NULL,
NULL,
NULL,
NULL,
_T("CAMigrateBOINCData::MoveFiles -- Invalid handle")
);
return FALSE;
}
// Copying all the files
while (hFind && FindNextFile(hFind, &ffData))
{
csFullPath = strSourceDirectory + ffData.cFileName;
csNewFullPath = strDestinationDirectory + ffData.cFileName;
RemoveReadOnly(csFullPath);
RemoveReadOnly(csNewFullPath);
if( !(ffData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
{
strMessage = _T("CAMigrateBOINCData::MoveFiles -- Copy File: '");
strMessage += csFullPath.c_str();
strMessage += _T("' to '");
strMessage += csNewFullPath.c_str();
strMessage += _T("'");
LogMessage(
INSTALLMESSAGE_INFO,
NULL,
NULL,
NULL,
NULL,
strMessage.c_str()
);
if( !CopyFile(csFullPath.c_str(), csNewFullPath.c_str(), FALSE) )
{
LogMessage(
INSTALLMESSAGE_INFO,
NULL,
NULL,
NULL,
GetLastError(),
_T("CAMigrateBOINCData::MoveFiles -- Failed to copy original file")
);
bRet = FALSE;
}
else
{
ullBytesTransfered += ((ffData.nFileSizeHigh * MAXDWORD) + ffData.nFileSizeLow);
//.........这里部分代码省略.........
示例6: setItemText
void ErrorDialog::setItemText(int id, tstring text)
{
SetWindowText(GetDlgItem(handle, id), text.c_str());
}
示例7: SetQueryString
bool VaultSearchQuery::SetQueryString( const tstring& queryString, tstring& errors )
{
// Set the QueryString
m_QueryString = queryString;
m_SQLQueryString.clear();
if ( !ParseQueryString( m_QueryString, errors, this ) )
{
Log::Warning( TXT( "Errors occurred while parsing the query string: %s\n %s\n" ), m_QueryString.c_str(), errors.c_str() );
return false;
}
return true;
}
示例8: Init
//
/// String-aware overload
//
TProfile::TProfile(const tstring& section, const tstring& filename)
{
Init(
section.empty() ? 0 : section.c_str(),
filename.empty() ? 0 : filename.c_str());
}
示例9: CreateWaitableTimer
//
// String-aware overload
//
TWaitableTimer::TWaitableTimer(bool manualReset, const tstring& name, LPSECURITY_ATTRIBUTES sa)
{
Handle = CreateWaitableTimer(sa, manualReset, name.c_str());
if (!Handle) throw TXOwl(_T("CreateWaitableTimer failed."));
}
示例10: _T
/////////////////////////////////////////////////////////////////////
//
// Function:
//
// Description:
//
/////////////////////////////////////////////////////////////////////
tstring CACreateProjectInitFile::ParseParameter(tstring& strSetupExeName, tstring& strParameter)
{
tstring strParameterName;
tstring strEncodedValue;
tstring strParameterValue;
tstring strError;
size_t iParameterStart = 0;
size_t iParameterEnd = 0;
strParameterName = strParameter + _T("_");
strError = _T("Searching for parameter '");
strError += strParameterName;
strError += _T("'");
LogMessage(
INSTALLMESSAGE_INFO,
NULL,
NULL,
NULL,
NULL,
strError.c_str()
);
iParameterStart = strSetupExeName.rfind(strParameterName);
if (iParameterStart != tstring::npos) {
iParameterStart += strParameterName.size();
iParameterEnd = strSetupExeName.find(_T("_"), iParameterStart);
if (iParameterEnd == tstring::npos) {
iParameterEnd = strSetupExeName.find(_T("."), iParameterStart);
if (iParameterEnd == tstring::npos) {
return tstring(_T(""));
}
}
strEncodedValue = strSetupExeName.substr(iParameterStart, iParameterEnd - iParameterStart);
strError = _T("Found encoded value '");
strError += strEncodedValue;
strError += _T("'");
LogMessage(
INSTALLMESSAGE_INFO,
NULL,
NULL,
NULL,
NULL,
strError.c_str()
);
// WCG didn't want to have to encode their setup cookie value. So all parameters but the setup cookie
// are base64 encoded.
//
if (strParameterName == _T("asc_")) {
strParameterValue = strEncodedValue;
} else {
CW2A pszASCIIEncodedValue( strEncodedValue.c_str() );
CA2W pszUnicodeDecodedValue( r_base64_decode(pszASCIIEncodedValue, strlen(pszASCIIEncodedValue)).c_str() );
strError = _T("Decoded value '");
strError += pszUnicodeDecodedValue;
strError += _T("'");
LogMessage(
INSTALLMESSAGE_INFO,
NULL,
NULL,
NULL,
NULL,
strError.c_str()
);
strParameterValue = pszUnicodeDecodedValue;
}
}
strError = _T("Returning value '");
strError += strParameterValue;
strError += _T("'");
LogMessage(
INSTALLMESSAGE_INFO,
NULL,
NULL,
NULL,
NULL,
strError.c_str()
);
return strParameterValue;
//.........这里部分代码省略.........
示例11: TriToken
tstring TriToken(tstring& Token){
tstring::size_type begin = Token.find_first_not_of(_T(' '));
if(begin == string::npos)return Token;
tstring::size_type end = Token.find_last_not_of(_T(' '));
return Token.substr(begin,end-begin+1);
}
示例12: set_srcdir
void set_srcdir(tstring const& x)
{
srcdir.assign(x.data(), x.size());
}
示例13: set_test_resources_dir
void set_test_resources_dir(tstring const& x)
{
top_srcdir.assign(x.data(), x.size());
}
示例14: switch
void Logger::Log(LogLevel level, const tstring& pMessage, const tstring& tag)
{
#if LOGGER_MIN_LEVEL > 0
tstring levelName;
switch(level)
{
case LogLevel::Info :
levelName = _T("INFO");
break;
case LogLevel::Warning:
levelName = _T("WARNING");
break;
case LogLevel::Error:
levelName = _T("ERROR");
break;
case LogLevel::Debug:
levelName = _T("DEBUG");
break;
}
#ifdef DESKTOP
tstringstream messageBuffer;
messageBuffer << _T("[") << tag << _T("] ") << _T("[") << levelName << _T("] ") << pMessage << std::endl;
tstring combinedMessage = messageBuffer.str();
if(m_UseConsole)
{
switch(level)
{
case LogLevel::Info :
#if LOGGER_MIN_LEVEL < 2
SetConsoleTextAttribute(m_ConsoleHandle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
#endif
break;
case LogLevel::Warning :
#if LOGGER_MIN_LEVEL < 3
SetConsoleTextAttribute(m_ConsoleHandle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
#endif
break;
case LogLevel::Error :
#if LOGGER_MIN_LEVEL < 4
SetConsoleTextAttribute(m_ConsoleHandle, FOREGROUND_INTENSITY | FOREGROUND_RED);
#endif
break;
case LogLevel::Debug :
#if LOGGER_MIN_LEVEL < 5
#ifdef DEBUG
SetConsoleTextAttribute(m_ConsoleHandle, FOREGROUND_INTENSITY | FOREGROUND_GREEN);
#endif
#endif
break;
}
tprintf(combinedMessage.c_str());
}
else
{
OutputDebugString(combinedMessage.c_str());
}
#ifndef NO_LOG_FILE
LogMessage(combinedMessage);
#endif
#else
switch(level)
{
case LogLevel::Info:
#if LOGGER_MIN_LEVEL < 2
__android_log_print(ANDROID_LOG_INFO, tag.c_str(), "%s", pMessage.c_str());
#endif
break;
case LogLevel::Warning:
#if LOGGER_MIN_LEVEL < 3
__android_log_print(ANDROID_LOG_WARN, tag.c_str(), "%s", pMessage.c_str());
#endif
break;
case LogLevel::Error:
#if LOGGER_MIN_LEVEL < 4
__android_log_print(ANDROID_LOG_ERROR, tag.c_str(), "%s", pMessage.c_str());
#endif
break;
case LogLevel::Debug:
#if LOGGER_MIN_LEVEL < 5
#ifdef DEBUG
__android_log_print(ANDROID_LOG_DEBUG, tag.c_str(), pMessage.c_str());
#endif
#endif
break;
}
#ifndef NO_LOG_FILE
tstringstream messageBuffer;
messageBuffer << _T("[") << tag << _T("] ") << _T("[") << levelName << _T("] ") << pMessage << std::endl;
LogMessage(messageBuffer.str());
#endif
#endif
#endif
}
示例15: OpenWaitableTimer
//
// String-aware overload
//
TWaitableTimer::TWaitableTimer(const tstring& name, bool inherit, uint32 access)
{
Handle = OpenWaitableTimer(access, inherit, name.c_str());
if (!Handle) throw TXOwl(_T("OpenWaitableTimer failed."));
}