本文整理汇总了C++中tstring::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ tstring::clear方法的具体用法?C++ tstring::clear怎么用?C++ tstring::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tstring
的用法示例。
在下文中一共展示了tstring::clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetTransportLayer
SPLogTransportLayer CLogTransportFactory::GetTransportLayer(const tstring& name, CNetworkLog& netLog, tstring& errorString)
{
HRESULT hResult = S_OK;
try
{
errorString.clear();
IComUDPListenerPtr comUDPListener;
hResult = comUDPListener.CreateInstance(__uuidof(CComUDPListener), 0, CLSCTX_LOCAL_SERVER);
if ( S_OK == hResult )
{
comUDPListener->AddWatch(GetCurrentProcessId());
return SPLogTransportLayer(new CLocalNetworkComLogTransport(comUDPListener, name, netLog));
}
else
{
return SPLogTransportLayer(new CLocalNetworkLogTransport(name, netLog));
}
}
catch(CExceptionBase &e)
{
errorString = Format(_T("\nComError:\n%d\nSockError:\n%s"),hResult, e.m_strWhat.c_str());
return SPLogTransportLayer();
}
catch(...)
{
errorString = Format(_T("\nComError:\n%d\nSockError:\n%s"),hResult, _T("Unkwnown exception"));
return SPLogTransportLayer();
}
}
示例2: GetExtension
void PathX::GetExtension(const tstring& path, tstring& outExtension)
{
tstring::size_type pos = path.find_last_of(extension);
if (pos == tstring::size_type(-1))
{
outExtension.clear();
return;
}
else if(pos == tstring::size_type(path.length()-1))
{
outExtension.clear();
return;
}
else
{
outExtension = path.substr(pos+1, path.length());
return;
}
}
示例3: onEndTestCase
void onEndTestCase()
{
ASSERT(!s_currentTestCase.empty());
if (s_teardown != nullptr)
{
try
{
s_teardown();
}
catch(const Core::Exception& e)
{
processSetupTeardownException(TXT("TearDown"), e.twhat());
}
catch (...)
{
processSetupTeardownException(TXT("TearDown"), TXT("UNKNOWN"));
}
}
s_executed.push_back(s_currentTestCase);
// Update statistics.
if (s_currentResult == SUCCEEDED)
{
++s_numPassed;
if (!s_verbose)
tcout << TXT(".");
}
else if (s_currentResult == FAILED)
{
++s_numFailed;
s_failures.push_back(s_currentTestCase);
s_failuresAsserts.push_back(s_currentTestCaseAsserts);
if (!s_verbose)
tcout << TXT("F");
}
else
{
ASSERT_FALSE();
ASSERT(s_currentResult == UNKNOWN);
++s_numUnknown;
if (!s_verbose)
tcout << TXT("?");
}
s_currentResult = UNKNOWN;
s_currentTestCase.clear();
s_currentTestCaseAsserts.clear();
}
示例4: TEXT
const tstring& CDBTableInfoRecord::GetField(unsigned int idx) const
{
static tstring str;
if(!TblPtr)
{
_ASSERT(false);
str.clear();
return str;
}
switch (idx)
{
case Name:
return TblPtr->GetName();
break;
case DBName:
return TblPtr->GetDBName();
break;
case Buildin:
str = TblPtr->GetSchema().IsBuildin() ? TEXT("1") : TEXT("0");
return str;
break;
case DBExist:
str = TblPtr->GetSchema().IsDBExist() ? TEXT("1") : TEXT("0");
return str;
break;
case State:
str = IsStateNormal() ? TEXT("") : TEXT("!");
break;
default:
_ASSERT(false);
str.clear();
return str;
break;
}
return str;
}
示例5: ReadStringData
bool Control::ReadStringData(tstring& str) const
{
StringDataBinding* data = CastDataBinding<StringDataBinding, DataBindingTypes::String>( m_DataBinding );
if (data)
{
str.clear();
data->Get( str );
return true;
}
HELIUM_BREAK(); // you should not call this, your control is using custom data
return false;
}
示例6: GetDirectory
void PathX::GetDirectory(const tstring& path, tstring& outDirectory)
{
tstring::size_type pos = path.find_last_of(separator);
if (pos == tstring::size_type(-1))
{
outDirectory.clear();
return;
}
else
{
outDirectory = path.substr(0, pos);
return;
}
}
示例7: set_text
void set_text(const TCHAR *_text) {
assert_none_locked();
assert_thread();
#ifndef USE_GDI
if (_text != NULL)
text = _text;
else
text.clear();
invalidate();
#else /* USE_GDI */
::SetWindowText(hWnd, _text);
#endif /* USE_GDI */
}
示例8: set_text
void set_text(const TCHAR *_text) {
AssertNoneLocked();
AssertThread();
#ifndef USE_GDI
if (_text != nullptr)
text = _text;
else
text.clear();
Invalidate();
#else /* USE_GDI */
::SetWindowText(hWnd, _text);
#endif /* USE_GDI */
}
示例9: tstring
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// распарсить путь в котором указана переменная среды
// возможные варианты: "VarName", "%VarName", "%VarName%", "%VarName%LocalPath", "VarName%"
// возвращает true, если название VarName задано не точно (варианты 1, 2)
bool nf::Parser::ParseEnvVarPath(tstring const& Src
, tstring& VarName
, tstring& LocalPath)
{
LocalPath.clear();
tsmatch what;
if (! boost::regex_search(Src, what, tregex(re::RE_EV)))
{
VarName = Src;
return false;
}
VarName = what[1];
LocalPath = what[3];
return ! tstring(what[2]).empty();
}
示例10: prettify
void CmdDlg::prettify(tstring &text)
{
try {
const tstring search(_T("\n")), replace(_T("\r\n"));
// http://stackoverflow.com/a/14678800/98528
tstring::size_type pos = 0;
while ((pos = text.find(search, pos)) != tstring::npos) {
text.replace(pos, search.length(), replace);
pos += replace.length();
}
text += replace;
} catch (...) {
text.clear();
}
}
示例11: GetFileName
void PathX::GetFileName(const tstring& path, tstring& outFileName)
{
tstring::size_type pos = path.find_last_of(separator);
if (pos == tstring::size_type(-1))
{
outFileName = path;
return;
}
else if(pos == tstring::size_type(path.length()-1))
{
outFileName.clear();
return;
}
else
{
outFileName = path.substr(pos+1, path.length());
return;
}
}
示例12: onEndTestSet
void onEndTestSet()
{
ASSERT(s_currentTestCase.empty());
ASSERT(s_currentTestCaseAsserts.empty());
if (!s_quiet && !s_verbose)
{
tcout << std::endl;
}
if (!s_failures.empty())
{
const tstring failureCount = (s_quiet) ? Core::fmt(TXT(" %s: %u failure(s)"), s_currentTestSet.c_str(), s_failures.size())
: Core::fmt(TXT(" %u failure(s)"), s_failures.size());
tcout << std::endl;
tcout << failureCount << std::endl;
for (size_t i = 0; i != s_failures.size(); ++i)
{
debugWrite(TXT(" > %s\n"), s_failures[i].c_str());
tcout << TXT(" > ") << s_failures[i] << std::endl;
for (size_t j = 0; j != s_failuresAsserts[i].size(); ++j)
{
debugWrite(TXT(" %s\n"), s_failuresAsserts[i][j].c_str());
tcout << TXT(" ") << s_failuresAsserts[i][j] << std::endl;
}
}
}
if (!s_quiet)
{
tcout << std::endl;
}
s_currentTestSet.clear();
s_failures.clear();
s_failuresAsserts.clear();
s_executed.clear();
s_setup = nullptr;
s_teardown = nullptr;
}
示例13: GetLocalAddr
BOOL CSocketObj::GetLocalAddr(tstring &Address, WORD &Port)
{
SOCKADDR_STORAGE name;
int namelen;
char addrbuf[NI_MAXHOST];
char portbuf[NI_MAXSERV];
Address.clear();
Port = 0;
namelen = sizeof(name);
if (getsockname(mSock, (PSOCKADDR)&name, &namelen) == 0) {
if (getnameinfo((PSOCKADDR)&name, namelen, addrbuf, NI_MAXHOST, portbuf, NI_MAXSERV, NI_NUMERICHOST || NI_NUMERICSERV) == 0) {
Address = string_to_tstring(string(addrbuf));
Port = stoi(portbuf);
}
return TRUE;
}
return FALSE;
}
示例14: GetFileNameNoExtension
void PathX::GetFileNameNoExtension(const tstring& path, tstring& outFileName)
{
tstring fileName;
GetFileName(path, fileName);
tstring::size_type pos = fileName.find_last_of(extension);
if (pos == tstring::size_type(-1))
{
outFileName = path;
return;
}
else if(pos == tstring::size_type(0))
{
outFileName.clear();
return;
}
else
{
outFileName = fileName.substr(0, pos);
return;
}
}
示例15: GetAddressSymbol
/// Get the symbol for the specified address.
///
/// @param[out] rSymbol Address symbol.
/// @param[in] pAddress Address to translate.
///
/// @return True if the address was successfully resolved, false if not.
void Helium::GetAddressSymbol( tstring& rSymbol, void* pAddress )
{
HELIUM_ASSERT( pAddress );
MutexScopeLock scopeLock( GetStackWalkMutex() );
ConditionalSymInitialize();
// rSymbol.Remove( 0, rSymbol.GetSize() );
rSymbol.clear();
HANDLE hProcess = GetCurrentProcess();
HELIUM_ASSERT( hProcess );
bool bAddedModuleName = false;
DWORD64 moduleBase = SymGetModuleBase64( hProcess, reinterpret_cast< uintptr_t >( pAddress ) );
if( moduleBase )
{
IMAGEHLP_MODULE64 moduleInfo;
MemoryZero( &moduleInfo, sizeof( moduleInfo ) );
moduleInfo.SizeOfStruct = sizeof( moduleInfo );
if( SymGetModuleInfo64( hProcess, moduleBase, &moduleInfo ) )
{
rSymbol += TXT( "(" );
rSymbol += moduleInfo.ModuleName;
rSymbol += TXT( ") " );
bAddedModuleName = true;
}
}
if( !bAddedModuleName )
{
rSymbol += TXT( "(???) " );
}
uint64_t symbolInfoBuffer[
( sizeof( SYMBOL_INFO ) + sizeof( tchar_t ) * ( MAX_SYM_NAME - 1 ) + sizeof( uint64_t ) - 1 ) /
sizeof( uint64_t ) ];
MemoryZero( symbolInfoBuffer, sizeof( symbolInfoBuffer ) );
SYMBOL_INFO& rSymbolInfo = *reinterpret_cast< SYMBOL_INFO* >( &symbolInfoBuffer[ 0 ] );
rSymbolInfo.SizeOfStruct = sizeof( SYMBOL_INFO );
rSymbolInfo.MaxNameLen = MAX_SYM_NAME;
if( SymFromAddr( hProcess, reinterpret_cast< uintptr_t >( pAddress ), NULL, &rSymbolInfo ) )
{
rSymbolInfo.Name[ MAX_SYM_NAME - 1 ] = TXT( '\0' );
rSymbol += rSymbolInfo.Name;
rSymbol += TXT( " " );
}
else
{
rSymbol += TXT( "??? " );
}
DWORD displacement = 0;
IMAGEHLP_LINE64 lineInfo;
MemoryZero( &lineInfo, sizeof( lineInfo ) );
lineInfo.SizeOfStruct = sizeof( lineInfo );
if( SymGetLineFromAddr64( hProcess, reinterpret_cast< uintptr_t >( pAddress ), &displacement, &lineInfo ) )
{
tchar_t lineNumberBuffer[ 32 ];
StringFormat( lineNumberBuffer, HELIUM_ARRAY_COUNT( lineNumberBuffer ), TXT( "%u" ), lineInfo.LineNumber );
lineNumberBuffer[ HELIUM_ARRAY_COUNT( lineNumberBuffer ) - 1 ] = TXT( '\0' );
rSymbol += TXT( "(" );
rSymbol += lineInfo.FileName;
rSymbol += TXT( ", line " );
rSymbol += lineNumberBuffer;
rSymbol += TXT( ")" );
}
else
{
rSymbol += TXT( "(???, line ?)" );
}
}