Beispiel #1
0
QList<TypeMap::Entry>::ConstIterator TypeMap::elementEntry( const QName &typeName ) const
{
  QList<Entry>::ConstIterator it;
  for ( it = mElementMap.constBegin(); it != mElementMap.constEnd(); ++it ) {
    if ( (*it).typeName == typeName.localName() && (*it).nameSpace == typeName.nameSpace() )
      break;
  }
  return it;
}
Beispiel #2
0
QStringList TypeMap::forwardDeclarationsForAttribute( const QName &typeName ) const
{
  QList<Entry>::ConstIterator it;
  for ( it = mAttributeMap.constBegin(); it != mAttributeMap.constEnd(); ++it ) {
    if ( (*it).typeName == typeName.localName() && (*it).nameSpace == typeName.nameSpace() )
      return (*it).forwardDeclarations;
  }

  return QStringList();
}
Beispiel #3
0
QString TypeMap::localTypeForAttribute( const QName &typeName ) const
{
  QList<Entry>::ConstIterator it;
  for ( it = mAttributeMap.constBegin(); it != mAttributeMap.constEnd(); ++it ) {
    if ( (*it).typeName == typeName.localName() && (*it).nameSpace == typeName.nameSpace() )
      return (*it).localType;
  }

  return QString();
}
Beispiel #4
0
XSD::Element WSDL::findElement( const QName &elementName ) const
{
  const XSD::Types types = mDefinitions.type().types();
  const XSD::Element::List elements = types.elements();
  for ( int i = 0; i < elements.count(); ++i ) {
    if ( elements[ i ].nameSpace() == elementName.nameSpace() && elements[ i ].name() == elementName.localName() )
      return elements[ i ];
  }

  return XSD::Element();
}
Beispiel #5
0
Binding WSDL::findBinding( const QName &bindingName ) const
{
  const Binding::List list = mDefinitions.bindings();
  Binding::List::ConstIterator it;
  for ( it = list.constBegin(); it != list.constEnd(); ++it ) {
    if ( (*it).name() == bindingName.localName() && (*it).nameSpace() == bindingName.nameSpace() ) {
      return *it;
    }
  }

  return Binding();
}
Beispiel #6
0
Message WSDL::findMessage( const QName &messageName ) const
{
  const Message::List list = mDefinitions.messages();
  Message::List::ConstIterator it;
  for ( it = list.constBegin(); it != list.constEnd(); ++it ) {
    if ( (*it).name() == messageName.localName() && (*it).nameSpace() == messageName.nameSpace() ) {
      return *it;
    }
  }
  qDebug( "findMessage: no match found for '%s'!", qPrintable( messageName.qname() ) );

  return Message();
}
Beispiel #7
0
PortType WSDL::findPortType( const QName &portTypeName ) const
{
  const PortType::List list = mDefinitions.portTypes();
  PortType::List::ConstIterator it;
  for ( it = list.begin(); it != list.end(); ++it ) {
    if ( (*it).name() == portTypeName.localName() && (*it).nameSpace() == portTypeName.nameSpace() ) {
      return *it;
    }
  }
  qDebug( "findPortType: no match found for '%s'!", qPrintable( portTypeName.qname() ) );

  return PortType();
}
KODE::Code ElementArgumentSerializer::generate() const
{
  Q_ASSERT(!mLocalVarName.isEmpty());
  Q_ASSERT(!mOutputVarName.isEmpty());
  const QString varAndMethodBefore = mOutputVarName + (mAppend ? QLatin1String(".append(") : QLatin1String(" = "));
  const QString varAndMethodAfter = mAppend ? QString::fromLatin1(")") : QString();

  KODE::Code block;
  // for debugging, add this:
  //block += "// type: " + type.qname() + " element:" + elementType.qname();

  //if ( name.localName() == "..." )
  //    qDebug() << "appendElementArg:" << name << "type=" << type << "isBuiltin=" << mTypeMap.isBuiltinType(type) << "isQualified=" << isQualified;
  if ( mTypeMap.isTypeAny( mType ) ) {
    block += QLatin1String("if (!") + mLocalVarName + QLatin1String(".isNull()) {");
    block.indent();
    block += varAndMethodBefore + mLocalVarName + varAndMethodAfter + QLatin1String(";") + COMMENT;
    block.unindent();
    block += "}";
  } else {
    const QName actualType = mType.isEmpty() ? mElementType : mType;
    const QString typeArgs = namespaceString(actualType.nameSpace()) + QLatin1String(", QString::fromLatin1(\"") + actualType.localName() + QLatin1String("\")");
    const bool isComplex = mTypeMap.isComplexType( mType, mElementType );
    const bool isPolymorphic = mTypeMap.isPolymorphic( mType, mElementType );

    if ( mAppend && mOmitIfEmpty ) {
      if ( mUsePointer ) {
          block += "if (" + mLocalVarName + ") {";
      } else {
          block += "if (!" + mLocalVarName + "_nil) {";
      }
      block.indent();
    }

    if ( isComplex ) {
      const QString op = (isPolymorphic || mUsePointer) ? "->" : ".";
      block += QLatin1String("KDSoapValue ") + mValueVarName + QLatin1Char('(') + mLocalVarName + op + QLatin1String("serialize(") + mNameArg + QLatin1String("));") + COMMENT;
    } else {
      if ( mTypeMap.isBuiltinType( mType, mElementType ) ) {
        const QString qtTypeName = mTypeMap.localType( mType, mElementType );
        const QString value = mTypeMap.serializeBuiltin( mType, mElementType, mLocalVarName, qtTypeName );

        block += QLatin1String("KDSoapValue ") + mValueVarName + QLatin1String("(" )+ mNameArg + QLatin1String(", ") + value + QLatin1String(", ") + typeArgs + QLatin1String(");") + COMMENT;
      } else {
        block += QLatin1String("KDSoapValue ") + mValueVarName + QLatin1String("(") + mNameArg + QLatin1String(", ") + mLocalVarName + QLatin1String(".serialize(), ") + typeArgs + QLatin1String(");") + COMMENT;
      }
    }
    if ( !mNameNamespace.isEmpty() )
      block += mValueVarName + QLatin1String(".setNamespaceUri(") + mNameNamespace + QLatin1String(");");
    if ( mIsQualified )
      block += mValueVarName + QLatin1String(".setQualified(true);");
    if ( mNillable )
      block += mValueVarName + QLatin1String(".setNillable(true);");
    if ( mAppend && mOmitIfEmpty ) { // omit empty children (testcase: MSExchange, no <ParentFolderIds/>)
      block += "if (!" + mValueVarName + ".isNil())";
    }
    block += varAndMethodBefore + mValueVarName + varAndMethodAfter + QLatin1String(";") + COMMENT;

    if ( mAppend && mOmitIfEmpty ) {
      block.unindent();
      block += "}";
    }
  }
  return block;
}
void ElementArgumentSerializer::setElementName( const QName &name )
{
  mNameArg = QLatin1String("QString::fromLatin1(\"") + name.localName() + QLatin1String("\")");
  mNameNamespace = namespaceString(name.nameSpace());
  mValueVarName = QLatin1String("_value") + upperlize(KODE::Style::makeIdentifier(name.localName()));
}
Beispiel #10
0
bool QName::operator == (const QName &qname) const {
    return (qname.nameSpace() == _nameSpace && qname.localName() == _localName);
}