本文整理汇总了C++中CArray::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ CArray::push_back方法的具体用法?C++ CArray::push_back怎么用?C++ CArray::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CArray
的用法示例。
在下文中一共展示了CArray::push_back方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseCommandLineFile
st_bool CCommandLineParser::ParseCommandLineFile(const char* pFilename, const char* pExeName, SUserSettings& sConfig)
{
st_bool bSuccess = false;
FILE* pFile = fopen(pFilename, "r");
if (pFile)
{
// parse the cmd-line options in the file and store in an array of arguments
CArray<CFixedString> aArguments;
CFixedString strTemp;
st_bool bInQuotes = false;
while (!feof(pFile))
{
st_char chTemp = (st_char)fgetc(pFile);
st_bool bSaveString = false;
if (chTemp == '#')
{
// skip rest of comment line
while (!feof(pFile) && (chTemp != '\r' && chTemp != '\n'))
chTemp = (st_char)fgetc(pFile);
bSaveString = true;
}
else if (chTemp == '\"')
{
// quote delimited string
if (bInQuotes)
bSaveString = true;
bInQuotes = !bInQuotes;
}
else if (!bInQuotes && (chTemp == ' ' || chTemp == '\r' || chTemp == '\n'))
{
// other whitespace
bSaveString = true;
}
else
{
strTemp += chTemp;
}
if (bSaveString && !strTemp.empty( ))
{
// save this string as an argument
aArguments.push_back(strTemp);
strTemp.resize(0);
}
}
fclose(pFile);
// convert the array to a standard argv-type data structure
const st_int32 c_nNumArgs = st_int32(aArguments.size( ) + 1);
char** argv = new char*[c_nNumArgs];
for (st_int32 i = 1; i < c_nNumArgs; ++i)
argv[i] = (char*) aArguments[i - 1].c_str( );
argv[0] = (char*) pExeName; // normally contains the exe name
// feed back into the parse routine
bSuccess = Parse(c_nNumArgs, argv, sConfig);
delete [] argv;
}
return bSuccess;
}