本文整理汇总了C++中qstring::const_iterator::isSpace方法的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator::isSpace方法的具体用法?C++ const_iterator::isSpace怎么用?C++ const_iterator::isSpace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qstring::const_iterator
的用法示例。
在下文中一共展示了const_iterator::isSpace方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void BlockStats::update(const QString& text, Dictionary* dictionary)
{
// Calculate stats
m_characters = text.length();
m_spaces = 0;
m_words = 0;
bool word = false;
QString::const_iterator end = text.constEnd();
for (QString::const_iterator i = text.constBegin(); i != end; ++i) {
if (i->isLetterOrNumber() || i->category() == QChar::Punctuation_Dash) {
if (word == false) {
word = true;
m_words++;
}
} else if (i->isSpace()) {
word = false;
m_spaces++;
} else if (*i != 0x2019 && *i != 0x0027) {
word = false;
}
}
// Update stored list of misspelled words
checkSpelling(text, dictionary);
}
示例2: spacesAtCorner
// Finds how many spaces the given string has at one end.
// direction=+1 -> left end of the string, -1 for right end.
int spacesAtCorner(const QString& string, int direction = +1) {
int spaces = 0;
QString::const_iterator it;
for ( it = direction == 1 ? string.begin() : string.end()-1 ; it != string.end(); it += direction ) {
if ( ! it->isSpace() ) break;
spaces += 1;
}
return spaces;
}
示例3: update
void BlockStats::update(const QString& text)
{
m_checked = Unchecked;
m_characters = text.length();
m_spaces = 0;
m_words = 0;
bool word = false;
QString::const_iterator end = text.constEnd();
for (QString::const_iterator i = text.constBegin(); i != end; ++i) {
if (i->isLetterOrNumber() || i->category() == QChar::Punctuation_Dash) {
if (word == false) {
word = true;
m_words++;
}
} else if (i->isSpace()) {
word = false;
m_spaces++;
} else if (*i != 0x2019 && *i != 0x0027) {
word = false;
}
}
}
示例4: consumeToken
AnimExpression::Token AnimExpression::consumeToken(const QString& str, QString::const_iterator& iter) const {
if (!_tokenStack.empty()) {
Token top = _tokenStack.top();
_tokenStack.pop();
return top;
} else {
while (iter != str.end()) {
if (iter->isSpace()) {
++iter;
} else if (iter->isLetter()) {
return consumeIdentifier(str, iter);
} else if (iter->isDigit()) {
return consumeNumber(str, iter);
} else {
switch (iter->unicode()) {
case '&': return consumeAnd(str, iter);
case '|': return consumeOr(str, iter);
case '>': return consumeGreaterThan(str, iter);
case '<': return consumeLessThan(str, iter);
case '(': ++iter; return Token(Token::LeftParen);
case ')': ++iter; return Token(Token::RightParen);
case '!': return consumeNot(str, iter);
case '-': ++iter; return Token(Token::Minus);
case '+': ++iter; return Token(Token::Plus);
case '*': ++iter; return Token(Token::Multiply);
case '/': ++iter; return Token(Token::Divide);
case '%': ++iter; return Token(Token::Modulus);
case ',': ++iter; return Token(Token::Comma);
default:
qCCritical(animation) << "AnimExpression: unexpected char" << *iter << "at index " << (int)(iter - str.begin());
return Token(Token::Error);
}
}
}
return Token(Token::End);
}
}
示例5: skipSpaces
static void skipSpaces( QString::const_iterator& itr, const QString::const_iterator& end)
{
for (; itr != end && itr->isSpace(); ++itr) {}
}
示例6: make_pair
std::pair<TrieNode::Ptr,int> TrieNode::intersectF(
const TrieNode::Ptr &v1, const TrieNode::Ptr &v2, int index1)
{
typedef TrieNode::Ptr P;
typedef QMap<QString,int>::const_iterator MapIterator;
if (v1.isNull() || v2.isNull())
return std::make_pair(P(0), ((v1.isNull()) ? 1 : 0) | ((v2.isNull()) ? 2 : 0));
QString::const_iterator i = v1->prefix.constBegin()+index1, iEnd = v1->prefix.constEnd();
QString::const_iterator j = v2->prefix.constBegin(), jEnd = v2->prefix.constEnd();
while (i != iEnd && j != jEnd) {
if (i->isSpace()) {
if (! j->isSpace())
break;
do {
++j;
} while (j != jEnd && j->isSpace());
do {
++i;
} while (i != iEnd && i->isSpace());
} else {
if (*i != *j)
break;
++i;
++j;
}
}
if (i == iEnd) {
if (j == jEnd) {
if (v1->postfixes.isEmpty() || v2->postfixes.isEmpty()) {
if (v1->postfixes.isEmpty() && v2->postfixes.isEmpty())
return std::make_pair(v1, 3);
foreach (P t1, v1->postfixes)
if (t1->prefix.isEmpty()) {
if (index1 == 0)
return std::make_pair(v2, 2);
else
return std::make_pair(TrieNode::create(
v1->prefix.left(index1).append(v2->prefix), v2->postfixes),0);
}
foreach (P t2, v2->postfixes)
if (t2->prefix.isEmpty())
return std::make_pair(v1,1);
return std::make_pair(P(0), 0);
}
QMap<QString,int> p1, p2;
QList<P> p3;
int ii = 0;
foreach (P t1, v1->postfixes)
p1[t1->prefix] = ii++;
ii = 0;
foreach (P t2, v2->postfixes)
p2[t2->prefix] = ii++;
MapIterator p1Ptr = p1.constBegin(), p2Ptr = p2.constBegin(),
p1End = p1.constEnd(), p2End = p2.constEnd();
int sameV1V2 = 3;
while (p1Ptr != p1End && p2Ptr != p2End) {
if (p1Ptr.key().isEmpty()) {
if (p2Ptr.key().isEmpty()) {
if (sameV1V2 == 0)
p3.append(v1->postfixes.at(p1Ptr.value()));
++p1Ptr;
++p2Ptr;
} else {
if (sameV1V2 == 1)
for (MapIterator p1I = p1.constBegin();p1I != p1Ptr; ++p1I)
p3.append(v1->postfixes.at(p1I.value()));
++p1Ptr;
sameV1V2 &= 2;
}
} else if (p2Ptr.key().isEmpty()) {
if (sameV1V2 == 2)
for (MapIterator p2I = p2.constBegin(); p2I != p2Ptr; ++p2I)
p3.append(v2->postfixes.at(p2I.value()));
++p2Ptr;
sameV1V2 &= 1;
} else {
QChar c1 = p1Ptr.key().at(0);
QChar c2 = p2Ptr.key().at(0);
if (c1 < c2) {
if (sameV1V2 == 1)
for (MapIterator p1I = p1.constBegin(); p1I != p1Ptr; ++p1I)
p3.append(v1->postfixes.at(p1I.value()));
++p1Ptr;
sameV1V2 &= 2;
} else if (c1 > c2) {
if (sameV1V2 == 2)
for (MapIterator p2I = p2.constBegin(); p2I != p2Ptr; ++p2I)
p3.append(v2->postfixes.at(p2I. value()));
++p2Ptr;
sameV1V2 &= 1;
} else {
std::pair<P,int> res = intersectF(v1->postfixes.at(p1Ptr.value()),
v2->postfixes.at(p2Ptr.value()));
if (sameV1V2 !=0 && (sameV1V2 & res.second) == 0) {
if ((sameV1V2 & 1) == 1)
for (MapIterator p1I = p1.constBegin(); p1I != p1Ptr; ++p1I)
p3.append(v1->postfixes.at(p1I.value()));
if (sameV1V2 == 2)
for (MapIterator p2I = p2.constBegin(); p2I != p2Ptr; ++p2I)
p3.append(v2->postfixes.at(p2I.value()));
//.........这里部分代码省略.........