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


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

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


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

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

示例2: parse

/*!
    \internal
    Parses \a pattern.
    Allowed is f.ex.:
             qt.core.io.debug      FullText, QtDebugMsg
             qt.core.*             LeftFilter, all types
             *.io.warning          RightFilter, QtWarningMsg
             *.core.*              MidFilter
 */
void QLoggingRule::parse(const QStringRef &pattern)
{
    QStringRef p;

    // strip trailing ".messagetype"
    if (pattern.endsWith(QLatin1String(".debug"))) {
        p = QStringRef(pattern.string(), pattern.position(),
                       pattern.length() - 6); // strlen(".debug")
        messageType = QtDebugMsg;
    } else if (pattern.endsWith(QLatin1String(".info"))) {
        p = QStringRef(pattern.string(), pattern.position(),
                       pattern.length() - 5); // strlen(".info")
        messageType = QtInfoMsg;
    } else if (pattern.endsWith(QLatin1String(".warning"))) {
        p = QStringRef(pattern.string(), pattern.position(),
                       pattern.length() - 8); // strlen(".warning")
        messageType = QtWarningMsg;
    } else if (pattern.endsWith(QLatin1String(".critical"))) {
        p = QStringRef(pattern.string(), pattern.position(),
                       pattern.length() - 9); // strlen(".critical")
        messageType = QtCriticalMsg;
    } else {
        p = pattern;
    }

    if (!p.contains(QLatin1Char('*'))) {
        flags = FullText;
    } else {
        if (p.endsWith(QLatin1Char('*'))) {
            flags |= LeftFilter;
            p = QStringRef(p.string(), p.position(), p.length() - 1);
        }
        if (p.startsWith(QLatin1Char('*'))) {
            flags |= RightFilter;
            p = QStringRef(p.string(), p.position() + 1, p.length() - 1);
        }
        if (p.contains(QLatin1Char('*'))) // '*' only supported at start/end
            flags = 0;
    }

    category = p.toString();
}
开发者ID:RSATom,项目名称:Qt,代码行数:51,代码来源:qloggingregistry.cpp

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

示例4: toBool

bool toBool(const QStringRef stringref)
{
    return (stringref == "true" || stringref.string()->toInt() == 1);
}
开发者ID:schdorm,项目名称:openhanse-project,代码行数:4,代码来源:oqstring.cpp

示例5:

String::String(const QStringRef& ref)
{
    if (!ref.string())
        return;
    m_impl = StringImpl::create(reinterpret_cast_ptr<const UChar*>(ref.unicode()), ref.length());
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:6,代码来源:StringQt.cpp

示例6:

ProString::ProString(const QStringRef &str) :
    m_string(*str.string()), m_offset(str.position()), m_length(str.size()), m_file(0), m_hash(0x80000000)
{
}
开发者ID:RSATom,项目名称:Qt,代码行数:4,代码来源:proitems.cpp


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