本文整理汇总了C++中AnsiStr::substr方法的典型用法代码示例。如果您正苦于以下问题:C++ AnsiStr::substr方法的具体用法?C++ AnsiStr::substr怎么用?C++ AnsiStr::substr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnsiStr
的用法示例。
在下文中一共展示了AnsiStr::substr方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
bool IniFile::readIntArrayU32(const AnsiStr& section, const AnsiStr& variable, int ctExpected, std::vector<U32>& arrayInt)
{
AnsiStr strVal;
if(readValue(section, variable, strVal))
{
int pos;
int iComp = 0;
AnsiStr strTemp;
if(strVal.firstChar() == '(')
strVal = strVal.substr(1);
else
return false;
while(strVal.lfind(',', pos))
{
strTemp = strVal.substr(0, pos);
strVal = strVal.substr(pos + 1);
strVal.removeStartEndSpaces();
arrayInt.push_back(atoi(strTemp.ptr()));
iComp++;
}
if(strVal.length() >= 1)
{
if(strVal.lastChar() == ')')
{
strTemp = strVal.substr(0, strVal.length() - 1);
strTemp.removeStartEndSpaces();
if(strTemp.length() > 0)
arrayInt.push_back(atoi(strTemp.ptr()));
}
}
}
return ((int)arrayInt.size() == ctExpected);
}
示例2: ExtractOneLevelUp
//==================================================================
AnsiStr ExtractOneLevelUp(const AnsiStr& strFilePath)
{
AnsiStr strOutput = strFilePath;
bool bHasLastSlash = false;
char lastSlash;
//Remove last forward or backward slash
while((strOutput.lastChar() == '/') || (strOutput.lastChar() == '\\'))
{
lastSlash = strOutput.lastChar();
strOutput = strOutput.substr(0, strOutput.length() - 1);
bHasLastSlash = true;
}
int pos = 0;
//Up one level
if(strOutput.rfind('/', pos))
strOutput = strOutput.substr(0, pos);
else if(strOutput.rfind('\\', pos))
strOutput = strOutput.substr(0, pos);
if(bHasLastSlash)
strOutput += lastSlash;
return strOutput;
}
示例3: readValue
//====================================================================================
bool IniFile::readValue(const AnsiStr& section, const AnsiStr& variable, AnsiStr& strValue)
{
AnsiStr strLine = "";
if(readLine(section, variable, strLine))
{
int len = strLine.length();
for(int i=0; i < len; i++)
{
if(strLine[i] == L'=')
{
strValue = strLine.substr(i+1);
return true;
}
}
}
else
{
AnsiStr strFileTitle = ExtractFileName(m_strFileName);
vlogerror("SettingsScript tried to read [file: %s; section: %s; variable: %s] which is not found.",
strFileTitle.cptr(),
section.cptr(),
variable.cptr());
}
return false;
}
示例4: extractSection
//====================================================================================
int IniFile::extractSection(const AnsiStr& title, std::vector<AnsiStr>& lines) {
lines.resize(0);
AnsiStr str;
AnsiStr titleUpperCased = title;
titleUpperCased.toUpper();
int idxStart = -1;
for(int i=0; i < (int)m_content.size(); i++)
{
str = m_content[i];
if((str.firstChar() == '[')&&(str.lastChar() == ']'))
{
//[ + ] = 2
str = str.substr(1, str.length() - 2);
if(str.toUpper() == titleUpperCased) {
idxStart = i;
break;
}
}
}
//Process Content
for(int i=idxStart+1; i < (int)m_content.size(); i++) {
str = m_content[i];
if((str.firstChar() == '[')&&(str.lastChar() == ']'))
break;
else
lines.push_back(str);
}
return (int)lines.size();
}
示例5: ExtractFileTitleOnly
//==================================================================
AnsiStr ExtractFileTitleOnly(const AnsiStr& strFilePath)
{
int pos = 0;
AnsiStr strTemp = ExtractFileName(strFilePath);
if(strTemp.lfind('.', pos))
strTemp = strTemp.substr(0, pos);
return strTemp;
}
示例6: ExtractFileExt
//==================================================================
AnsiStr ExtractFileExt(const AnsiStr& strPathFileName)
{
int npos;
AnsiStr strOut;
if(strPathFileName.rfind('.', npos))
{
strOut = strPathFileName.substr(npos+1);
}
return strOut;
}
示例7: ExtractFilePath
//==================================================================
AnsiStr ExtractFilePath(const AnsiStr& fileName)
{
int npos;
AnsiStr strOutput;
if(fileName.rfind(L'/', npos) || fileName.rfind(L'\\', npos))
{
strOutput = fileName.substr(0, npos+1);
}
return strOutput;
}
示例8: ExtractFileName
//==================================================================
AnsiStr ExtractFileName(const AnsiStr& strPathFileName)
{
int npos;
AnsiStr strOutput = strPathFileName;
if(strPathFileName.rfind(L'/', npos) || strPathFileName.rfind(L'\\', npos))
{
strOutput = strPathFileName.substr(npos+1);
}
return strOutput;
}
示例9: CreateNewFileAtRoot
//==================================================================
AnsiStr CreateNewFileAtRoot(const char* pExtWithDot)
{
AnsiStr strOutput = ps::dir::GetExePath();
int posDot;
if(strOutput.rfind(L'.', posDot))
{
AnsiStr temp = strOutput.substr(0, posDot);
temp.appendFromT(pExtWithDot);
return temp;
}
else
return strOutput;
}
示例10: ChangeFileExt
//==================================================================
AnsiStr ChangeFileExt(const AnsiStr& strFilePath, const AnsiStr& strExtWithDot)
{
AnsiStr strOut;
int npos;
if(strFilePath.rfind('.', npos))
{
strOut = strFilePath.substr(0, npos);
strOut += strExtWithDot;
}
else
strOut = strFilePath + strExtWithDot;
return strOut;
}
示例11: readLine
//====================================================================================
bool IniFile::readLine(const AnsiStr& section, const AnsiStr& variable, AnsiStr& strLine)
{
int startPos = hasSection(section);
if(startPos < 0) return false;
//Record file pos
for(int i=startPos+1; i < (int)m_content.size(); i++)
{
strLine = m_content[i];
//If it is a comment then ignore
if(strLine.firstChar() == '#')
continue;
//Is section?
if((strLine.firstChar() == L'[')&&(strLine.lastChar() == L']'))
{
return false;
}
else
{
for(int iChar=0; iChar < strLine.length(); iChar++)
{
if(strLine[iChar] == L'=')
{
AnsiStr str = strLine.substr(0, iChar);
AnsiStr varUpperCased = variable;
varUpperCased.toUpper();
if( str.toUpper() == varUpperCased )
{
return true;
}
else
break;
}
}
}
}
return false;
}
示例12: hasSection
//====================================================================================
int IniFile::hasSection(const AnsiStr& strSection)
{
AnsiStr str;
for(int i=0; i < (int)m_content.size(); i++)
{
str = m_content[i];
char ch = str.firstChar();
ch = str.lastChar();
if((str.firstChar() == '[')&&(str.lastChar() == ']'))
{
//[ + ] = 2
str = str.substr(1, str.length() - 2);
AnsiStr strSecUpperCased = strSection;
strSecUpperCased.toUpper();
if(str.toUpper() == strSecUpperCased)
return i;
}
}
return -1;
}