当前位置: 首页>>代码示例>>C++>>正文


C++ qstring::const_iterator类代码示例

本文整理汇总了C++中qstring::const_iterator的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator类的具体用法?C++ const_iterator怎么用?C++ const_iterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了const_iterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
开发者ID:JackH79,项目名称:focuswriter,代码行数:25,代码来源:block_stats.cpp

示例2: 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;
}
开发者ID:lagenar,项目名称:clprover,代码行数:7,代码来源:qclprover.cpp

示例3: 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);
    }
}
开发者ID:AlphaStaxLLC,项目名称:hifi,代码行数:33,代码来源:AnimExpression.cpp

示例4: isCorrectRules

bool isCorrectRules(const RulesMap &rules)
{
    QString key, val;
    //Для каждого правила
    for (RulesMap::const_iterator i = rules.constBegin(); i != rules.constEnd(); ++i){
        key = i.key();
        val = i.value();
        //Для каждого символа ключа
        for (QString::const_iterator j = key.constBegin(); j != key.constEnd(); ++j){
            if (j->isLetter()||*j == '`'){
                if (!((*j >= QChar('a') && *j <= QChar('z')) || *j == '`' || (*j >= QChar('A') && *j <= QChar('Z')))){
                    return false;
                }
            }
            else{
                return false;
            }
        }
        //Для каждого символа значения
        for (QString::const_iterator j = val.constBegin(); j != val.constEnd(); ++j){
            if (j->isLetter()){
                if (!((*j >= QChar(1040) && *j <= (1105)))){
                    return false;
                }
            }
            else{
                return false;
            }
        }
    }
    return true;
}
开发者ID:KarenMarkosyan,项目名称:transliterator,代码行数:32,代码来源:check.cpp

示例5: 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;
}
开发者ID:KDE,项目名称:kdevelop,代码行数:11,代码来源:kdevqmljsplugin.cpp

示例6: isCorrectText

bool isCorrectText(const QString &text)
{
    for (QString::const_iterator i = text.constBegin(); i != text.constEnd(); ++i){
        if (i->isLetter()){
            if (!((*i >= 'a' && *i <= 'z') || (*i >= 'A' && *i <= 'Z'))){
                return false;
            }
        }
    }
    return true;
}
开发者ID:KarenMarkosyan,项目名称:transliterator,代码行数:11,代码来源:check.cpp

示例7: 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);
    }
}
开发者ID:AlphaStaxLLC,项目名称:hifi,代码行数:11,代码来源:AnimExpression.cpp

示例8: 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);
    }
}
开发者ID:AlphaStaxLLC,项目名称:hifi,代码行数:12,代码来源:AnimExpression.cpp

示例9:

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;
}
开发者ID:svenna,项目名称:focuswriter,代码行数:51,代码来源:writer.cpp

示例10: nameToObjectName

QString GluonObject::nameToObjectName( const QString& name )
{
    // Sanitize the object name to be an acceptable javascript object name.
    // While this is also done by the scripting engine, we use the object name for other things
    // as well, such as filenames etc
    QString theObjectName;
    QString::const_iterator i;
    for( i = name.constBegin(); i != name.constEnd(); ++i )
    {
        if( i->isLetterOrNumber() || *i == '_' )
            theObjectName.append( *i );
    }
    return theObjectName;
}
开发者ID:pranavrc,项目名称:gluon,代码行数:14,代码来源:gluonobject.cpp

示例11: fromYYYYMMDD

            QDate fromYYYYMMDD (const QString& yyyymmdd) {
                if (yyyymmdd.length() != YYYYMMDD_FORMAT.length())
                    throw "Invalid input. Provide date as yyyyMMdd (e.g. June 2, 2016 = '20160602')";

                for (QString::const_iterator chr (yyyymmdd.begin()); chr != yyyymmdd.end(); chr++) {
                    if (!chr->isDigit())
                        throw "Non digit character in input string.";
                }

                const QDate result = QDate::fromString(yyyymmdd, YYYYMMDD_FORMAT);

                if (!result.isValid())
                    throw "Invalid date input";

                return result;
            }
开发者ID:just10inc,项目名称:COPPA,代码行数:16,代码来源:time_utils.cpp

示例12: ParseDecimalPart

static
ParseResult ParseDecimalPart(ParseResult const& begin, QString::const_iterator end)
{
	Amount multiplier ("0.1"); //exactly 1 tenth
	Amount decrement ("0.1"); //exactly 1 tenth
	Amount a = ResultAmount(begin);
	QString::const_iterator iter;
	for (iter = ResultIter(begin); iter != end; iter++) {
		if (iter->isDigit()) {
			a += Amount(iter->digitValue())*multiplier;
			multiplier *= decrement;
		} else {
			throw std::runtime_error("Invalid currency string");
		}
	}
	return ParseResult(a,iter);
}
开发者ID:dotyjim,项目名称:BillsSplitter,代码行数:17,代码来源:ConvertToAmount.cpp

示例13: setRules

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void elMundo::setRules (QString ruleString)
{
    QString::const_iterator it;
    int B_bitmask = 0, S_bitmask = 0;
    QString digits;
    if (reBrule.indexIn(ruleString) >= 0) {
        digits = reBrule.cap(1);
        for (it = digits.constBegin(); it != digits.constEnd(); it++)
            B_bitmask |= (1 << it->digitValue());
    }
    if (reSrule.indexIn(ruleString) >= 0) {
        digits = reSrule.cap(1);
        for (it = digits.constBegin(); it != digits.constEnd(); it++)
            S_bitmask |= (1 << it->digitValue());
    }
    fprintf(stderr,"Rules(%s=+%x:%x)\n", ruleString.cStr(), B_bitmask,S_bitmask);
    setRules(B_bitmask, S_bitmask);
}
开发者ID:epiktetov,项目名称:juego-de-la-vida,代码行数:19,代码来源:elmundo.cpp

示例14: consumeIdentifier

AnimExpression::Token AnimExpression::consumeIdentifier(const QString& str, QString::const_iterator& iter) const {
    assert(iter != str.end());
    assert(iter->isLetter());
    auto begin = iter;
    while ((iter->isLetter() || iter->isDigit()) && iter != str.end()) {
        ++iter;
    }
    int pos = (int)(begin - str.begin());
    int len = (int)(iter - begin);

    QStringRef stringRef(const_cast<const QString*>(&str), pos, len);
    if (stringRef == "true") {
        return Token(true);
    } else if (stringRef == "false") {
        return Token(false);
    } else {
        return Token(stringRef);
    }
}
开发者ID:AlphaStaxLLC,项目名称:hifi,代码行数:19,代码来源:AnimExpression.cpp

示例15: ParseWholePart

static
ParseResult ParseWholePart(QString::const_iterator begin, QString::const_iterator end)
{
	Amount a (0);
	QString::const_iterator iter;
	for (iter = begin; iter != end; iter++) {
		if (iter->isDigit()) {
			a *= Amount(10);					//scale up
			a = a + Amount(iter->digitValue()); //add
		} else if (*iter == QLocale().groupSeparator()) {
			//eat it
		} else if (*iter == QLocale().decimalPoint()) {
			iter++; //skip the decimal point
			return ParseResult(a, iter);
		} else {
			throw std::runtime_error("Invalid currency string");
		}
	}
	return ParseResult(a,iter);
}
开发者ID:dotyjim,项目名称:BillsSplitter,代码行数:20,代码来源:ConvertToAmount.cpp


注:本文中的qstring::const_iterator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。