本文整理汇总了C++中AString::peek方法的典型用法代码示例。如果您正苦于以下问题:C++ AString::peek方法的具体用法?C++ AString::peek怎么用?C++ AString::peek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AString
的用法示例。
在下文中一共展示了AString::peek方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isNameEquals
bool AXmlElement::isNameEquals(const AString& nameattr) const
{
size_t pos = nameattr.find('@');
if (AConstant::npos == pos)
return m_Name.equals(nameattr);
else
{
AString name;
AString attr;
nameattr.peek(name, 0, pos);
nameattr.peek(attr, pos);
return (m_Name.equals(name) && m_Attributes.exists(attr));
}
}
示例2: generateRandomString
void ATextGenerator::generateRandomString(AOutputBuffer& target, size_t len, const AString& strCharSet)
{
for (size_t i = 0x0; i < len; ++i)
{
target.append(strCharSet.peek(ARandomNumberGenerator::get().nextRange(strCharSet.getSize())));
}
}
示例3: splitSyllables
int AWordUtility::splitSyllables(const AString& source, VECTOR_AString& result, bool handleSilentTrailing /* = true */)
{
if (source.isEmpty())
return 0;
AString word(source);
if (handleSilentTrailing)
word.stripTrailing(msstr_SilentEnd);
int count = 0;
size_t start = 0;
size_t pos = word.findOneOf(msstr_SyllableSeparators);
while (AConstant::npos != pos)
{
AString str;
word.peek(str, start, pos - start + 1);
result.push_back(str.c_str());
++count;
start = pos+1;
pos = word.findNotOneOf(msstr_SyllableSeparators, start);
if (AConstant::npos != pos)
pos = word.findOneOf(msstr_SyllableSeparators, start);
}
if (start < word.getSize())
{
//a_Append leftovers to last word
AString str;
word.peek(str, start);
if (count > 0)
result.back().append(str);
else
result.push_back(str);
}
//a_Account for the silent trailing letters
if (handleSilentTrailing && word.getSize() < source.getSize())
{
AString str;
source.peek(str, word.getSize());
if (count > 0)
result.back().append(str);
else
result.push_back(str);
}
return count;
}
示例4: getPlural
void AWordUtility::getPlural(const AString& one, AString& many)
{
many.clear();
//a_Words of size 1 or 2, just append s and return
if (one.getSize() < 3)
{
many.assign(one);
many.append('s');
return;
}
switch(one.last())
{
case 's':
{
char c = one.at(one.getSize()-2);
if ('i' == c)
{
//a_"is" -> "es"
many.assign(one);
many.set('i', many.getSize()-2);
}
else if ('u' == c)
{
//a_"us" -> "ii"
one.peek(many, 0, one.getSize()-2);
many.append("ii", 2);
}
else
{
many.assign(one);
many.append("es", 2);
}
}
break;
case 'z':
case 'x':
many.assign(one);
many.append("es", 2);
break;
case 'h':
{
char c = one.at(one.getSize()-2);
if ('s' == c || 'c' == c)
{
many.assign(one);
many.append("es", 2);
}
else
{
many.assign(one);
many.append('s');
}
}
break;
case 'y':
{
char c = one.at(one.getSize()-2);
if (AConstant::npos != sstr_Vowels.find(c))
{
//a_vowel+'y', add 's'
many.assign(one);
many.append('s');
}
else
{
//a_consonant+'y', convert 'y' to 'ies'
one.peek(many, 0, one.getSize()-1);
many.append("ies", 3);
}
}
break;
default:
many.assign(one);
many.append('s');
break;
}
}
示例5: str
void ATemplateNodeHandler_DADA::Node::_appendWordType(ADadaDataHolder *pddh, MAP_AString_AString& globals, const AString& strType, AOutputBuffer& target)
{
//a_First remove control tags "TYPE:controltag1,controltag2,..."
AString strTypeName, strControl;
LIST_AString listControlNames;
size_t pos = strType.find(':');
if (AConstant::npos != pos)
{
strType.peek(strTypeName, 0, pos);
strTypeName.makeLower();
strType.peek(strControl, pos+1);
strControl.makeLower();
strControl.split(listControlNames, ',', AConstant::ASTRING_WHITESPACE);
}
else
{
strTypeName.assign(strType);
strTypeName.makeLower();
}
ADadaDataHolder::WORDMAP::iterator it = pddh->useWordMap().find(strTypeName);
if (pddh->useWordMap().end() != it)
{
VECTOR_AString& vec = (*it).second;
u4 index = ARandomNumberGenerator::get().nextRange((int)vec.size());
AString strSaveVariable;
AString str(vec.at(index));
//a_Apply control code actions
LIST_AString::iterator itN = listControlNames.begin();
while (itN != listControlNames.end())
{
if ('$' == (*itN).at(0, '\x0'))
{
//a_Add variable to global map
(*itN).peek(strSaveVariable, 1);
globals[strSaveVariable] = str;
strSaveVariable.clear();
}
else if (!strTypeName.compare("verb"))
{
//a_Verb only control
if (!(*itN).compare("present", 7))
{
if (AConstant::npos != AWordUtility::sstr_Vowels.find(str.last()))
{
//a_Vowel at the end is removed and replaced with "ing"
str.rremove(1);
}
str.append("ing", 3);
}
else if (!(*itN).compare("past", 4))
{
if (AConstant::npos == AWordUtility::sstr_Vowels.find(str.last()))
{
str.append("ed", 2);
}
else
{
str.append("d", 1);
}
}
}
if (!(*itN).compare("article", 7))
{
AString strTemp(str);
if (AConstant::npos == AWordUtility::sstr_Vowels.find(str.at(0)))
{
str.assign("a ", 2);
}
else
{
str.assign("an ", 3);
}
str.append(strTemp);
}
if (!(*itN).compare("plural", 6))
{
AString strTemp;
AWordUtility::getPlural(str, strTemp);
str.assign(strTemp);
}
if (!(*itN).compare("uppercase", 9))
{
str.makeUpper();
}
if (!(*itN).compare("lowercase", 9))
{
str.makeLower();
}
if (!(*itN).compare("proper", 6))
{
str.use(0) = (u1)toupper(str.at(0));
//.........这里部分代码省略.........
示例6: parse
size_t AFragmentString::parse(const AString& str)
{
size_t iRet = AConstant::npos;
size_t iX = 0;
AString strHold;
while(iX < str.getSize())
{
switch(str[iX])
{
case '\\' :
{
++iX;
if (str.getSize() > iX)
{
strHold += str[iX];
iRet = iX;
}
else
{
//a_String truncated
iRet = iX - 1;
return iRet;
}
}
break;
case '(' :
{
iX++;
if (str.getSize() > iX)
{
size_t iF = str.find(')', iX+1);
if (iF != AConstant::npos)
{
AASSERT(this, iF >= iX);
if (!strHold.isEmpty()) { m_Container.push_back(new AFragmentConstant(strHold)); strHold.clear(); iRet = iX-1; }
AString strT;
str.peek(strT, iX, iF-iX);
iX = iF; // advance offset after extraction
u1 b;
u4 n[2];
b = (u1)strT.toInt();
if (b > 9)
b = 9;
if ((iF = strT.find(',')) == AConstant::npos)
{
// Only 1 number, the digit value
long stop = 10;
for (int i=1; i<b; ++i)
stop *= 10;
m_Container.push_back(new AFragmentCounter(b, u4(stop-1)));
}
else
{
AString str1;
strT.peek(str1, iF + 1);
if ((iF = str1.find(',')) == AConstant::npos)
{
n[0] = str1.toU4();
m_Container.push_back(new AFragmentCounter(b, n[0]));
}
else
{
AString strQ;
str1.peek(strQ, 0, iF);
n[0] = strQ.toU4();
strQ.clear();
str1.peek(strQ, iF+1);
n[1] = strQ.toU4();
if ((iF = str1.find(',', iF+1)) == AConstant::npos)
m_Container.push_back(new AFragmentCounter(b, n[0], n[1]));
else {
strQ.clear();
str1.peek(strQ, iF+1);
m_Container.push_back(new AFragmentCounter(b, n[0], n[1], strQ.toInt()));
}
}
}
iRet = iX;
}
else
{
//a_Closing tag not found
iRet = iX-1;
return iRet;
}
}
else
{
//a_String is truncated
iRet = iX-1;
return iRet;
}
}
break;
case '{' :
{
//.........这里部分代码省略.........