本文整理汇总了C++中stlw::string::assign方法的典型用法代码示例。如果您正苦于以下问题:C++ string::assign方法的具体用法?C++ string::assign怎么用?C++ string::assign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stlw::string
的用法示例。
在下文中一共展示了string::assign方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetBaseDir
static STLW::string GetBaseDir(const STLW::string & szTemplateName, STLW::string & sNormalizedFileName)
{
STLW::string sResult;
CHAR_8 szPath[MAX_PATH];
CHAR_P szFile = NULL;
DWORD dwLen = ::GetFullPathNameA(szTemplateName.c_str(), MAX_PATH, szPath, &szFile);
if (szFile == NULL) { return ""; }
sNormalizedFileName.assign(szPath, dwLen);
sResult.assign(szPath, szFile);
return sResult;
}
示例2: FindFile
//
// Find file in specified list of directories
//
INT_32 MainProcess::FindFile(const STLW::vector<STLW::string> & vDirectories,
const STLW::string & sFilename,
STLW::string & sFullpath)
{
STLW::vector<STLW::string>::const_iterator itvDirectories = vDirectories.begin();
while (itvDirectories != vDirectories.end())
{
sFullpath.erase();
const STLW::string & sDir(*itvDirectories);
if (sDir.size())
{
sFullpath.assign(sDir);
if (sDir[sDir.size() - 1] != '/') { sFullpath.append(1, '/'); }
}
sFullpath.append(sFilename);
const INT_64 iFileHandle = File::Open(sFullpath.c_str(), OpenMode::READ);
if (iFileHandle != -1)
{
File::Close(iFileHandle);
return 0;
}
++itvDirectories;
}
return -1;
}
示例3: sTMP
static STLW::string GetBaseDir(const STLW::string & szTemplateName, STLW::string & sNormalizedFileName)
{
if (szTemplateName.length() == 0) { return ""; }
STLW::vector<STLW::string> vCurrentDir;
CCHAR_P sBegin = szTemplateName.c_str();
CCHAR_P szEnd = szTemplateName.c_str() + szTemplateName.length();
CCHAR_P sIter = sBegin;
while (sIter != szEnd)
{
if (*sIter == '/')
{
if (sIter != sBegin)
{
STLW::string sTMP(sBegin, sIter);
if (sTMP == "/." || sTMP == "/") { ;; }
else if (sTMP == "/..")
{
STLW::vector<STLW::string>::iterator itEnd = vCurrentDir.end();
if (vCurrentDir.begin() == itEnd) { return ""; }
vCurrentDir.erase(--itEnd);
}
else
{
vCurrentDir.push_back(sTMP);
}
}
sBegin = sIter;
}
++sIter;
}
STLW::string sTMP(sBegin, sIter);
if (sTMP == "/") { return ""; }
STLW::string sResult;
for (UINT_32 iI = 0; iI < vCurrentDir.size(); ++iI) { sResult.append(vCurrentDir[iI]); }
sNormalizedFileName.assign(sResult);
sNormalizedFileName.append(sTMP);
sResult.append("/");
return sResult;
}
示例4: GetParams
//
// Get parameters
//
static INT_32 GetParams(const INT_32 iArgc,
CHAR_P * aArgv,
STLW::string & sGlobalConfigFile,
STLW::string & sConfigFile,
STLW::string & sModuleName,
bool & bDebugInfo,
bool & bPrintHelp,
bool & bPrintVersion,
bool & bPrintCompileInfo,
bool & bDaemonize)
{
bDebugInfo = bPrintHelp = bPrintVersion = bPrintCompileInfo = false;
bDaemonize = true;
sConfigFile.erase();
UINT_32 iArgNum = 1;
CCHAR_P szArgValue;
for(;;)
{
INT_32 iOption = GetOpt(oOptions, iArgNum, iArgc, aArgv, szArgValue);
if (iOption == -1) { break; }
switch (iOption)
{
case 'g':
sGlobalConfigFile = szArgValue;
break;
case 'f':
sConfigFile = szArgValue;
break;
case 'm':
sModuleName = szArgValue;
break;
case 'd':
bDebugInfo = true;
break;
case 'h':
bPrintHelp = true;
break;
case 'v':
bPrintVersion = true;
break;
case 'V':
bPrintCompileInfo = true;
break;
case 'F':
bDaemonize = false;
break;
case '?':
fprintf(stderr, "Unknown option `%s` or option with missed argument\n", aArgv[iArgNum]);
return EX_CONFIG;
break;
}
}
if (sConfigFile.empty())
{
// Check environment
CCHAR_P szConfigFile = getenv(ENV_CONFIG_FILE);
if (szConfigFile != NULL && *szConfigFile != '\0') { sConfigFile = szConfigFile; }
if (sConfigFile.empty()) { sConfigFile.assign(DEFAULT_CONFIG_FILE); }
}
if (sGlobalConfigFile.empty())
{
CCHAR_P szConfigFile = getenv("CAS_GLOBAL_CONFIG");
if (szConfigFile != NULL)
{
fprintf(stderr, "Global config not given, using %s from ENVIRONMENT\n", szConfigFile);
sGlobalConfigFile = szConfigFile;
}
}
return EX_OK;
}