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


C++ QStringRef::size方法代码示例

本文整理汇总了C++中QStringRef::size方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringRef::size方法的具体用法?C++ QStringRef::size怎么用?C++ QStringRef::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QStringRef的用法示例。


在下文中一共展示了QStringRef::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: readBitArray

QBitArray BaseStateAbstract::readBitArray(QStringRef val)
{
    QBitArray ret(val.size(), false);
    for (int i = 0; i < val.size(); i++) {
        if (val.at(i) == B_ONE) {
            ret.setBit(i);
        } // already set to false by default, nothing to change
    }

    return ret;
}
开发者ID:metrodango,项目名称:pip3line,代码行数:11,代码来源:basestateabstract.cpp

示例2: midRef

QStringRef Subtitle::Parser::trimmed(const QStringRef &ref) {
	int from = 0;
	for (; from <ref.size() && RichString::isSeperator(ref.at(from).unicode()); ++from) ;
	int to = -1;
	for (int p=from; p<ref.size(); ++p) {
		if (RichString::isSeperator(ref.at(p).unicode())) {
			if (to < 0)
				to = p;
		} else
			to = -1;
	}
	if (to < 0)
		return RichString::midRef(ref, from);
	return RichString::midRef(ref, from, to - from);
}
开发者ID:kleopatra999,项目名称:cmplayer-kldp.net,代码行数:15,代码来源:subtitle_parser.cpp

示例3: readByteArray

QByteArray BaseStateAbstract::readByteArray(QStringRef data)
{
    if (data.size() > 10000000) {
        emit log(tr("Restoring %1 bytes of data. That's a fat cat you have here, it will take some time to reconstitute.").arg(data.size()), "Save state",Pip3lineConst::LWARNING );
    }
    return stringToByteArray(data.toString());;
}
开发者ID:metrodango,项目名称:pip3line,代码行数:7,代码来源:basestateabstract.cpp

示例4: flagSize

Akonadi::Item::Flags Maildir::readEntryFlags(const QString &key) const
{
    Akonadi::Item::Flags flags;

    const QRegularExpression rx = statusSeparatorRx();
    const int index = key.indexOf(rx);
    if (index != -1) {
        const QStringRef mailDirFlags = key.midRef(index + 3);   // after "(:|!)2,"
        const int flagSize(mailDirFlags.size());
        for (int i = 0; i < flagSize; ++i) {
            const QChar flag = mailDirFlags.at(i);
            if (flag == QLatin1Char('P')) {
                flags << Akonadi::MessageFlags::Forwarded;
            } else if (flag == QLatin1Char('R')) {
                flags << Akonadi::MessageFlags::Replied;
            } else if (flag == QLatin1Char('S')) {
                flags << Akonadi::MessageFlags::Seen;
            } else if (flag == QLatin1Char('F')) {
                flags << Akonadi::MessageFlags::Flagged;
            }
        }
    }

    return flags;
}
开发者ID:KDE,项目名称:kdepim-runtime,代码行数:25,代码来源:maildir.cpp

示例5: isWhiteSpace

// Richtext simplification filter helpers: Check for blank QStringRef.
static inline bool isWhiteSpace(const QStringRef &in)
{
	const int count = in.size();
	for (int i = 0; i < count; i++)
		if (!in.at(i).isSpace())
			return false;
	return true;
}
开发者ID:Monthy,项目名称:gr-lida,代码行数:9,代码来源:editorwidget.cpp

示例6: getExpandedLinkTextWithEntities

TextWithEntities HiddenUrlClickHandler::getExpandedLinkTextWithEntities(ExpandLinksMode mode, int entityOffset, const QStringRef &textPart) const {
	TextWithEntities result;
	result.entities.push_back({ EntityInTextCustomUrl, entityOffset, textPart.size(), url() });
	if (mode == ExpandLinksAll) {
		result.text = textPart.toString() + qsl(" (") + url() + ')';
	}
	return result;
}
开发者ID:Ammohammad,项目名称:tdesktop,代码行数:8,代码来源:click_handler_types.cpp

示例7: on_match_helper

bool TreeSearch::on_match_helper() {
    //check if matches with Diacritics
    filled_details = false;
    fill_details();
    int startPos = info.start, subpos, last;

    if (reduce_thru_diacritics) {
        int count = sub_positionsOFCurrentMatch.count();

        for (int k = 0; k < count; k++) {
            subpos = sub_positionsOFCurrentMatch[k]; //getLastDiacritic(position-1,info.text)-1);
            QStringRef subword = addlastDiacritics(startPos, subpos, info.text, last);

            //qDebug() <<subword;
            for (int j = 0; j < possible_raw_datasOFCurrentMatch[k].count(); j++) {
                QString rawdata = possible_raw_datasOFCurrentMatch[k][j].getActual();
                bool raw_has_diacritics = startPos > 0 && isDiacritic((*info.text)[startPos - 1]);
                bool input_ended_with_diacritic = subword.size() > 0 && isDiacritic(subword.at(subword.size() - 1));

                if (raw_has_diacritics ||
                    input_ended_with_diacritic) {//in this case we can assume we are working in the first suffix or recursive affixes whose diacritics are for those before them
                    QStringRef diacritics_of_word = getDiacriticsBeforePosition(startPos, info.text),
                               diacritics_of_rawdata = (rawdata.size() > 0 ? addlastDiacritics(0, 0,
                                                        &rawdata) : QStringRef()); //to get first couple of diacritics of raw_data without letters

                    if (!equal(diacritics_of_word, diacritics_of_rawdata, true)) { //force_shadde
                        possible_raw_datasOFCurrentMatch[k].removeAt(j);
                        j--;
                        continue;
                    }
                }

                if (!equal(subword, rawdata, true)) { //force_shadde
                    possible_raw_datasOFCurrentMatch[k].removeAt(j);
                    j--;
                }
            }

            startPos = subpos + 1;
        }

        for (int i = 0; i < possible_raw_datasOFCurrentMatch.count(); i++)
            if (0 == possible_raw_datasOFCurrentMatch[i].count()) {
                return true;    //not matching, continue without doing anything
            }
    } else {
        last = getLastDiacritic(position - 1, info.text);
    }

    info.finish = last - 1;
    position = last;

    if (!onMatch()) {
        return false;
    } else {
        return true;
    }
}
开发者ID:tanab,项目名称:atmine,代码行数:58,代码来源:tree_search.cpp

示例8: handleCharacterData

void AbstractStructureParser::handleCharacterData(const QStringRef &text)
{
	if (m_currentString) {
		*m_currentString = text.toString();
		m_currentString = 0;
	} else if (m_currentArray) {
		const QString str = QString::fromRawData(text.unicode(), text.size());
		*m_currentArray = QByteArray::fromBase64(str.toLatin1());
		m_currentArray = 0;
	}
}
开发者ID:NeutronStein,项目名称:jreen,代码行数:11,代码来源:vcardfactory.cpp

示例9: hash

/*!
    return hash value for \a string.
*/
quint32 HbSharedCache::hash(const QStringRef &string)
{
    quint32 hashValue = 0;
    const QChar *data = string.unicode();
    int size = string.size();
    while (size--) {
        hashValue = data->unicode() + (hashValue << 6) + (hashValue << 16) - hashValue;
        ++data;
    }
    return hashValue;
}
开发者ID:kuailexs,项目名称:symbiandump-mw1,代码行数:14,代码来源:hbsharedcache.cpp

示例10: file

	std::tuple<bool, const char*> loadWordStatisticsXml(const std::wstring& filePath, WordsUsageInfo& wordsStat, std::vector<const WordSeqUsage*>& wordSeqOrder)
	{
		QFile file(QString::fromStdWString(filePath));
		if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
			return std::make_tuple(false, "Can't open file");

		QXmlStreamReader xml;
		xml.setDevice(&file);

		// got to document root

		xml.readNextStartElement(); // document root

		//
		while (!xml.atEnd())
		{
			xml.readNext();
			if (xml.isStartElement() && xml.name() == "word")
			{
				QXmlStreamAttributes attrs = xml.attributes();
				QStringRef idRef = attrs.value("id");
				bool parseNum;
				int usedCount = attrs.value("usedCount").toInt(&parseNum);
				if (!parseNum)
					return std::make_tuple(false, "usedCount must be integer");

				QString wordQ = QString::fromRawData(idRef.constData(), idRef.size());
				std::wstring wordW((const wchar_t*)wordQ.utf16(), wordQ.size());

				bool wasAdded = false;
				const WordPart* wordPart = wordsStat.getOrAddWordPart(wordW, WordPartSide::WholeWord, &wasAdded);
				if (!wasAdded)
					return std::make_tuple(false, "Error: duplicate words in words statistic");
				
				WordSeqKey wordIds({ wordPart->id() });

				WordSeqUsage* wordUsage = wordsStat.getOrAddWordSequence(wordIds, &wasAdded);
				if (!wasAdded)
					return std::make_tuple(false, "Error: duplicate words in words statistic");

				wordUsage->UsedCount = usedCount;

				wordSeqOrder.push_back(wordUsage);
			}
		}
		if (xml.hasError())
			return std::make_tuple(false, "Error in XML parsing");

		return std::make_tuple(true, nullptr);
	}
开发者ID:tivadj,项目名称:PticaGovorun,代码行数:50,代码来源:RunBuildLanguageModel.cpp

示例11: characters

void CStateMachine::characters(QXmlStreamReader* reader)
{
    // qDebug() << QString("characters");
	QStringRef text = reader->text();
	switch(m_state)
	{
		case e_reading_nextlist:
			if(m_diffFromRev == -1)
			{
				parseCollection<CPlaylistItem>(text, m_nextlistModelPtr);
			}
			else
			{
				parseCollectionDiff<CPlaylistItem>(text, m_nextlistModelPtr);
			}
			break;

		case e_reading_playlist:
			if(m_diffFromRev == -1)
			{
				parseCollection<CPlaylistItem>(text, m_playlistModelPtr);
			}
			else
			{
				parseCollectionDiff<CPlaylistItem>(text, m_playlistModelPtr);
			}
			break;

		case e_reading_collection:
			if(m_diffFromRev == -1)
			{
				parseCollection<CCollectionItem>(text, m_collectionModelPtr);
			}
			else
			{
				parseCollectionDiff<CCollectionItem>(text, m_collectionModelPtr);
			}
			break;

		default:
			if(text.size() > 0)
			{
				if( ! text.toString().trimmed().isEmpty() ) {
					// not interested in whitespaces from indentation here.
					qDebug() << QString("Received unexpected characters: ").append(text);
				}
			}
	}
}
开发者ID:BackupTheBerlios,项目名称:muroa-svn,代码行数:49,代码来源:CStateMachine.cpp

示例12: isNCName

/*!
   \internal

   Determines whether \a c is a valid instance of
   production [4]NCName in the XML 1.0 Namespaces specification. If it
   is, true is returned, otherwise false.

    \sa \l {http://www.w3.org/TR/REC-xml-names/#NT-NCName}
           {W3CNamespaces in XML 1.0 (Second Edition), [4] NCName}
 */
bool QXmlUtils::isNCName(const QStringRef &ncName)
{
    if(ncName.isEmpty())
        return false;

    const QChar first(ncName.at(0));

    if(!QXmlUtils::isLetter(first) && first.unicode() != '_' && first.unicode() != ':')
        return false;

    const int len = ncName.size();
    for(int i = 0; i < len; ++i)
    {
        const QChar &at = ncName.at(i);
        if(!QXmlUtils::isNameChar(at) || at == QLatin1Char(':'))
            return false;
    }

    return true;
}
开发者ID:66eli77,项目名称:RadChip,代码行数:30,代码来源:qxmlutils.cpp

示例13: parseNextLine

void QLoggingSettingsParser::parseNextLine(QStringRef line)
{
    // Remove whitespace at start and end of line:
    line = line.trimmed();

    // comment
    if (line.startsWith(QLatin1Char(';')))
        return;

    if (line.startsWith(QLatin1Char('[')) && line.endsWith(QLatin1Char(']'))) {
        // new section
        auto sectionName = line.mid(1, line.size() - 2).trimmed();
        m_inRulesSection = sectionName.compare(QLatin1String("rules"), Qt::CaseInsensitive) == 0;
        return;
    }

    if (m_inRulesSection) {
        int equalPos = line.indexOf(QLatin1Char('='));
        if (equalPos != -1) {
            if (line.lastIndexOf(QLatin1Char('=')) == equalPos) {
                const auto pattern = line.left(equalPos).trimmed();
                const auto valueStr = line.mid(equalPos + 1).trimmed();
                int value = -1;
                if (valueStr == QLatin1String("true"))
                    value = 1;
                else if (valueStr == QLatin1String("false"))
                    value = 0;
                QLoggingRule rule(pattern, (value == 1));
                if (rule.flags != 0 && (value != -1))
                    _rules.append(rule);
                else
                    warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData());
            } else {
                warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData());
            }
        }
    }
}
开发者ID:RSATom,项目名称:Qt,代码行数:38,代码来源:qloggingregistry.cpp

示例14: nextToken

QStringRef ChessEngine::nextToken(const QStringRef& previous, bool untilEnd)
{
	const QString* str = previous.string();
	if (str == 0)
		return QStringRef();

	int i;
	int start = -1;
	int firstPos = previous.position() + previous.size();

	for (i = firstPos; i < str->size(); i++)
	{
		if (str->at(i).isSpace())
		{
			if (start == -1)
				continue;
			break;
		}
		else if (start == -1)
		{
			start = i;
			if (untilEnd)
			{
				int end = str->size();
				while (str->at(--end).isSpace())
					;
				i = end + 1;
				break;
			}
		}
	}

	if (start == -1)
		return QStringRef();
	return QStringRef(str, start, i - start);
}
开发者ID:eliaskousk,项目名称:cutechess,代码行数:36,代码来源:chessengine.cpp

示例15: tokenize

	UrlParser::UrlTokenList UrlParser::tokenize(const QString &text, Flags flags)
	{
		UrlTokenList result;
		static QRegExp linkRegExp("([a-zA-Z0-9\\-\\_\\.][email protected]([a-zA-Z0-9\\-\\_]+\\.)+[a-zA-Z]+)|"
		                          "([a-z]+(\\+[a-z]+)?://|www\\.)"
		                          "[\\w-]+(\\.[\\w-]+)*\\.\\w+"
		                          "(:\\d+)?"
		                          "(/[\\w\\+\\.\\[\\]!%\\$/\\(\\),:;@'&=~-]*"
		                          "(\\?[\\w\\+\\.\\[\\]!%\\$/\\(\\),:;@\\'&=~-]*)?"
		                          "(#[\\w\\+\\.\\[\\]!%\\$/\\\\\\(\\)\\|,:;@&=~-]*)?)?",
		                          Qt::CaseInsensitive);
		Q_ASSERT(linkRegExp.isValid());
		QList<QPair<int, int> > tags;
		int currentTag = 0;
		if (flags & Html) {
			enum TagParserState {
				AtText,
				AtTag,
				AtSingleQuote,
				AtDoubleQuote
			};
			TagParserState state = AtText;
			int start = 0;
			for (int i = 0; i < text.size(); ++i) {
				QChar ch = text.at(i);
				switch (state) {
				case AtText:
					if (ch == QLatin1Char('<')) {
						state = AtTag;
						start = i;
					}
					break;
				case AtTag:
					if (ch == QLatin1Char('>')) {
						tags << qMakePair(start, i);
						state = AtText;
					} else if (ch == QLatin1Char('\'')) {
						state = AtSingleQuote;
					} else if (ch == QLatin1Char('\"')) {
						state = AtDoubleQuote;
					}
					break;
				case AtSingleQuote:
					if (ch == QLatin1Char('\''))
						state = AtTag;
					break;
				case AtDoubleQuote:
					if (ch == QLatin1Char('\"'))
						state = AtTag;
					break;
				}
			}
		}
		int pos = 0;
		int lastPos = 0;
		while (((pos = linkRegExp.indexIn(text, pos)) != -1)) {
			QString link = linkRegExp.cap(0);
			while (currentTag < tags.size() && tags.at(currentTag).second < pos)
				currentTag++;
			if (currentTag < tags.size()) {
				const QPair<int, int> &pair = tags.at(currentTag);
				int left = qBound(pair.first, pos, pair.second);
				int right = qBound(pair.first, pos + link.size(), pair.second);
				if (left != right) {
					pos += link.size();
					continue;
				}
			}
			UrlToken tok = { text.midRef(lastPos, pos - lastPos), QString() };
			if (!tok.text.isEmpty()) {
				if (!result.isEmpty() && result.last().url.isEmpty()) {
					QStringRef tmp = result.last().text;
					result.last().text = QStringRef(tmp.string(), tmp.position(), tmp.size() + tok.text.size());
				} else {
					result << tok;
				}
			}
			tok.text = text.midRef(pos, link.size());
			pos += link.size();
			if (link.startsWith(QLatin1String("www."), Qt::CaseInsensitive))
				link.prepend(QLatin1String("http://"));
			else if(!link.contains(QLatin1String("//")))
				link.prepend(QLatin1String("mailto:"));
			tok.url = link;
			result << tok;
			lastPos = pos;
		}
		if (!result.isEmpty() && result.last().url.isEmpty()) {
			result.last().text = text.midRef(result.last().text.position());
		} else {
			UrlToken tok = { text.midRef(lastPos), QString() };
			result << tok;
		}
		return result;
	}
开发者ID:dganic,项目名称:qutim,代码行数:95,代码来源:utils.cpp


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