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


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

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


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

示例1: LOG

/** Skips to the end tag of an unknown element, ignoring any nested elements. */
void PwStreamUtilsV4::readUnknown(QXmlStreamReader& xml) {
    QStringRef unknownTagName = xml.name();
    LOG("WARN: unknown XML element: %s", unknownTagName.toUtf8().constData());

    while (!xml.hasError() && !(xml.isEndElement() && (xml.name() == unknownTagName))) {
        xml.readNext();
        if (xml.isStartElement()) {
            readUnknown(xml);
        }
    }
}
开发者ID:piotrkubisa,项目名称:keepassb,代码行数:12,代码来源:PwStreamUtilsV4.cpp

示例2: 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

示例3: 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());
}
开发者ID:Kakadu,项目名称:qtcreator-ocaml-plugin,代码行数:79,代码来源:RubyScanner.cpp


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