本文整理汇总了C++中StringData::length方法的典型用法代码示例。如果您正苦于以下问题:C++ StringData::length方法的具体用法?C++ StringData::length怎么用?C++ StringData::length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringData
的用法示例。
在下文中一共展示了StringData::length方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isEqualNoCase
bool isEqualNoCase(const StringData& left, const StringData& right)
{
if (left.length() != right.length())
return false;
for (unsigned int i = 0; i < left.length(); i++)
{
if (toupper(left[i]) != toupper(right[i]))
return false;
}
return true;
}
示例2: xorString
StringData StringData::xorString(const StringData& str1, const StringData& str2)
{
int maxLen = str1.length() > str2.length() ? str1.length() : str2.length();
int minLen = str1.length() > str2.length() ? str2.length() : str1.length();
char *buff = new char[maxLen];
int i = 0;
for (i = 0; i < minLen; i++)
{
buff[i] = str1[i] ^ str2[i];
}
if (str1.length() > str2.length())
{
for (i = minLen; i < maxLen; i++)
buff[i] = ~str1[i];
}
else
{
for (i = minLen; i < maxLen; i++)
buff[i] = ~str2[i];
}
StringData data = StringData(buff, maxLen);
delete[] buff;
return data;
}
示例3: match
int StringData::match(StringData match, StringData* retModifiedData,
bool replace, StringData replaceWith)
{
int retVal = FIRST;
int pos = buf.find(match.buf);
if (pos == -1)
{
return NOT_FOUND;
}
else
{
if (pos != 0)
retVal = FOUND;
}
unsigned int replacePos = pos + match.length();
if (retModifiedData)
{
(*retModifiedData) = buf.substr(0, pos);
}
if (replace)
{
if (replacePos <= buf.size())
{
buf.replace(0, replacePos, replaceWith.buf);
}
}
return retVal;
}
示例4: inflate
void StringData::inflate(int size, const StringData &fillval, bool before)
{
if ((int) buf.length() >= size)
return;
StringData dtVal;
int iInflateSize = size - buf.length();
for (unsigned int i = 0; i < iInflateSize / fillval.length(); i++)
{
dtVal += fillval;
}
if (iInflateSize % fillval.length() > 0)
dtVal += fillval.substr(0, iInflateSize % fillval.length());
if (before)
operator =(dtVal + *this);
else
operator =(*this + dtVal);
}
示例5: replace
void StringData::replace(const StringData& from, const StringData to)
{
int pos = 0;
while ((pos = find(from)) != -1)
{
replace(pos, from.length(), to);
}
}
示例6: data
map<int, StringData> StringData::split(const StringData& sp, bool bCut) const
{
StringData dtVal;
map<int, StringData> mapVal;
StringData data(*this);
int i = 0;
while (data.match(sp, &dtVal, true) != NOT_FOUND)
{
mapVal[i++] = dtVal;
if (bCut)
{
while (data.substr(0, sp.length()) == sp)
data = data.substr(sp.length());
}
}
if (data.length() > 0)
mapVal[i] = data;
return mapVal;
}
示例7: isEndWith
bool StringData::isEndWith(const StringData& str, bool bCase) const
{
if (buf.length() < str.length())
return false;
StringData subStr = buf.substr(buf.length() - str.length());
if (bCase)
{
if (subStr == str)
return true;
else
return false;
}
else
{
if (compareNoCase(subStr.getData(), str.getData(), str.length()) == 0)
return true;
else
return false;
}
}
示例8: findNoCase
int StringData::findNoCase(const StringData& match, int start/*=0*/)
{
const char* pStrCompare = match.getDataBuf();
const char* pStr = getDataBuf();
int iLen = match.length();
int iMaxLen = length();
for (int i = 0; i <= iMaxLen - iLen; i++)
{
if (!compareNoCase(pStr + i, pStrCompare, iLen))
return i;
}
return -1;
}
示例9: findlastNoCase
int StringData::findlastNoCase(const StringData& match, int stop/*=-1*/) const
{
if (stop >= (int) buf.size() || stop <= 0)
stop = buf.size() - 1;
const char* pStr = buf.c_str();
const char* pCompare = match.getDataBuf();
int len = match.length();
for (int i = stop - len + 1; i >= 0; i--)
{
if (!compareNoCase(pStr + i, pCompare, len))
return i;
}
return -1;
}
示例10: getDataSection
void getDataSection(const StringData& data, unsigned int& start,
StringData& dtRet, bool& bIsNumric)
{
bIsNumric = (data[start] <= '9' && data[start] >= '0');
while (start < data.length())
{
if (bIsNumric)
{
if (!(data[start] <= '9' && data[start] >= '0'))
break;
}
else
{
if (data[start] <= '9' && data[start] >= '0')
break;
}
dtRet += data[start++];
}
}
示例11: if
bool StringData::operator>(const StringData& data) const
{
if (length() > 0 && data.length() == 0)
return true;
if (length() == 0 && data.length() > 0)
return false;
if (length() == 0 && data.length() == 0)
return false;
unsigned int pos1 = 0;
unsigned int pos2 = 0;
while (true)
{
if (pos1 == length() && pos2 == data.buf.length())
return false;
if (pos1 == length() && pos2 < data.buf.length())
return false;
if (pos2 == length() && pos1 < length())
return true;
KData dtData1, dtData2;
bool isNumeric1, isNumeric2;
getDataSection(*this, pos1, dtData1, isNumeric1);
getDataSection(data, pos2, dtData2, isNumeric2);
if (isNumeric1 && !isNumeric2)
return false;
else if (!isNumeric1 && isNumeric2)
return true;
else if (isNumeric1 && isNumeric2)
{
if (dtData1.length() > dtData2.length())
{
return true;
}
else if (dtData2.length() > dtData1.length())
{
return false;
}
else
{
if (dtData1.buf == dtData2.buf)
continue;
else
return (dtData1.buf > dtData2.buf);
}
}
else if (!isNumeric1 && !isNumeric2)
{
unsigned int len = min(dtData1.length(), dtData2.length());
for (unsigned int i = 0; i < len; i++)
{
char ch1 = dtData1[i];
char ch2 = dtData2[i];
bool bUpcase1, bUpcase2;
if (ch1 >= 'A' && ch1 <= 'Z')
{
bUpcase1 = true;
ch1 += ('a' - 'A');
}
else
{
bUpcase1 = false;
}
if (ch2 >= 'A' && ch2 <= 'Z')
{
bUpcase2 = true;
ch2 += ('a' - 'A');
}
else
{
bUpcase2 = false;
}
if (ch2 == ch1)
{
if (bUpcase1 == bUpcase2)
continue;
else if (bUpcase1)
return true;
else
return false;
}
else
{
return ch1 > ch2;
}
}
if (dtData1.length() == dtData2.length())
continue;
else if (dtData1.length() > dtData2.length())
return true;
else
return false;
}
}
}