本文整理汇总了C++中QStringRef::at方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringRef::at方法的具体用法?C++ QStringRef::at怎么用?C++ QStringRef::at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStringRef
的用法示例。
在下文中一共展示了QStringRef::at方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compress
QString CompressedWhitespace::compress(const QStringRef &input)
{
Q_ASSERT(!isEven(1) && isEven(0) && isEven(2));
Q_ASSERT(!input.isEmpty());
QString result;
const int len = input.length();
/* The amount of compressed characters. For instance, if input is
* four spaces followed by one tab, compressedChars will be 2, and the resulting
* QString will have a length of 1, two compressedChars stored in one QChar. */
int compressedChars = 0;
for(int i = 0; i < len; ++i)
{
const QChar c(input.at(i));
int start = i;
while(true)
{
if(i + 1 == input.length() || input.at(i + 1) != c)
break;
else
++i;
}
/* The length of subsequent whitespace characters in the input. */
int wsLen = (i - start) + 1;
/* We might get a sequence of whitespace that is so long, that we can't
* store it in one unit/byte. In that case we chop it into as many subsequent
* ones that is needed. */
while(true)
{
const int unitLength = qMin(wsLen, int(MaxCharCount));
wsLen -= unitLength;
ushort resultCP = toCompressedChar(c, unitLength);
if(isEven(compressedChars))
result += QChar(resultCP);
else
{
resultCP = resultCP << 8;
resultCP |= result.at(result.size() - 1).unicode();
result[result.size() - 1] = resultCP;
}
++compressedChars;
if(wsLen == 0)
break;
}
}
return result;
}
示例2: isCompleteCharLiteral
static bool isCompleteCharLiteral(const BackwardsScanner &tk, int index)
{
const QStringRef text = tk.textRef(index);
if (text.length() < 2)
return false;
else if (text.at(text.length() - 1) == QLatin1Char('\''))
return text.at(text.length() - 2) != QLatin1Char('\\'); // ### not exactly.
return false;
}
示例3: 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);
}
示例4: rangeAt
// ### the name and behavior of this function is dubious
QmlJS::AST::Node *SemanticInfo::declaringMemberNoProperties(int cursorPosition) const
{
AST::Node *node = rangeAt(cursorPosition);
if (UiObjectDefinition *objectDefinition = cast<UiObjectDefinition*>(node)) {
const QStringRef name = objectDefinition->qualifiedTypeNameId->name;
if (!name.isEmpty() && name.at(0).isLower()) {
QList<AST::Node *> path = rangePath(cursorPosition);
if (path.size() > 1)
return path.at(path.size() - 2);
} else if (name.contains(QLatin1String("GradientStop"))) {
QList<AST::Node *> path = rangePath(cursorPosition);
if (path.size() > 2)
return path.at(path.size() - 3);
}
} else if (UiObjectBinding *objectBinding = cast<UiObjectBinding*>(node)) {
const QStringRef name = objectBinding->qualifiedTypeNameId->name;
if (name.contains(QLatin1String("Gradient"))) {
QList<AST::Node *> path = rangePath(cursorPosition);
if (path.size() > 1)
return path.at(path.size() - 2);
}
}
return node;
}
示例5: 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;
}
示例6: Cell
KeyFace::KeyFace(VAC * vac, XmlStreamReader & xml) :
Cell(vac, xml),
KeyCell(vac, xml),
FaceCell(vac, xml)
{
// Cycles
QString str;
QStringRef d = xml.attributes().value("cycles");
bool opened = false;
for(int i=0; i<d.length(); ++i)
{
QChar c = d.at(i);
if(c == '[')
opened = true;
if(opened)
str += c;
if(c==']')
{
cycles_ << Cycle();
cycles_.last().fromString(str);
opened = false;
str.clear();
}
}
}
示例7: 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;
}
示例8: 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;
}
}
示例9: parseInt
QT_BEGIN_NAMESPACE
static int parseInt(const QStringRef &str, bool *ok)
{
int pos = 0;
int number = 0;
while (pos < str.length() && str.at(pos).isDigit()) {
if (pos != 0)
number *= 10;
number += str.at(pos).unicode() - '0';
++pos;
}
if (pos != str.length())
*ok = false;
else
*ok = true;
return number;
}
示例10: isQtKeyword
bool isQtKeyword(const QStringRef &text)
{
switch (text.length()) {
case 4:
switch (text.at(0).toLatin1()) {
case 'e':
if (text == QLatin1String("emit"))
return true;
break;
case 'S':
if (text == QLatin1String("SLOT"))
return true;
break;
}
break;
case 5:
if (text.at(0) == QLatin1Char('s') && text == QLatin1String("slots"))
return true;
break;
case 6:
if (text.at(0) == QLatin1Char('S') && text == QLatin1String("SIGNAL"))
return true;
break;
case 7:
switch (text.at(0).toLatin1()) {
case 's':
if (text == QLatin1String("signals"))
return true;
break;
case 'f':
if (text == QLatin1String("foreach") || text == QLatin1String("forever"))
return true;
break;
}
break;
default:
break;
}
return false;
}
示例11: 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;
}
示例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: equal
bool equal(const QStringRef &word1,const QString &word2) // is diacritics tolerant
{
int length1=word1.count();
int length2=word2.count();
int i1=-1,i2=-1;
QList<QChar> diacritics1,diacritics2;
QChar letter1,letter2;
while (i1+1<length1 && i2+1<length2)
{
i1++;
i2++;
diacritics1.clear();
diacritics2.clear();
while (i1<length1 && isDiacritic(word1.at(i1)))
{
if (word1.at(i1)!=shadde && word1.at(i1)!=aleft_superscript)
diacritics1.append(word1.at(i1));
i1++;
}
if (i1<length1)
letter1=word1.at(i1);
else
letter1='\0';
while (i2<length2 && isDiacritic(word2.at(i2)))
{
if (word2.at(i2)!=shadde && word2.at(i2)!=aleft_superscript)
diacritics2.append(word2.at(i2));
i2++;
}
if (i2<length2)
letter2=word2.at(i2);
else
letter2='\0';
//now comparison first diacritics then next_letter
if (diacritics1.count()==0 || diacritics2.count()==0 || equal_strict(diacritics1,diacritics2))
{
if (equal(letter1,letter2))
continue;
else
return false;
}
return false;
}
if (length1-(i1+1)==0 && length2-(i2+1)==0)
return true;
if (length1-(i1+1)==0)
{
for (int i=i2+1;i<length2;i++)
if (!isDiacritic(word2.at(i)))
return false;
}
else
{
for (int i=i1+1;i<length1;i++)
if (!isDiacritic(word1.at(i)))
return false;
}
return true;
}
示例14: while
glm::vec3 XMLReader::ToVec3(const QStringRef &s)
{
glm::vec3 result;
int start_idx;
int end_idx = -1;
for(int i = 0; i < 3; i++){
start_idx = ++end_idx;
while(end_idx < s.length() && s.at(end_idx) != QChar(' '))
{
end_idx++;
}
result[i] = s.mid(start_idx, end_idx - start_idx).toFloat();
}
return result;
}
示例15: readIdentifier
/**
reads identifier and classifies it
*/
Token Scanner::readIdentifier()
{
QChar ch = m_src.peek();
while (ch.isLetterOrNumber() || ch == '_' || ch == '?' || ch == '!') {
m_src.move();
ch = m_src.peek();
}
QStringRef value = m_src.value();
Token::Kind kind = Token::Identifier;
if (m_src.peek() == ':' && m_src.peek(1) != ':') {
m_src.move();
kind = Token::SymbolHashKey;
} else if (value.at(0) == '@') {
kind = Token::ClassField;
} else if (value.length() > 1 && value.at(0) == ':') {
kind = Token::Symbol;
} else if (value.at(0) == '$') {
kind = Token::Global;
} else if (value.at(0).isUpper()) {
kind = Token::Constant;
if (m_hasContextRecognition && m_contextPattern.match(m_tokenSequence).hasMatch()) {
m_context << value.toString();
m_contextDepths << m_indentDepth;
}
// TODO: Use gperf for this keywords hash
} else if (value == "end") {
kind = Token::KeywordEnd;
m_indentDepth--;
if (!m_contextDepths.empty() && m_indentDepth < m_contextDepths.last()) {
m_context.pop_back();
m_contextDepths.pop_back();
}
} else if (value == "self") {
kind = Token::KeywordSelf;
} else if (value == "def") {
kind = Token::KeywordDef;
m_indentDepth++;
} else if (value == "module") {
kind = Token::KeywordModule;
m_indentDepth++;
} else if (value == "class") {
kind = Token::KeywordClass;
m_indentDepth++;
} else if (value == "if" || value == "unless") {
kind = Token::KeywordFlowControl;
if (m_controlFlowShouldIncIndentPattern.match(m_tokenSequence).hasMatch())
m_indentDepth++;
} else if (value == "while" || value == "until") {
kind = Token::KeywordLoop;
m_indentDepth++;
} else if (value == "do" || value == "begin" || value == "case") {
kind = Token::KeywordBlockStarter;
m_indentDepth++;
} else if (value == "else"
|| value == "elsif"
|| value == "ensure"
|| value == "rescue") {
kind = Token::KeywordElseElsIfRescueEnsure;
} else if (value == "protected" || value == "private" || value == "public") {
kind = Token::KeywordVisibility;
} else if (std::find(&RUBY_KEYWORDS[0], &RUBY_KEYWORDS[N_KEYWORDS], value.toUtf8()) != &RUBY_KEYWORDS[N_KEYWORDS]) {
kind = Token::Keyword;
} else if (m_methodPattern.match(m_tokenSequence).hasMatch()) {
QChar ch = m_src.peek();
while (!ch.isNull() && !ch.isSpace() && ch != '(' && ch != '#') {
m_src.move();
ch = m_src.peek();
}
kind = Token::Method;
} else if (m_parameterPattern.match(m_tokenSequence).hasMatch()) {
kind = Token::Parameter;
}
return Token(kind, m_src.anchor(), m_src.length());
}