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


C++ QXmlAttributes::length方法代码示例

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


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

示例1: startElement

bool TsHandler::startElement( const QString& /* namespaceURI */,
                              const QString& /* localName */,
                              const QString& qName,
                              const QXmlAttributes& atts )
{
    if ( qName == QString("byte") ) {
        for ( int i = 0; i < atts.length(); i++ ) {
            if ( atts.qName(i) == QString("value") ) {
                QString value = atts.value( i );
                int base = 10;
                if ( value.startsWith("x") ) {
                    base = 16;
                    value = value.mid( 1 );
                }
                int n = value.toUInt( 0, base );
                if ( n != 0 )
                    accum += QChar( n );
            }
        }
    } else {
        if ( qName == QString("TS") ) {
            m_language = atts.value(QLatin1String("language"));
        } else if ( qName == QString("context") ) {
            context.truncate( 0 );
            source.truncate( 0 );
            comment.truncate( 0 );
            m_translatorComment.truncate( 0 );
            translations.clear();
            contextIsUtf8 = encodingIsUtf8( atts );
        } else if ( qName == QString("message") ) {
            inMessage = true;
            type = MetaTranslatorMessage::Finished;
            source.truncate( 0 );
            comment.truncate( 0 );
            m_translatorComment.truncate( 0 );
            translations.clear();
            messageIsUtf8 = encodingIsUtf8( atts );
            m_isPlural = atts.value(QLatin1String("numerus")).compare(QLatin1String("yes")) == 0;
        } else if (qName == QString("location") && inMessage) {
            bool bOK;
            int lineNo = atts.value(QString("line")).toInt(&bOK);
            if (!bOK) lineNo = -1;
            m_fileName = atts.value(QString("filename"));
            m_lineNumber = lineNo;
        } else if ( qName == QString("translation") ) {
            for ( int i = 0; i < atts.length(); i++ ) {
                if ( atts.qName(i) == QString("type") ) {
                    if ( atts.value(i) == QString("unfinished") )
                        type = MetaTranslatorMessage::Unfinished;
                    else if ( atts.value(i) == QString("obsolete") )
                        type = MetaTranslatorMessage::Obsolete;
                    else
                        type = MetaTranslatorMessage::Finished;
                }
            }
        }
        accum.truncate( 0 );
    }
    return true;
}
开发者ID:nmelchior,项目名称:Tools,代码行数:60,代码来源:metatranslator.cpp

示例2: startElement

bool StructureParser::startElement( const QString& namespaceURI,
                                    const QString& ,
                                    const QString& qName,
                                    const QXmlAttributes& attributes)
{
    QTreeWidgetItem * element;


    if (!stack.isEmpty())
    {
        QTreeWidgetItem *lastChild = stack.top().firstChild();

        if ( lastChild )
        {
            while ( lastChild->nextSibling() )
                lastChild = lastChild->nextSibling();
        }
        element = new QTreeWidgetItem( stack.top(), lastChild, qName, namespaceURI );
    }
    else
    {
        element = new QTreeWidgetItem( table, qName, namespaceURI );
    }

    stack.push( element );
    element->setOpen( TRUE );
    if ( attributes.length() > 0 ) {
        for ( int i = 0 ; i < attributes.length(); i++ ) {
            new QTreeWidgetItem( element, attributes.qName(i), attributes.uri(i) );
        }
    }
    return TRUE;
}
开发者ID:aafontoura,项目名称:mission-groundstation,代码行数:33,代码来源:structureparser.cpp

示例3: startElement

bool TsHandler::startElement( const QString& /* namespaceURI */, const QString& /* localName */, const QString& qName, const QXmlAttributes& atts )
{
	if ( qName == QString( "byte" ) )
	{
		for ( int i = 0; i < atts.length(); i++ )
		{
			if ( atts.qName( i ) == QString( "value" ) )
			{
				QString value = atts.value( i );
				int base = 10;
				if ( value.startsWith( "x" ) )
				{
					base = 16;
					value = value.mid( 1 );
				}
				int n = value.toUInt( 0, base );
				if ( n != 0 )
					accum += QChar( n );
			}
		}
	}
	else
	{
		if ( qName == QString( "context" ) )
		{
			context.truncate( 0 );
			source.truncate( 0 );
			comment.truncate( 0 );
			translation.truncate( 0 );
			contextIsUtf8 = encodingIsUtf8( atts );
		}
		else if ( qName == QString( "message" ) )
		{
			inMessage = TRUE;
			type = MetaTranslatorMessage::Finished;
			source.truncate( 0 );
			comment.truncate( 0 );
			translation.truncate( 0 );
			messageIsUtf8 = encodingIsUtf8( atts );
		}
		else if ( qName == QString( "translation" ) )
		{
			for ( int i = 0; i < atts.length(); i++ )
			{
				if ( atts.qName( i ) == QString( "type" ) )
				{
					if ( atts.value( i ) == QString( "unfinished" ) )
						type = MetaTranslatorMessage::Unfinished;
					else if ( atts.value( i ) == QString( "obsolete" ) )
						type = MetaTranslatorMessage::Obsolete;
					else
						type = MetaTranslatorMessage::Finished;
				}
			}
		}
		accum.truncate( 0 );
	}
	return TRUE;
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:59,代码来源:metatranslator.cpp

示例4: startElement

		bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
		{
			if(depth == 0) {
				Parser::Event *e = new Parser::Event;
				QXmlAttributes a;
				for(int n = 0; n < atts.length(); ++n) {
					QString uri = atts.uri(n);
					QString ln = atts.localName(n);
					if(a.index(uri, ln) == -1)
						a.append(atts.qName(n), uri, ln, atts.value(n));
				}
				e->setDocumentOpen(namespaceURI, localName, qName, a, nsnames, nsvalues);
				nsnames.clear();
				nsvalues.clear();
				e->setActualString(in->lastString());

				in->resetLastData();
				eventList.append(e);
				in->pause(true);
			}
			else {
				QDomElement e = doc->createElementNS(namespaceURI, qName);
				for(int n = 0; n < atts.length(); ++n) {
					QString uri = atts.uri(n);
					QString ln = atts.localName(n);
					bool have;
					if(!uri.isEmpty()) {
						have = e.hasAttributeNS(uri, ln);
						if(qt_bug_have)
							have = !have;
					}
					else
						have = e.hasAttribute(ln);
					if(!have)
						e.setAttributeNS(uri, atts.qName(n), atts.value(n));
				}

				if(depth == 1) {
					elem = e;
					current = e;
				}
				else {
					current.appendChild(e);
					current = e;
				}
			}
			++depth;
			return true;
		}
开发者ID:BackupTheBerlios,项目名称:synapse-xmpp-svn,代码行数:49,代码来源:parser.cpp

示例5: startElement

bool XMLHandler::startElement( const QString& namespaceURI, const QString& /*localName*/, const QString& qName, const QXmlAttributes& atts )
{
    if (m_currentNode->nodeType() == Node::TEXT_NODE)
	exitText();

    ElementImpl *newElement;
    if (namespaceURI.isNull())
	newElement = m_doc->createElement(qName);
    else
	newElement = m_doc->createElementNS(namespaceURI,qName);

    // ### handle exceptions
    int i;
    for (i = 0; i < atts.length(); i++)
	newElement->setAttribute(atts.localName(i),atts.value(i));
    if (m_currentNode->addChild(newElement)) {
	if (m_view)
	    newElement->attach(m_view);
	m_currentNode = newElement;
	return TRUE;
    }
    else {
	delete newElement;
	return FALSE;
    }
}
开发者ID:BackupTheBerlios,项目名称:nirvana-svn,代码行数:26,代码来源:xml_tokenizer.cpp

示例6: startElement

bool SAXConfigurationHandler::startElement ( const QString & namespaceURI, 
        const QString & localName, const QString & qName, 
        const QXmlAttributes & atts ) {
    int idx = qName.find ( ':' );
    QString prefix = "";
    if ( idx > 0 ) {
        prefix = qName.left ( idx );
    }
    ConfigurationPtr c(new DefaultConfiguration( localName, 
            getLocationString(), namespaceURI, prefix ));

    // if processing the toplevel item simply push it, otherwise link it
    // with the parent
    if( d->configuration.isNull() ) {
        d->configuration = c;
    } else {
        ConfigurationPtr parent = d->elements.top();
        parent->addChild( c );
    }

    // process attributes
    for( int i = 0; i < atts.length(); i ++ ) {
        c->setAttribute( atts.localName( i ), atts.value( i ) );
    }

    // push currently built configuration to the stack
    d->elements.push( c );

    return true;
}
开发者ID:acassis,项目名称:lintouch,代码行数:30,代码来源:SAXConfigurationHandler.cpp

示例7: startElement

bool TemplateQueryHandler::startElement ( const QString & /*namespaceURI*/, const QString & /*localName*/, const QString & qName, const QXmlAttributes & atts )
{
  //qDebug() << "startElement: " << qName;
  if(!m_inTripleList && (qName.compare("triple_list")==0 ))
    {
      m_inTripleList = true;
      return true;
    }
  if(m_currentTriple)
    {
      if(qName.compare("subject") == 0 )
	{
	  // no need to check for element type, since subject are always URIs (when received)
	  m_component = ESubject;
	}
      else if(qName.compare("predicate") == 0 )
	{
	  // no need to check for element type, since predicates are always URIs 
	  m_component = EPredicate;
	}
      else if(qName.compare("object") == 0 && 
	      (atts.length() == 1) && 
	      (atts.qName(0).compare("type") == 0))
	{
	  //check elementtype for object, bNode is illegal when received.
	  QString attrvalue = atts.value(0);
	  m_component = EObject;
	  if( attrvalue.compare("literal", Qt::CaseInsensitive) == 0) 
	    m_elementType = TripleElement::ElementTypeLiteral;
	  else if (attrvalue.compare("URI", Qt::CaseInsensitive) == 0)
	    m_elementType = TripleElement::ElementTypeURI;
	  else
	    {
	      m_errorString = "Invalid object type: ";
	      m_errorString.append(attrvalue);
	      return false;
	    }
	  m_component = EObject;
	}
      else
	{
	  m_errorString = "Invalid element name for a triple: ";
	  m_errorString.append(qName);
	  return false;
	}
    }
  else
    {
      if(qName.compare("triple") == 0 )
	{
	  m_currentTriple = new Triple();
	}
      else
	{
	  m_errorString = "starting something other than triple element";
	  return false;
	}
    }
  return true;
}
开发者ID:smart-m3,项目名称:libwhiteboard-qt4,代码行数:60,代码来源:templatequeryhandler.cpp

示例8: indexOf

    int indexOf(const QXmlAttributes & attributes, const QString & name,
                 const QString & type = "CDATA", const bool mandatory = true)
    {
        const int idx(attributes.index(name));
        if (idx < 0 || idx > attributes.length()) { return -1; }
        if (attributes.type(idx) != type) { return -1; }
        if (mandatory && attributes.value(idx).isEmpty()) { return -1; }

        return idx;
    }
开发者ID:Exarchiasghost,项目名称:doxygen,代码行数:10,代码来源:dbusxmlscanner.cpp

示例9: startElement

bool LastFMStatusParser::startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &attributes)
{
	if (attributes.length() > 0)
	{
		if (attributes.value(0) == "manual-updates")
		{
			m_found = true;
		}
	}

	return QXmlDefaultHandler::startElement(namespaceURI, localName, qName, attributes);
}
开发者ID:Znurre,项目名称:nplayer,代码行数:12,代码来源:LastFmStatusParser.cpp

示例10: return

static bool encodingIsUtf8( const QXmlAttributes& atts )
{
    for ( int i = 0; i < atts.length(); i++ ) {
	// utf8="true" is a pre-3.0 syntax
	if ( atts.qName(i) == QString("utf8") ) {
	    return ( atts.value(i) == QString("true") );
	} else if ( atts.qName(i) == QString("encoding") ) {
	    return ( atts.value(i) == QString("UTF-8") );
	}
    }
    return FALSE;
}
开发者ID:OS2World,项目名称:LIB-QT3_Toolkit_Vbox,代码行数:12,代码来源:metatranslator.cpp

示例11: startElement

bool MyHandler::startElement( const QString&, /* We have omitted the names of the parameters that we don't use. This prevents the compiler from issuing "unused parameter" warnings. */
                              const QString&, const QString& qName,
                              const QXmlAttributes& atts) {
    QString str = QString("\n%1\\%2").arg(indent).arg(qName);
    cout << str;
    if (atts.length()>0) {
        QString fieldName = atts.qName(0);
        QString fieldValue = atts.value(0);
        cout << QString("(%2=%3)").arg(fieldName).arg(fieldValue);
    }
    cout << "{";
    indent += "    ";
    return TRUE;
}
开发者ID:jabouzi,项目名称:qt,代码行数:14,代码来源:myhandler.cpp

示例12: startElement

/*!
    Start parsing an element called \a qName, which can be be broken up
    into \a namespaceURI and \a localName.  The attribute list is \a atts.
*/
bool QWbXmlToXmlContentHandler::startElement( const QString& , const QString& , const QString& qName, const QXmlAttributes& atts )
{
    if ( d->lastWasTag ) {
        d->result += "\n";
        addIndent();
    }
    ++(d->indent);
    d->result += "<" + qName;
    for( int index = 0; index < atts.length(); ++index ) {
        d->result += " " + atts.qName( index ) + "=\"";
        addQuoted( atts.value( index ) );
        d->result += "\"";
    }
    d->result += ">";
    d->lastWasTag = true;
    return true;
}
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:21,代码来源:qwbxmlreader.cpp

示例13: startElement

bool PropertyParser::startElement( const QString & /* namespaceUrl */,
    const QString & /* localName */, const QString& elementName,
    const QXmlAttributes& attribute )
{
    // If debugging, print each element and its attributes as encountered.
    m_indent += "    ";
    if ( m_debug )
    {
        std::cout << m_indent << "<" << elementName;
        for ( int id = 0;
              id < attribute.length();
              id++ )
        {
            std::cout << " " << attribute.localName(id) << "=\""
              << attribute.value(id) << "\"";
        }
        std::cout << " >" << std::endl;
    }
    // Skip all elements until <BehavePlus> is found.
    if ( ! m_elements )
    {
        if ( elementName == "BehavePlus" )
        {
            push( elementName );
            return( true );
        }
        trError( "PropertyParser:unknownDocument" );
        return( false );
    }
    // <property> elements
    if ( elementName == "property" )
    {
        push( elementName );
        if ( ! handleProperty( elementName, attribute ) )
        {
            return( false );
        }
    }
    // Ignore all other tags
    else
    {
        trError( "PropertyParser:unknownElement", elementName );
        return( false );
    }
    return( true );
}
开发者ID:cbevins,项目名称:BehavePlus5,代码行数:46,代码来源:property.cpp

示例14: startElement

bool XmlParser::startElement( const QString & /* namespaceUri */,
    const QString & /* localName */, const QString& elementName,
    const QXmlAttributes& attribute )
{
    // If debugging, print each element and its attributes as encountered.
    m_indent += "    ";
    if ( m_debug )
    {
        std::cout << m_indent << "<" << elementName;
        for ( int id = 0;
              id < attribute.length();
              id++ )
        {
            std::cout << " " << attribute.localName(id) << "=\""
              << attribute.value(id) << "\"";
        }
        std::cout << " >" << std::endl;
    }
    return( true );
}
开发者ID:cbevins,项目名称:BehavePlus5,代码行数:20,代码来源:xmlparser.cpp

示例15: domstring

bool
MMLContentHandler::startElement(const QString &/*namespaceURI*/,
        const QString & localName, const QString &/*qName*/,
        const QXmlAttributes &atts ) {
    if (debug) qDebug("startElement '%s'", (const char*)localName.toUtf8());
    // the root element must be a 'math' element, it this is absent,
    // we create one
    if (cur == doc && localName != "math") {
        MMLElement *e = doc->createElement("math");
        cur->appendChild(e);
        cur = e;
    }
    bool ok = false;
    MMLElement *e = doc->createElement(domstring(localName));
    if (e) {
        cur->appendChild(e);
        for (int i=0; e->attributesValid() && i<atts.length(); ++i) {
            QString v = atts.value(i).simplified();
            e->setAttribute(atts.localName(i).toUtf8(),
            domstring(v));
        }
        if (e->attributesValid()) {
            cur = e;
            ok = true;
        } else {
            err = qstring(e->errorMsg());
            cur = NULL;
        }
    } else {
        err = qstring(doc->errorMsg());
        qDebug("error: %s", (const char*)err.toUtf8());
        // read failed: clear all
        cur = NULL;
    }
    return ok;
}
开发者ID:BackupTheBerlios,项目名称:libmathml-svn,代码行数:36,代码来源:mmlcontenthandler.cpp


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