本文整理汇总了C++中QStringRef::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringRef::isEmpty方法的具体用法?C++ QStringRef::isEmpty怎么用?C++ QStringRef::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStringRef
的用法示例。
在下文中一共展示了QStringRef::isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseReflink
QString ZefaniaLex::parseReflink()
{
const QStringRef fscope = m_xml->attributes().value("fscope");
const QStringRef mscope = m_xml->attributes().value("mscope");
const QStringRef target = m_xml->attributes().value("target");
QString ret;
if(!mscope.isEmpty()) {
VerseUrl burl;
burl.fromMscope(mscope.toString());
QString text;
if(!fscope.isEmpty()) {
text = fscope.toString();
} else {
text = m_refText.toString(burl);
}
m_xml->skipCurrentElement();
ret = "<span class=\"crossreference\"><a class=\"reflink\" href=\"" + burl.toString() + "\">" + text + "</a></span>";
} else if(!target.isEmpty()) {
/* if(target == "XXX") {
}*/
ret = m_xml->readElementText(QXmlStreamReader::IncludeChildElements);
}
return ret;
}
示例2: parseSubtask
void parseSubtask(QXmlStreamReader & in, Task & task)
{
QXmlStreamAttributes attrs = in.attributes();
QString title = attrs.value("title").toString();
Task::SubTask& st(task.subTasks[title]);
QStringRef bgColor = attrs.value("bgcolor");
QStringRef fgColor = attrs.value("fgcolor");
QStringRef active = attrs.value("active");
st.title = title;
if (!bgColor.isEmpty())
st.bgColor = QColor(bgColor.toString());
if (!fgColor.isEmpty())
st.fgColor = QColor(fgColor.toString());
if (!active.isEmpty())
st.active = active.toString().toUInt();
// read subtask
while(!in.atEnd()) {
QXmlStreamReader::TokenType token = in.readNext();
if (token == QXmlStreamReader::StartElement) {
QString elementName = in.name().toString();
if (0) {
} else if (elementName.compare("description", Qt::CaseInsensitive) == 0){
st.description = in.readElementText();
} else if (elementName.compare("hits", Qt::CaseInsensitive) == 0) {
parseHits(in, task, st.title);
}
} else if (token == QXmlStreamReader::EndElement && in.name().toString().compare("subtask", Qt::CaseInsensitive) == 0) {
return;
}
}
}
示例3: parseDemos
void FluidLauncher::parseDemos(QXmlStreamReader& reader)
{
while (!reader.atEnd()) {
reader.readNext();
if (reader.isStartElement() && reader.name() == "example") {
QXmlStreamAttributes attrs = reader.attributes();
QStringRef filename = attrs.value("filename");
if (!filename.isEmpty()) {
QStringRef name = attrs.value("name");
QStringRef image = attrs.value("image");
QStringRef args = attrs.value("args");
QStringRef idpocket = attrs.value("idpocket");
QStringRef desc = attrs.value("desc");
Launcher* newDemo = new Launcher(
idpocket.toString(),
filename.toString(),
name.isEmpty() ? "Unnamed Demo" : name.toString(),
image.toString(),
args.toString().split(" "),
desc.toString());
demoList.append(newDemo);
}
} else if(reader.isEndElement() && reader.name() == "demos") {
return;
}
}
}
示例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: attr
QPair<QStringRef,QStringRef> QDeclarativeStyledTextPrivate::parseAttribute(const QChar *&ch, const QString &textIn)
{
skipSpace(ch);
int attrStart = ch - textIn.constData();
int attrLength = 0;
while (!ch->isNull()) {
if (*ch == greaterThan) {
break;
} else if (*ch == equals) {
++ch;
if (*ch != singleQuote && *ch != doubleQuote) {
while (*ch != greaterThan && !ch->isNull())
++ch;
break;
}
++ch;
if (!attrLength)
break;
QStringRef attr(&textIn, attrStart, attrLength);
QStringRef val = parseValue(ch, textIn);
if (!val.isEmpty())
return QPair<QStringRef,QStringRef>(attr,val);
break;
} else {
++attrLength;
}
++ch;
}
return QPair<QStringRef,QStringRef>();
}
示例6:
void AccelTreeBuilder<FromDocument>::whitespaceOnly(const QStringRef &ch)
{
Q_ASSERT(!ch.isEmpty());
Q_ASSERT(ch.toString().trimmed().isEmpty());
/* This gets problematic due to how QXmlStreamReader works(which
* is the only one we get whitespaceOnly() events from). Namely, text intermingled
* with CDATA gets reported as individual Characters events, and
* QXmlStreamReader::isWhitespace() can return differently for each of those. However,
* it will occur very rarely, so this workaround of 1) mistakenly compressing 2) decompressing 3)
* appending, will happen infrequently.
*/
if(m_hasCharacters)
{
if(m_isCharactersCompressed)
{
m_characters = CompressedWhitespace::decompress(m_characters);
m_isCharactersCompressed = false;
}
m_characters.append(ch.toString());
}
else
{
/* We haven't received a text node previously. */
m_characters = CompressedWhitespace::compress(ch);
m_isCharactersCompressed = true;
m_isPreviousAtomic = false;
m_hasCharacters = true;
}
}
示例7: startDocument
void XMLDocumentParser::startDocument()
{
initializeParserContext();
ExceptionCode ec = 0;
if (!m_parsingFragment) {
document()->setXMLStandalone(m_stream.isStandaloneDocument(), ec);
QStringRef version = m_stream.documentVersion();
if (!version.isEmpty())
document()->setXMLVersion(version, ec);
QStringRef encoding = m_stream.documentEncoding();
if (!encoding.isEmpty())
document()->setXMLEncoding(encoding);
}
}
示例8: handleStartElement
void MessageFactory::handleStartElement(const QStringRef &name, const QStringRef &uri,
const QXmlStreamAttributes &attributes)
{
m_depth++;
if (m_depth == 1)
m_stanza.reset(new MessagePrivate);
StanzaFactory::handleStartElement(name, uri, attributes);
if (m_depth == 1) {
m_state = AtMessage;
MessagePrivate *p = static_cast<MessagePrivate*>(m_stanza.data());
QStringRef subtype = attributes.value(QLatin1String("type"));
if (subtype.isEmpty())
p->subtype = Message::Normal;
else
p->subtype = strToEnum<Message::Type>(subtype, message_types);
if (p->subtype < 0)
p->subtype = Message::Invalid;
} else if(m_depth == 2) {
if(name == QLatin1String("body"))
m_state = AtBody;
else if(name == QLatin1String("subject"))
m_state = AtSubject;
else if(name == QLatin1String("thread"))
m_state = AtThread;
}
}
示例9: ParseSeq
void WplParser::ParseSeq(const QDir& dir, QXmlStreamReader* reader,
SongList* songs) const {
while (!reader->atEnd()) {
QXmlStreamReader::TokenType type = reader->readNext();
switch (type) {
case QXmlStreamReader::StartElement: {
QStringRef name = reader->name();
if (name == "media") {
QStringRef src = reader->attributes().value("src");
if (!src.isEmpty()) {
Song song = LoadSong(src.toString(), 0, dir);
if (song.is_valid()) {
songs->append(song);
}
}
} else {
Utilities::ConsumeCurrentElement(reader);
}
break;
}
case QXmlStreamReader::EndElement: {
if (reader->name() == "seq") {
return;
}
break;
}
default:
break;
}
}
}
示例10:
void
Attr::Load(QXmlStreamAttributes &attrs)
{
const QString &full_prefix = prefix_.With(name_);
QStringRef ref = attrs.value(full_prefix);
if (!ref.isEmpty())
value_ = ref.toString();
}
示例11: valueAsString
QString ScXmlStreamAttributes::valueAsString (const QString& attrName, const QString def) const
{
QString retValue = def;
QStringRef att = value(attrName);
if (!att.isEmpty() || hasAttribute(attrName))
retValue = att.toString();
return retValue;
}
示例12: booleanAttributeValue
static inline bool booleanAttributeValue(const QXmlStreamReader &r, const char *nameC,
bool defaultValue)
{
const QStringRef attributeValue = r.attributes().value(QLatin1String(nameC));
if (attributeValue.isEmpty())
return defaultValue;
return attributeValue == QLatin1String("true");
}
示例13: typeByName
static T typeByName(const QStringRef &name, const char* types[], int n)
{
if (name.isEmpty())
return static_cast<T>(-2); // Empty
ActivityLessThen activityLessThen;
const char **res = qBinaryFind(types, types + n, name, activityLessThen);
return static_cast<T>((res == types + n) ? -1 : (res - types));
}
示例14: 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;
}
示例15: startDocument
void XMLTokenizer::startDocument()
{
initializeParserContext();
ExceptionCode ec = 0;
if (!m_parsingFragment) {
m_doc->setXMLStandalone(m_stream.isStandaloneDocument(), ec);
#if QT_VERSION >= 0x040400
QStringRef version = m_stream.documentVersion();
if (!version.isEmpty())
m_doc->setXMLVersion(version, ec);
QStringRef encoding = m_stream.documentEncoding();
if (!encoding.isEmpty())
m_doc->setXMLEncoding(encoding);
#endif
}
}