本文整理汇总了C++中qstring::const_iterator::unicode方法的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator::unicode方法的具体用法?C++ const_iterator::unicode怎么用?C++ const_iterator::unicode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qstring::const_iterator
的用法示例。
在下文中一共展示了const_iterator::unicode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: consumeNot
AnimExpression::Token AnimExpression::consumeNot(const QString& str, QString::const_iterator& iter) const {
assert(iter != str.end());
assert(iter->unicode() == '!');
iter++;
if (iter->unicode() == '=') {
iter++;
return Token(Token::NotEqual);
} else {
return Token(Token::Not);
}
}
示例2: consumeOr
AnimExpression::Token AnimExpression::consumeOr(const QString& str, QString::const_iterator& iter) const {
assert(iter != str.end());
assert(iter->unicode() == '|');
iter++;
if (iter->unicode() == '|') {
iter++;
return Token(Token::Or);
} else {
qCCritical(animation) << "AnimExpression: unexpected char" << *iter << "at index " << (int)(iter - str.begin());
return Token(Token::Error);
}
}
示例3:
QByteArray RTF::Writer::fromUnicode(const QString& string) const
{
QByteArray text;
QByteArray encoded;
QTextCodec::ConverterState state;
state.flags = QTextCodec::ConvertInvalidToNull;
QString::const_iterator end = string.constEnd();
for (QString::const_iterator i = string.constBegin(); i != end; ++i) {
switch (i->unicode()) {
case '\t': text += "\\tab "; break;
case '\\': text += "\\'5C"; break;
case '{': text += "\\'7B"; break;
case '}': text += "\\'7D"; break;
case 0x00a0: text += "\\~"; break;
case 0x00ad: text += "\\-"; break;
case 0x00b7: text += "\\|"; break;
case 0x2002: text += "\\enspace "; break;
case 0x2003: text += "\\emspace "; break;
case 0x2004: text += "\\qmspace "; break;
case 0x200c: text += "\\zwnj "; break;
case 0x200d: text += "\\zwj "; break;
case 0x200e: text += "\\ltrmark "; break;
case 0x200f: text += "\\rtlmark "; break;
case 0x2011: text += "\\_"; break;
case 0x2013: text += "\\endash "; break;
case 0x2014: text += "\\emdash "; break;
case 0x2018: text += "\\lquote "; break;
case 0x2019: text += "\\rquote "; break;
case 0x201c: text += "\\ldblquote "; break;
case 0x201d: text += "\\rdblquote "; break;
case 0x2022: text += "\\bullet "; break;
default:
encoded = m_codec->fromUnicode(i, 1, &state);
if (state.invalidChars == 0) {
if (encoded.count() == 1 && encoded.at(0) >= 0x20) {
text += encoded;
} else {
for (int j = 0; j < encoded.count(); ++j) {
text += "\\'" + QByteArray::number(static_cast<unsigned char>(encoded.at(j)), 16).toUpper();
}
}
} else {
text += "\\u" + QByteArray::number(i->unicode()) + "?";
}
}
}
return text;
}
示例4: consumeNumber
AnimExpression::Token AnimExpression::consumeNumber(const QString& str, QString::const_iterator& iter) const {
assert(iter != str.end());
assert(iter->isDigit());
auto begin = iter;
while (iter->isDigit() && iter != str.end()) {
++iter;
}
// parse whole integer part
int pos = (int)(begin - str.begin());
int len = (int)(iter - begin);
QString sub = QStringRef(const_cast<const QString*>(&str), pos, len).toString();
int whole = sub.toInt();
// parse optional fractional part
if (iter->unicode() == '.') {
iter++;
auto begin = iter;
while (iter->isDigit() && iter != str.end()) {
++iter;
}
int pos = (int)(begin - str.begin());
int len = (int)(iter - begin);
QString sub = QStringRef(const_cast<const QString*>(&str), pos, len).toString();
int fraction = sub.toInt();
return Token(computeFloat(whole, fraction));
} else {
return Token(whole);
}
}
示例5: todosAscii
bool todosAscii(const QString& s)
{
for (QString::const_iterator it = s.begin(); it != s.end(); ++it)
if (it->unicode() > 127)
return false;
return true;
}
示例6: 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);
}
}