本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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 );
}
示例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 );
}
示例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;
}