本文整理汇总了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;
}
示例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);
}
示例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());;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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);
}
示例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);
}
}
}
}
示例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;
}
示例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());
}
}
}
}
示例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);
}
示例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;
}