本文整理汇总了C++中TSTRING类的典型用法代码示例。如果您正苦于以下问题:C++ TSTRING类的具体用法?C++ TSTRING怎么用?C++ TSTRING使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TSTRING类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: _GetNumberFormat
bool OverwriteDlg::_SetStaticText(Window &Wnd, CTSTRING &tsFileName) {
bool r = false;
FILESIZE fs;
if (FileGetSize(tsFileName, fs)) {
FILETIMES ft;
if (FileGetTime(tsFileName, ft)) {
/*
* Set the text of the static control as follows:
*
* [size in bytes] [formatted size]
* [created date]
* [modified date]
*/
TSTRING tsTemp;
TSTRING tsFormatBytes = _GetNumberFormat(fs.ui64Bytes);
sprintf(tsTemp, _T("%s Bytes (%s)\nCreated: %s\nModified: %s"),
tsFormatBytes.c_str(), fs.tsStrFmt.c_str(),
ft.tsLongCreated.c_str(), ft.tsLongModified.c_str());
Wnd.SetWindowText(tsTemp);
r = true;
}
}
return r;
}
开发者ID:ryanlederman,项目名称:extfilecopy,代码行数:34,代码来源:OverwriteDlg.cpp
示例2: Replace
TSTRING Replace( const TSTRING& orignStr, const TSTRING& oldStr, const vector<TSTRING>&vc )
{
size_t pos = 0;
TSTRING tempStr = orignStr;
TSTRING::size_type newStrLen;
TSTRING::size_type oldStrLen = oldStr.length();
int i=0;
while(true)
{
pos = tempStr.find(oldStr, pos);
if (pos == TSTRING::npos) break;
TSTRING s=vc.at(i);
s = _T("\'")+s +_T("\'");
newStrLen= s.length();
tempStr.replace(pos, oldStrLen, s);
pos += newStrLen;
i++;
}
return tempStr;
}
开发者ID:AsamQi,项目名称:node-sqlite3,代码行数:25,代码来源:NodeFunction.cpp
示例3: MakeFile
void MakeFile( TSTRING& strNameMakeMe )
{
try
{
iFSServices* pFSServices = iFSServices::GetInstance(); ASSERT( pFSServices );
pFSServices->MakeTempFilename( strNameMakeMe );
std::string strA;
for( TSTRING::iterator i = strNameMakeMe.begin(); i != strNameMakeMe.end(); i++ )
{
char ach[6];
ASSERT( MB_CUR_MAX <= 6 );
int n = wctomb( ach, *i );
ASSERT( n != -1 );
for( int j = 0; j < n; j++ )
strA += ach[j];
}
TOFSTREAM file( strA.c_str() );
ASSERT( file );
file.close();
}
catch( eFSServices e )
{
ASSERT( false );
}
catch( ... )
{
ASSERT( false );
}
}
开发者ID:brc0x1,项目名称:tripwire-open-source,代码行数:33,代码来源:textreportviewer_t.cpp
示例4: FullPath
bool cUnixFSServices::GetExecutableFilename(TSTRING& strFullPath, const TSTRING& strFilename) const
{
bool fGotName = false;
if (strFilename.empty())
return false;
// if there is a slash in the filename, it's absolute or relative to cwd
if (TSTRING::npos != strFilename.find(_T('/')))
{
// if absolute path
if (strFilename[0] == _T('/'))
{
strFullPath = strFilename;
fGotName = true;
}
else // is relative path; find path from cwd
{
fGotName = FullPath(strFullPath, strFilename);
}
}
else // it's just a filename: should be found in path
{
fGotName = util_PathFind(strFullPath, strFilename);
TSTRING strFP;
if (fGotName && FullPath(strFP, strFullPath))
strFullPath = strFP;
}
return (fGotName);
}
开发者ID:Tripwire,项目名称:tripwire-open-source,代码行数:32,代码来源:unixfsservices.cpp
示例5: if
Handle<Value> Statement::GetFieldValueByIndex(const Arguments& args)
{
Statement* pStatement = ObjectWrap::Unwrap<Statement>(args.This());
HandleScope scope;
int index = args[0]->Int32Value();
Sqlite3_XX::VARIANT var = pStatement->pRecord->GetFieldValue(index);
if (var.vt == Sqlite3_XX::VT_BSTR)
{
TSTRING value = var.bstrVal;
#ifdef OS_WIN32
return scope.Close(String::New(encodeConv::CodingConv::Unicode2Utf8(value.c_str()).c_str()));
#elif defined OS_LINUX
return scope.Close(String::New(value.c_str()));
#endif
}
else if (var.vt == Sqlite3_XX::VT_I4)
{
return scope.Close(Integer::New(var.intVal));
}
else if (var.vt == Sqlite3_XX::VT_R8)
{
return scope.Close(Number::New(var.dblVal));
}
return Undefined();
}
开发者ID:Rudeman,项目名称:achat,代码行数:28,代码来源:Statement.cpp
示例6: AllTestsRunOnEncodedString
bool cEncoder::AllTestsRunOnEncodedString( const TSTRING& s ) const
{
TSTRING::const_iterator cur = s.begin(); // pointer to working position in s
const TSTRING::const_iterator end = s.end(); // end of s
TSTRING::const_iterator first = end; // identifies beginning of current character
TSTRING::const_iterator last = end; // identifies end of current character
// while get next char (updates cur)
while( cCharUtil::PopNextChar( cur, end, first, last ) )
{
sack_type::const_iterator atE;
for( atE = m_encodings.begin();
atE != m_encodings.end();
atE++ )
{
if( (*atE)->NeedsEncoding( first, last ) )
{
return false;
}
}
}
return true;
}
开发者ID:faical-yannick-congo,项目名称:tripwire-open-source,代码行数:25,代码来源:displayencoder.cpp
示例7: TSTRING
/// <summary>
/// <para name='Name'>SLog::getDateTimeString</para>
/// <para name='Purpose'>Return a formatted date time string</para>
/// </summary>
/// <param name='logFormat'>indicate whether to return the date time string in log format or decoration format</param>
/// <returns>a formatted date/time string</returns>
/// <remarks>
/// <para name='Notes'></para>
/// <para name='Author'>Kenn Guilstorf</para>
/// <para name='LastModified'>2015-10-26</para>
/// </remarks>
TSTRING SLog::getDateTimeString(bool logFormat)
{
TSTRING retValue;
TSTRING strFormat;
TCHAR* chBuffer = new TCHAR[50];
SYSTEMTIME st;
if (logFormat)
{
strFormat = TSTRING(_T("%04d-%02d-%02d %02d:%02d:%02d.%03d | "));
}
else
{
strFormat = TSTRING(_T(".%04d%02d%02d.%02d%02d%02d%03d"));
}
GetLocalTime(&st);
SPRINTF(chBuffer,
50,
strFormat.c_str(),
(int)st.wYear,
(int)st.wMonth,
(int)st.wDay,
(int)st.wHour,
(int)st.wMinute,
(int)st.wSecond,
(int)st.wMilliseconds);
retValue = TSTRING(chBuffer);
return retValue;
}
开发者ID:KennGuilstorf,项目名称:SPerfTest,代码行数:44,代码来源:SLog.cpp
示例8: 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
示例9: util_RemoveDuplicateSeps
////////////////////////////////////////////////////////////////////////////////
// Function name : util_RemoveDuplicateSeps
// Description :
// takes all adjacent slashes and replaces them with a single slash
// ///root//foo -> /root/foo
// rel//foo/// -> rel/foo/
//
// Return type : void
// Argument : TSTRING& strPath
///////////////////////////////////////////////////////////////////////////////
void util_RemoveDuplicateSeps(TSTRING& strPath)
{
bool fLastCharWasSep = false;
TSTRING::iterator iter = strPath.begin();
while (iter != strPath.end())
{
bool fErasedChar = false;
// if we've found a char that's not '/', then it's not the root
if (*iter == TW_SLASH)
{
// if this char is a duplicate sep, erase it
if (fLastCharWasSep)
{
iter = strPath.erase(iter);
fErasedChar = true;
}
fLastCharWasSep = true;
}
else
{
fLastCharWasSep = false;
}
// don't go past end of string (could happen with erase)
if (!fErasedChar)
iter++;
}
}
开发者ID:Tripwire,项目名称:tripwire-open-source,代码行数:39,代码来源:unixfsservices.cpp
示例10: _T
///////////////////////////////////////////////////////////////////////////////
// LookupArgInfo
///////////////////////////////////////////////////////////////////////////////
bool cCmdLineParser::LookupArgInfo(int argId, TSTRING& arg, TSTRING& alias) const
{
arg = _T("");
alias = _T("");
cHashTableIter<TSTRING, cArgInfo> iter(mArgTable);
for(iter.SeekBegin(); ! iter.Done(); iter.Next())
{
if(iter.Val().mId == argId)
{
TSTRING str = iter.Key();
if((str.length() > 0) && (str[0] == _T('-')))
{
// this is the alias!
alias = (str.c_str() + 1);
}
else
{
// this is the arg...
arg = str;
}
}
}
return ((! arg.empty()) || (! alias.empty()));
}
开发者ID:brc0x1,项目名称:tripwire-open-source,代码行数:28,代码来源:cmdlineparser.cpp
示例11: _DoZeroAccumulator
void CameraControlsDlg::_DoZeroAccumulator(void) {
TSTRING tsMsg;
sprintf(tsMsg, _T("Are you sure you want")
_T(" to zero the step accumulator and")
_T(" global frame count?\n\n")
_T("Frame count is currently: %d\n"),
*m_pdwFrameCount);
if (IDYES == MessageBox(m_hWnd, tsMsg.c_str(),
_T("FURR - Confirm Accumulator Reset"),
MB_YESNO | MB_ICONQUESTION))
{
if (!m_AMSComm.Camera_ResetAccumulator()) {
_ThrowAMSError();
} else {
*m_pdwFrameCount = 0UL;
m_pParent->Output(FURR_OT_INFORMATION, _T("CameraControls:")
_T("Set step accumulator and frame count to zero"));
}
}
}
开发者ID:ryanlederman,项目名称:furr,代码行数:30,代码来源:cameracontrolsdlg.cpp
示例12: DisplayStringToFCOName
///////////////////////////////////////////////////////////////////////////////
// DisplayStringToFCOName
///////////////////////////////////////////////////////////////////////////////
bool cFSNameTranslator::DisplayStringToFCOName( const TSTRING& strC, cFCOName& name ) const
{
TSTRING str = strC;
const TCHAR dq = _T('\"');
// do a little error checking. must have at least '""'
if( str.size() < 1 )
return false;
if( dq != str[0] )
return false;
if( dq != str[str.size() - 1] )
return false;
// get rid of beginning and trailing quote
str = str.substr( 1, str.size() - 2 );
//
// undo funky wide char encoding
//
cDisplayEncoder e( cDisplayEncoder::ROUNDTRIP );
if( ! e.Decode( str ) )
return false;
// give to cFCOName
name = str;
return true;
}
开发者ID:jiangzhw,项目名称:tripwire-open-source,代码行数:31,代码来源:fsnametranslator.cpp
示例13: d
///////////////////////////////////////////////////////////////////////////////
// IsObjectEncrypted
///////////////////////////////////////////////////////////////////////////////
bool cTWUtil::IsObjectEncrypted(const TCHAR* objFileName, const cFileHeaderID& fhid, const TSTRING& errorMsg)
{
bool fEncrypted = false;
cDebug d("IsObjectEncrypted");
d.TraceDebug(_T("Reading from file %s\n"), objFileName);
try
{
cFileArchive arch;
arch.OpenRead(objFileName);
cFileHeader fileHeader;
cSerializerImpl fhSer(arch, cSerializerImpl::S_READ, objFileName);
fileHeader.Read(&fhSer);
// check for a mismatched header
if (fileHeader.GetID() != fhid)
ThrowAndAssert(eSerializerInputStreamFmt(_T(""), objFileName, eSerializer::TY_FILE));
// switch on the type of encoding...
if (fileHeader.GetEncoding() == cFileHeader::ASYM_ENCRYPTION)
{
fEncrypted = true;
}
else if (fileHeader.GetEncoding() == cFileHeader::COMPRESSED)
{
fEncrypted = false;
}
else
// unknown encoding...
ThrowAndAssert(eSerializerInputStreamFmt(_T(""), objFileName, eSerializer::TY_FILE));
}
catch (eArchive& e)
{
// Note: Output to TCERR is O.K. here, it is documented that this is what this function does
TSTRING msg = e.GetMsg();
if (!msg.empty())
msg += _T("\n");
msg += errorMsg;
cTWUtil::PrintErrorMsg(ePoly(e.GetID(), msg, e.GetFlags()));
ThrowAndAssert(ePoly());
}
catch (eSerializer& e)
{
// Note: Output to TCERR is O.K. here, it is documented that this is what this function does
TSTRING msg = e.GetMsg();
if (!msg.empty())
msg += _T("\n");
msg += errorMsg;
cTWUtil::PrintErrorMsg(ePoly(e.GetID(), msg, e.GetFlags()));
ThrowAndAssert(ePoly());
}
return (fEncrypted);
}
开发者ID:Tripwire,项目名称:tripwire-open-source,代码行数:60,代码来源:twutil.cpp
示例14: PrintIter
static void PrintIter(const iFCOIter* pIter, cDebug& d)
{
TSTRING str;
for(; ! pIter->Done(); pIter->Next())
{
str += pIter->FCO()->GetName().AsString().c_str();
str += _T(" ");
}
d.TraceDebug(_T("%s\n"), str.c_str());
}
开发者ID:brc0x1,项目名称:tripwire-open-source,代码行数:10,代码来源:fcosetimpl_t.cpp
示例15: util_FileIsExecutable
///////////////////////////////////////////////////////////////////////////////
// Function name : util_FileIsExecutable
// Description : file ( or file a link points to ) must be a regular
// file and executable by someone
//
// Return type : bool
// Argument : const TSTRING& strFile
///////////////////////////////////////////////////////////////////////////////
bool util_FileIsExecutable(const TSTRING& strFile)
{
if (strFile.empty())
return false;
struct stat s;
if (stat(strFile.c_str(), &s) < 0) // this call handles links
return false;
return (S_ISREG(s.st_mode) && (s.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))); // can someone execute it?
}
开发者ID:Tripwire,项目名称:tripwire-open-source,代码行数:19,代码来源:unixfsservices.cpp
示例16: HexValueToCharString
TSTRING cCharEncoderUtil::HexValueToCharString( const TSTRING& str )
{
TSTRING strOut;
TSTRING::const_iterator at;
for( at = str.begin(); at < str.end(); at += TCHAR_AS_HEX__IN_TCHARS )
{
strOut += hex_to_char( at, at + TCHAR_AS_HEX__IN_TCHARS );
}
return strOut;
}
开发者ID:faical-yannick-congo,项目名称:tripwire-open-source,代码行数:12,代码来源:displayencoder.cpp
示例17: CharStringToHexValue
TSTRING cCharEncoderUtil::CharStringToHexValue( const TSTRING& str )
{
TSTRING strOut;
TSTRING::const_iterator at;
for( at = str.begin(); at < str.end(); at++ )
{
strOut += char_to_hex( *at );
}
return strOut;
}
开发者ID:faical-yannick-congo,项目名称:tripwire-open-source,代码行数:12,代码来源:displayencoder.cpp
示例18: defined
void cUnixFSServices::ReadDir(const TSTRING& strFilename, std::vector<TSTRING>& v, bool bFullPaths) const
{
#else
void cUnixFSServices::ReadDir(const TSTRING& strFilenameC, std::vector<TSTRING>& v, bool bFullPaths) const
{
TSTRING strFilename = cDevicePath::AsNative(strFilenameC);
#endif
//Get all the filenames
DIR* dp = 0;
#if defined(O_DIRECTORY) && defined(O_NOATIME)
//dfd will be autoclosed by closedir(), should not be explicitly closed.
int dfd = open(strFilename.c_str(), O_RDONLY | O_DIRECTORY | O_NOATIME);
if (dfd > 0)
dp = fdopendir(dfd);
#else
dp = opendir(strFilename.c_str());
#endif
if (dp == NULL)
{
throw eFSServicesGeneric(strFilename, iFSServices::GetInstance()->GetErrString());
return;
}
struct dirent* d;
while ((d = readdir(dp)) != NULL)
{
if ((strcmp(d->d_name, _T(".")) != 0) && (strcmp(d->d_name, _T("..")) != 0))
{
if (bFullPaths)
{
//Create the full pathname
TSTRING strNewName = strFilename;
// get full path of dir entry
util_TrailingSep(strNewName, true);
strNewName += d->d_name;
// save full path name
v.push_back(strNewName);
}
else
v.push_back(d->d_name);
}
}
//Close the directory
closedir(dp);
}
开发者ID:Tripwire,项目名称:tripwire-open-source,代码行数:52,代码来源:unixfsservices.cpp
示例19: AllIdentifiersUnique
bool cEncoder::AllIdentifiersUnique() const
{
TSTRING chars;
for( sack_type::const_iterator atE = m_encodings.begin(); atE != m_encodings.end(); atE++ )
{
TCHAR chID = (*atE)->Identifier();
if( chars.find( chID ) == TSTRING::npos )
chars += chID;
else
return false;
}
return true;
}
开发者ID:faical-yannick-congo,项目名称:tripwire-open-source,代码行数:13,代码来源:displayencoder.cpp
示例20: MakeFileError
///////////////////////////////////////////////////////////////////////////////
// MakeFileError
///////////////////////////////////////////////////////////////////////////////
TSTRING cErrorUtil::MakeFileError( const TSTRING& msg, const TSTRING& fileName )
{
TSTRING ret;
ret = TSS_GetString( cCore, core::STR_ERR2_FILENAME );
ret.append( fileName );
ret.append( 1, _T('\n') );
if ( msg.length() > 0 )
{
ret.append(msg);
}
return ret;
}
开发者ID:jiangzhw,项目名称:tripwire-open-source,代码行数:17,代码来源:errorutil.cpp
注:本文中的TSTRING类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论