Esempio n. 1
0
bool TypeMap::isComplexType( const QName &typeName, const QName& elementName ) const
{
    if (!typeName.isEmpty()) {
        return isComplexType( typeName );
    } else {
        QList<Entry>::ConstIterator it = elementEntry( elementName );
        return it != mElementMap.constEnd() ? (*it).complexType : false;
    }
}
Esempio n. 2
0
void TypeMap::addSchemaTypes( const XSD::Types &types, const QString& ns )
{
  Q_ASSERT( mNSManager );

  XSD::SimpleType::List simpleTypes = types.simpleTypes();
  XSD::SimpleType::List::ConstIterator simpleIt;
  for ( simpleIt = simpleTypes.constBegin(); simpleIt != simpleTypes.constEnd(); ++simpleIt ) {
    Entry entry;
    entry.basicType = false;
    entry.builtinType = false;
    entry.nameSpace = (*simpleIt).nameSpace();
    entry.typeName = (*simpleIt).name();
    entry.localType = prefixNamespace( mNSManager->prefix( entry.nameSpace ).toUpper() + "__" + adaptLocalTypeName( (*simpleIt).name() ), ns );
    entry.baseType = (*simpleIt).baseTypeName();
    //qDebug() << entry.baseType.nameSpace() << entry.baseType.localName() << entry.baseType;
    //entry.headers << (*simpleIt).name().toLower() + ".h";
    entry.forwardDeclarations << entry.localType;

    mTypeMap.append( entry );
  }

  foreach ( const XSD::ComplexType &complex, types.complexTypes() ) {
    Entry entry;
    entry.basicType = false;
    entry.builtinType = false;
    entry.complexType = true;
    entry.nameSpace = complex.nameSpace();
    entry.typeName = complex.name();
    entry.isPolymorphic = complex.isPolymorphicBaseClass();

    //qDebug() << "TypeMap: adding complex type" << entry.nameSpace << entry.typeName << "derived types:" << complex.derivedTypes();

    // Keep empty complex types, useful for document mode.
    /*if ( (*complexIt).isEmpty() )
        entry.localType = "void";
    else*/ {
        entry.localType = prefixNamespace( mNSManager->prefix( entry.nameSpace ).toUpper() + "__" + adaptLocalTypeName( complex.name() ), ns );
        if (complex.isConflicting()) {
            entry.localType += complex.isAnonymous() ? "Element" : "Type";
        }
        //entry.headers << (*complexIt).name().toLower() + ".h";
        entry.forwardDeclarations << entry.localType;
    }

    mTypeMap.append( entry );
  }

  XSD::Attribute::List attributes = types.attributes();
  XSD::Attribute::List::ConstIterator attrIt;
  for ( attrIt = attributes.constBegin(); attrIt != attributes.constEnd(); ++attrIt ) {
    if ( (*attrIt).nameSpace() == "http://www.w3.org/2003/05/soap-encoding" ) // e.g. soap-enc:arrayType
      continue;
    Entry entry;
    entry.basicType = false;
    entry.builtinType = false;
    entry.nameSpace = (*attrIt).nameSpace();
    entry.typeName = (*attrIt).name();
    entry.localType = prefixNamespace( mNSManager->prefix( entry.nameSpace ).toUpper() + "__" + adaptLocalTypeName( (*attrIt).name() + "Attribute" ), ns );
    entry.headers << (*attrIt).name().toLower() + "attribute.h";
    entry.forwardDeclarations << entry.localType;

    mAttributeMap.append( entry );
  }

  const XSD::Element::List elements = types.elements();
  Q_FOREACH( const XSD::Element& elemIt, elements ) {
    Entry entry;
    entry.nameSpace = elemIt.nameSpace();
    entry.typeName = elemIt.name();

    QName type = elemIt.type();
    if ( type.isEmpty() ) {
        qDebug() << "ERROR: element without type" << elemIt.nameSpace() << elemIt.name();
    }

    // Resolve to localType(type)
    QList<Entry>::ConstIterator it = typeEntry(type);
    if ( it == mTypeMap.constEnd() ) {
        qDebug() << "ERROR: basic type not found:" << type;
        Q_ASSERT(0);
        continue;
    }
    const QString resolvedType = (*it).localType;
    Q_ASSERT( !resolvedType.isEmpty() );
    entry.localType = resolvedType;
    entry.basicType = (*it).basicType;
    entry.builtinType = (*it).builtinType;
    entry.complexType = (*it).complexType;
    entry.baseType = type;
    if ( !entry.basicType )
        entry.forwardDeclarations << entry.localType;

    // The "FooElement" type isn't necessary, we just point to the resolved type
    // directly, this is much simpler.
    /*} else {
      entry.localType = mNSManager->prefix( entry.nameSpace ).toUpper() + "__" + adaptLocalTypeName( elemIt.name() + "Element" );
    }*/
    //qDebug() << "Adding TypeMap entry for element" << entry.typeName << resolvedType;
    mElementMap.append( entry );
  }