Return-Path: Delivered-To: apmail-ws-axis-cvs-archive@www.apache.org Received: (qmail 13848 invoked from network); 4 Apr 2006 15:36:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 4 Apr 2006 15:36:32 -0000 Received: (qmail 32368 invoked by uid 500); 4 Apr 2006 15:36:28 -0000 Delivered-To: apmail-ws-axis-cvs-archive@ws.apache.org Received: (qmail 32282 invoked by uid 500); 4 Apr 2006 15:36:28 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 32137 invoked by uid 99); 4 Apr 2006 15:36:27 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Apr 2006 08:36:26 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 04 Apr 2006 08:36:24 -0700 Received: (qmail 13246 invoked by uid 65534); 4 Apr 2006 15:36:03 -0000 Message-ID: <20060404153603.13245.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r391340 [3/3] - in /webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws: ./ cpp/ cpp/literal/ Date: Tue, 04 Apr 2006 15:36:00 -0000 To: axis-cvs@ws.apache.org From: dicka@apache.org X-Mailer: svnmailer-1.0.7 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubHeaderWriter.java URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubHeaderWriter.java?rev=391340&r1=391339&r2=391340&view=diff ============================================================================== --- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubHeaderWriter.java (original) +++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubHeaderWriter.java Tue Apr 4 08:35:58 2006 @@ -245,7 +245,8 @@ try { writer.write("#include \n"); - writer.write("#include \n"); + writer.write("#include \n"); + writer.write("#include \n"); writer.write("#include \n"); writer.write("AXIS_CPP_NAMESPACE_USE\n"); Type atype; Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubWriter.java URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubWriter.java?rev=391340&r1=391339&r2=391340&view=diff ============================================================================== --- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubWriter.java (original) +++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubWriter.java Tue Apr 4 08:35:58 2006 @@ -83,8 +83,7 @@ { try { - writer - .write(classname + writer.write(classname + "::" + classname + "(const char* pchEndpointUri, AXIS_PROTOCOL_TYPE eProtocol)\n:Stub(pchEndpointUri, eProtocol)\n{\n"); @@ -166,10 +165,6 @@ } writer.write("#include \n"); writer.write ("#include \n\n"); - - writer.write("#include \n\n"); // for memcpy - writer.write("using namespace std;\n\n "); - } catch (IOException e) { throw new WrapperFault(e); @@ -779,14 +774,15 @@ writer.write("\t\tint iExceptionCode = e.getExceptionCode();\n\n"); writer.write("\t\tif( AXISC_NODE_VALUE_MISMATCH_EXCEPTION != iExceptionCode)\n"); writer.write("\t\t{\n"); - writer.write("\t\t\tthrow SoapFaultException( e);\n"); + writer.write("\t\t\tm_pCall->unInitialize();\n"); + writer.write("\t\t\tthrow;\n"); writer.write("\t\t}\n\n"); //ISoapFault* pSoapFault = (ISoapFault*) m_pCall->checkFault("Fault", // "http://localhost/axis/MathOps"); - writer.write("\t\tISoapFault *\tpSoapFault = (ISoapFault *) m_pCall->checkFault( \"Fault\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"" + writer.write("\t\tISoapFault * pSoapFault = (ISoapFault *)\n\t\t\tm_pCall->checkFault(\"Fault\",\"" + wscontext.getWrapInfo().getTargetEndpointURI() + "\");\n\n"); - writer.write("\t\tif( pSoapFault)\n"); + writer.write("\t\tif(pSoapFault)\n"); writer.write("\t\t{\n"); //writer.write("\t\t\tpcCmplxFaultName = // pSoapFault->getCmplxFaultObjectName();\n"); @@ -800,8 +796,30 @@ int j = 0; if (!paramsFault.hasNext()) { - writer.write("\t\t\tm_pCall->unInitialize();\n\n"); - writer.write("\t\t\tthrow SoapFaultException( e);\n"); + writer.write("\t\t\tconst char *detail = pSoapFault->getSimpleFaultDetail();\n"); + writer.write("\t\t\tbool deleteDetail=false;\n\n"); + writer.write("\t\t\tif (NULL==detail || 0==strlen(detail))\n"); + writer.write("\t\t\t{\n"); + writer.write("\t\t\t\tdetail=m_pCall->getFaultAsXMLString();\n"); + writer.write("\t\t\t\tif (NULL==detail)\n"); + writer.write("\t\t\t\t{\n"); + writer.write("\t\t\t\t\tdetail=\"\";\n"); + writer.write("\t\t\t\t}\n"); + writer.write("\t\t\t\telse\n"); + writer.write("\t\t\t\t{\n"); + writer.write("\t\t\t\t\tdeleteDetail=true;\n"); + writer.write("\t\t\t\t}\n"); + writer.write("\t\t\t}\n\n"); + writer.write("\t\t\tOtherFaultException ofe(pSoapFault->getFaultcode(),\n"); + writer.write("\t\t\t\tpSoapFault->getFaultstring(), pSoapFault->getFaultactor(),\n"); + writer.write("\t\t\t\tdetail, iExceptionCode);\n\n"); + writer.write("\t\t\tif (deleteDetail && NULL!=detail)\n"); + writer.write("\t\t\t{\n"); + writer.write("\t\t\t\tAxis::AxisDelete( (void *) const_cast(detail), XSD_STRING);\n"); + writer.write("\t\t\t}\n\n"); + writer.write("\t\t\tm_pCall->unInitialize();\n"); + writer.write("\t\t\tdelete pSoapFault;\n"); + writer.write("\t\t\tthrow ofe;\n"); } else { @@ -842,13 +860,40 @@ { writer.write("\t\t\telse\n"); writer.write("\t\t\t{\n"); - writer.write("\t\t\t\tm_pCall->unInitialize();\n\n"); - writer.write("\t\t\t\tthrow SoapFaultException(e);\n"); + writer.write("\t\t\t\tconst char *detail = pSoapFault->getSimpleFaultDetail();\n"); + writer.write("\t\t\t\tbool deleteDetail=false;\n\n"); + writer.write("\t\t\t\tif (NULL==detail || 0==strlen(detail))\n"); + writer.write("\t\t\t\t{\n"); + writer.write("\t\t\t\t\tdetail=m_pCall->getFaultAsXMLString();\n"); + writer.write("\t\t\t\t\tif (NULL==detail)\n"); + writer.write("\t\t\t\t\t{\n"); + writer.write("\t\t\t\t\t\tdetail=\"\";\n"); + writer.write("\t\t\t\t\t}\n"); + writer.write("\t\t\t\t\telse\n"); + writer.write("\t\t\t\t\t{\n"); + writer.write("\t\t\t\t\t\tdeleteDetail=true;\n"); + writer.write("\t\t\t\t\t}\n"); + writer.write("\t\t\t\t}\n\n"); + writer.write("\t\t\t\tOtherFaultException ofe(pSoapFault->getFaultcode(),\n"); + writer.write("\t\t\t\t\tpSoapFault->getFaultstring(), pSoapFault->getFaultactor(),\n"); + writer.write("\t\t\t\t\tdetail, iExceptionCode);\n\n"); + writer.write("\t\t\t\tif (deleteDetail && NULL!=detail)\n"); + writer.write("\t\t\t\t{\n"); + writer.write("\t\t\t\t\tAxis::AxisDelete( (void *) const_cast(detail), XSD_STRING);\n"); + writer.write("\t\t\t\t}\n\n"); + writer.write("\t\t\t\tm_pCall->unInitialize();\n"); + writer.write("\t\t\t\tdelete pSoapFault;\n"); + writer.write("\t\t\t\tthrow ofe;\n"); writer.write("\t\t\t}\n"); } writer.write("\t\t}\n"); - writer.write("\t\telse\n\t\t{\n\t\t\tthrow;\n\t\t}\n"); + writer.write("\t\telse\n"); + writer.write("\t\t{\n"); + writer.write("\t\t\tm_pCall->unInitialize();\n"); + writer.write("\t\t\tdelete pSoapFault;\n"); + writer.write("\t\t\tthrow;\n"); + writer.write("\t\t}\n"); writer.write("\t}\n"); writer.write("}\n"); } Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ParamCPPFileWriter.java URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ParamCPPFileWriter.java?rev=391340&r1=391339&r2=391340&view=diff ============================================================================== --- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ParamCPPFileWriter.java (original) +++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ParamCPPFileWriter.java Tue Apr 4 08:35:58 2006 @@ -47,26 +47,32 @@ {} protected void writeDestructors() throws WrapperFault {} + protected abstract void writeRestrictionCheckerFunction() + throws WrapperFault; public void writeSource() throws WrapperFault { try { - this.writer = - new BufferedWriter(new FileWriter(getFilePath(), false)); + this.writer = new BufferedWriter(new FileWriter(getFilePath(), false)); writeClassComment(); writePreprocessorStatements(); - writeGlobalCodes(); - writeAttributes(); - writeConstructors(); - writeDestructors(); - writeMethods(); - //cleanup + + if (type.isSimpleType()) + writeRestrictionCheckerFunction(); + else + { + writeGlobalCodes(); + writeAttributes(); + writeConstructors(); + writeDestructors(); + writeMethods(); + } + writer.flush(); writer.close(); if (WSDL2Ws.verbose) - System.out.println( - getFilePath().getAbsolutePath() + " created....."); + System.out.println(getFilePath().getAbsolutePath() + " created....."); } catch (IOException e) { @@ -80,42 +86,14 @@ protected abstract void writeGlobalCodes() throws WrapperFault; protected File getFilePath() throws WrapperFault { - return this.getFilePath(false); - } + classname = CUtils.sanitiseClassName( classname); - protected File getFilePath(boolean useServiceName) throws WrapperFault - { - String targetOutputLocation = - this.wscontext.getWrapInfo().getTargetOutputLocation(); + String targetOutputLocation = this.wscontext.getWrapInfo().getTargetOutputLocation(); if (targetOutputLocation.endsWith("/")) - targetOutputLocation = - targetOutputLocation.substring( - 0, - targetOutputLocation.length() - 1); + targetOutputLocation = targetOutputLocation.substring(0,targetOutputLocation.length() - 1); new File(targetOutputLocation).mkdirs(); - - String fileName = - targetOutputLocation + "/" + classname + CUtils.CPP_CLASS_SUFFIX; - - if (useServiceName) - { - String serviceName = this.wscontext.getSerInfo().getServicename(); - fileName = - targetOutputLocation - + "/" - + serviceName - + "_" - + classname - + CUtils.CPP_CLASS_SUFFIX; - this.wscontext.addGeneratedFile( - serviceName + "_" + classname + CUtils.CPP_CLASS_SUFFIX); - } - else - { - this.wscontext.addGeneratedFile( - classname + CUtils.CPP_CLASS_SUFFIX); - } - + String fileName = targetOutputLocation + "/" + this.classname + CUtils.CPP_CLASS_SUFFIX; + this.wscontext.addGeneratedFile(classname + CUtils.CPP_CLASS_SUFFIX); return new File(fileName); } @@ -123,14 +101,9 @@ { try { - writer.write( - "#include \"" - + this.classname - + CUtils.CPP_HEADER_SUFFIX - + "\"\n"); writer.write("#include \n"); - writer.write("#include \n\n"); - + writer.write("#include \n\n"); + writer.write("#include \"" + this.classname + CUtils.CPP_HEADER_SUFFIX + "\"\n"); } catch (IOException e) { Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ParmHeaderFileWriter.java URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ParmHeaderFileWriter.java?rev=391340&r1=391339&r2=391340&view=diff ============================================================================== --- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ParmHeaderFileWriter.java (original) +++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ParmHeaderFileWriter.java Tue Apr 4 08:35:58 2006 @@ -29,355 +29,611 @@ import java.io.IOException; import java.util.HashSet; import java.util.Iterator; +import java.util.Vector; +import javax.xml.namespace.QName; + +import org.apache.axis.wsdl.symbolTable.TypeEntry; import org.apache.axis.wsdl.wsdl2ws.CUtils; import org.apache.axis.wsdl.wsdl2ws.ParamWriter; import org.apache.axis.wsdl.wsdl2ws.WSDL2Ws; import org.apache.axis.wsdl.wsdl2ws.WrapperFault; -import org.apache.axis.wsdl.wsdl2ws.info.ElementInfo; import org.apache.axis.wsdl.wsdl2ws.info.Type; import org.apache.axis.wsdl.wsdl2ws.info.WebServiceContext; -public class ParmHeaderFileWriter extends ParamWriter { - public ParmHeaderFileWriter(WebServiceContext wscontext, Type type) - throws WrapperFault { - super(wscontext, type); - } - - public void writeSource() throws WrapperFault { - try { - this.writer = new BufferedWriter(new FileWriter(getFilePath(), - false)); - writeClassComment(); - // if this headerfile not defined define it - this.writer.write("#if !defined(__" + classname.toUpperCase() + "_" - + getFileType().toUpperCase() + "_H__INCLUDED_)\n"); - this.writer.write("#define __" + classname.toUpperCase() + "_" - + getFileType().toUpperCase() + "_H__INCLUDED_\n\n"); - writePreprocessorStatements(); - - this.writer.write("class " + classname); - if (this.type.isFault()) - this.writer.write(" : public SoapFaultException"); - this.writer.write("\n{\n"); - - writeAttributes(); - writeGetSetMethods(); - writeConstructors(); - writeDestructors(); - this.writer.write("};\n\n"); - this.writer.write("#endif /* !defined(__" + classname.toUpperCase() - + "_" + getFileType().toUpperCase() + "_H__INCLUDED_)*/\n"); - writer.flush(); - writer.close(); - if (WSDL2Ws.verbose) { - System.out.println(getFilePath().getAbsolutePath() - + " created....."); - } - } catch (IOException e) { - e.printStackTrace(); - throw new WrapperFault(e); - } - } - - protected void writeAttributes() throws WrapperFault { - int anyCounter = 0; - if (type.isArray()) - return; - try { - writer.write("public:\n"); - for (int i = 0; i < attribs.length; i++) { - //chek if attrib name is same as class name and if so change - if (classname.equals(attribs[i].getParamName())) { - attribs[i].setParamName("m_" + attribs[i].getParamName()); - } - // FJP Nillable vv - if (isElementNillable(i) || attribs[i].isArray()) { - - if(attribs[i].isAnyType()){ - anyCounter += 1; - writer - .write("\t" - + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) - + " *\t" + attribs[i].getParamName() - + Integer.toString(anyCounter) - + ";\n"); - - } - - else{ - writer - .write("\t" - + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) - + " *\t" + attribs[i].getParamName() - + ";\n"); - } - - } else { - // FJP Nillable ^^ - - if(attribs[i].isAnyType()){ - anyCounter += 1; - writer - .write("\t" - + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) - + " \t" + attribs[i].getParamName() - + Integer.toString(anyCounter) - + ";\n"); - - } - - else{ - - writer - .write("\t" - + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) - + "\t" + attribs[i].getParamName() + ";\n"); - } - } - } - } catch (IOException e) { - throw new WrapperFault(e); - } - } - - /** - * Dushshantha: This method writes getters and setters of the attributes. - */ - protected void writeGetSetMethods() throws WrapperFault { - int anyCounter = 0; - if (type.isArray()) { - return; - } - try { - for (int i = 0; i < attribs.length; i++) { - // FJP Nillable vv - if (i == 0) { - writer.write("\n"); - } - - String methodName = attribs[i].getParamNameWithoutSymbols(); - - if( methodName.endsWith( "_")) +public class ParmHeaderFileWriter extends ParamWriter +{ + public ParmHeaderFileWriter(WebServiceContext wscontext, Type type) + throws WrapperFault + { + super(wscontext, type); + } + + public void writeSource() throws WrapperFault + { + try + { + this.writer = new BufferedWriter(new FileWriter(getFilePath(), false)); + writeClassComment(); + // if this headerfile not defined define it + this.writer.write("#if !defined(__" + classname.toUpperCase() + "_" + + getFileType().toUpperCase() + "_H__INCLUDED_)\n"); + this.writer.write("#define __" + classname.toUpperCase() + "_" + + getFileType().toUpperCase() + "_H__INCLUDED_\n\n"); + + if (type.isSimpleType()) + writeSimpleTypeWithEnumerations(); + else + { + writePreprocessorStatements(); + + classname = CUtils.sanitiseClassName( classname); + + this.writer.write("class STORAGE_CLASS_INFO " + classname); + if (this.type.isFault()) + this.writer.write(" : public SoapFaultException"); + this.writer.write("\n{\n"); + writeAttributes(); + writeGetSetMethods(); + writeConstructors(); + writeDestructors(); + writeDeepCopyFlags(); + this.writer.write("};\n\n"); + } + this.writer.write("#endif /* !defined(__" + classname.toUpperCase() + + "_" + getFileType().toUpperCase() + "_H__INCLUDED_)*/\n"); + writer.flush(); + writer.close(); + if (WSDL2Ws.verbose) + System.out.println(getFilePath().getAbsolutePath() + " created....."); + } + catch (IOException e) + { + e.printStackTrace(); + throw new WrapperFault(e); + } + } + + /** + * + */ + private void writeDeepCopyFlags() throws WrapperFault + { + if (type.isArray()) + return; + + if (attribs.length == 0) + return; + + try + { + boolean foundDeepCopyType = false; + for (int i = 0 ; i < attribs.length ; i++) + { + Type type = attribs[i].getType(); + boolean isPointerType = false; + + if (type.isSimpleType()) + isPointerType = CUtils.isPointerType(CUtils.getclass4qname(type.getBaseType())); + else + isPointerType = CUtils.isPointerType(getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i])); + + if ((attribs[i].isSimpleType() + || attribs[i].getType().isSimpleType()) + && !attribs[i].isArray() + && (isElementNillable(i) + || isElementOptional(i) + || isPointerType + || attribs[i].getChoiceElement() + || attribs[i].getAllElement())) + { + if (!foundDeepCopyType) + { + writer.write("\nprivate:\n"); + foundDeepCopyType = true; + } + writer.write("\tbool __axis_deepcopy_" + attribs[i].getParamNameWithoutSymbols() + ";\n"); + } + } + } + catch (IOException e) + { + throw new WrapperFault(e); + } + } + + protected void writeSimpleTypeWithEnumerations() throws WrapperFault + { + try + { + writer.write("#include \n"); + writer.write("#include \n"); + writer.write("AXIS_CPP_NAMESPACE_USE \n\n"); + + Vector restrictionData = type.getEnumerationdata(); + if (restrictionData == null) + return; + + TypeEntry baseEType = (TypeEntry) restrictionData.firstElement(); + QName baseType = baseEType.getQName(); + if (!CUtils.isSimpleType(baseType)) + return; + + String langTypeName = CUtils.getclass4qname(baseType); + writer.write("typedef "); + if (CUtils.isPointerType(CUtils.getclass4qname(baseType)) + || "xsd__base64Binary".equals(CUtils.getclass4qname(baseType)) + || "xsd__hexBinary".equals(CUtils.getclass4qname(baseType))) + { + writer.write(langTypeName + " " + classname + ";\n"); + writer.write("typedef " + langTypeName + "_Array " + classname + "_Array;\n"); + + for (int i = 1; i < restrictionData.size(); i++) + { + QName value = (QName) restrictionData.elementAt(i); + if ("enumeration".equals(value.getLocalPart())) + { + writer.write("static const " + classname + " " + + classname + "_" + value.getNamespaceURI() + + " = \"" + value.getNamespaceURI() + "\";\n"); + } + else if ("maxLength".equals(value.getLocalPart())) + { + writer.write("static const int " + classname + + "_MaxLength = " + value.getNamespaceURI() + ";\n"); + } + else if ("minLength".equals(value.getLocalPart())) + { + writer.write("static const int " + classname + + "_MinLength = " + value.getNamespaceURI() + ";\n"); + } + } + } + else if ("int".equals(baseType.getLocalPart())) + { + if (restrictionData.size() > 1) + { + //there are enumerations or min/maxInclusive + boolean isEnum = false; + boolean hasRestrictionItems = false; + for (int i = 1; i < restrictionData.size(); i++) + { + QName value = (QName) restrictionData.elementAt(i); + if ("enumeration".equals(value.getLocalPart())) + { + isEnum = true; + if (i > 1) + writer.write(", "); + else + writer.write(" enum { "); + + writer.write("ENUM" + classname.toUpperCase() + "_" + + value.getNamespaceURI() + "=" + + value.getNamespaceURI()); + } + else if ("minInclusive".equals(value.getLocalPart())) + { + hasRestrictionItems = true; + if (i <= 1) + writer.write(langTypeName + " " + classname + ";\n"); + + writer.write("static const int " + classname + + "_MinInclusive = " + value.getNamespaceURI() + ";\n"); + } + else if ("maxInclusive".equals(value.getLocalPart())) + { + hasRestrictionItems = true; + if (i <= 1) + writer.write(langTypeName + " " + classname + ";\n"); + + writer.write("static const int " + classname + + "_MaxInclusive = " + value.getNamespaceURI() + ";\n"); + } + } + + if (isEnum) + writer.write("} " + classname + ";\n"); + else if (!hasRestrictionItems) + writer.write(langTypeName + " " + classname + ";\n"); + } + else + writer.write(langTypeName + " " + classname + ";\n"); + } + else + { + writer.write(langTypeName + " " + classname + ";\n"); + for (int i = 1; i < restrictionData.size(); i++) + { + QName value = (QName) restrictionData.elementAt(i); + if ("enumeration".equals(value.getLocalPart())) + { + writer.write("static const " + classname + " " + + classname + "_" + value.getNamespaceURI() + + " = \"" + value.getNamespaceURI() + "\";\n"); + } + } + } + } + catch (IOException e) + { + throw new WrapperFault(e); + } + } + + protected void writeAttributes() throws WrapperFault + { + int anyCounter = 0; + + if (type.isArray()) + return; + + try + { + writer.write("public:\n"); + for (int i = 0; i < attribs.length; i++) + { + attribs[i].setParamName( CUtils.sanitiseAttributeName( classname, attribs[i].getParamName())); + + if (isElementNillable(i) + || attribs[i].isArray() + || isElementOptional(i) + && !attribs[i].getAllElement()) + { + if(attribs[i].isAnyType()) + { + anyCounter += 1; + writer.write("\t" + + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) + + " * " + attribs[i].getParamName() + + Integer.toString(anyCounter) + + ";\n"); + } + else if( attribs[i].isArray()) + { + String paramName = getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]); + if (!paramName.endsWith("*")) + paramName += " *"; + + if (!attribs[i].isSimpleType() && attribs[i].getType().isSimpleType()) + writer.write("\t"); + else + writer.write("\tclass "); + + writer.write(paramName + " " + attribs[i].getParamName() + ";\n"); + } + else if(attribs[i].getChoiceElement() && !isElementNillable(i)) + writer.write("\t" + + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) + + " " + attribs[i].getParamName() + + ";\n"); + else + writer.write("\t" + + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) + + " * " + attribs[i].getParamName() + + ";\n"); + } + else if(attribs[i].getAllElement() || attribs[i].getChoiceElement() ) + { + writer.write("\t" + + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) + + " " + attribs[i].getParamName() + + ";\n"); + } + else if(attribs[i].isAnyType()) + { + anyCounter += 1; + writer.write("\t" + + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) + + " " + attribs[i].getParamName() + + Integer.toString(anyCounter) + + ";\n"); + } + + else + { + writer.write("\t" + + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) + + " " + attribs[i].getParamNameWithoutSymbols() + + ";\n"); + } + } + + if (extensionBaseAttrib != null && + getCorrectParmNameConsideringArraysAndComplexTypes(extensionBaseAttrib) != null) + { + writer.write("\t" + + getCorrectParmNameConsideringArraysAndComplexTypes(extensionBaseAttrib) + + " " + + extensionBaseAttrib.getParamNameWithoutSymbols() + ";\n"); + } + } + catch (IOException e) + { + throw new WrapperFault(e); + } + } + + /** + * Dushshantha: This method writes getters and setters of the attributes. + */ + protected void writeGetSetMethods() throws WrapperFault + { + int anyCounter = 0; + + if (type.isArray()) + return; + + try + { + for (int i = 0; i < attribs.length; i++) + { + String methodName = attribs[i].getParamNameWithoutSymbols(); + + if( methodName.endsWith( "_")) { String localMethodName = methodName.substring( 0, methodName.length() - 1); if( localMethodName.equals( classname)) - { methodName = localMethodName; + } + + if (isElementNillable(i) || attribs[i].isArray() || isElementOptional(i)) + { + if ( attribs[i].isAnyType()) + { + anyCounter += 1; + writer.write("\t" + + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) + + " * get" + + methodName + Integer.toString(anyCounter) + "();\n"); + + writer.write("\t" + + "void set" + methodName + + Integer.toString(anyCounter) + + "(" + + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) + + " * pInValue);\n\n"); + } + else + { + if(attribs[i].getAllElement() || attribs[i].getChoiceElement()) + { + String paramName = getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]); + if (!paramName.endsWith("*")) + paramName += " *"; + + if (attribs[i].isArray()) + { + writer.write( "\n\t" + paramName + " get" + methodName + "();\n"); + + writer.write( "\t" + "void set" + methodName + "(" + paramName + " pInValue"); + } + else if (isElementNillable(i)) + { + writer.write( "\n\t" + + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) + + " * get" + methodName + "();\n"); + + writer.write( "\t" + + "void set" + methodName + "(" + + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) + + " * pInValue"); + } + else + { + writer.write( "\n\t" + + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) + + " get" + methodName + "();\n"); + + writer.write( "\t" + + "void set" + methodName + "(" + + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) + + " pInValue"); + } + } + else + { + writer.write( "\n\t" + + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) + + " * get" + methodName + "();\n"); + + writer.write( "\t" + + "void set" + methodName + "(" + + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) + + " * pInValue"); + } + + if ((isElementNillable(i) || isElementOptional(i) + || attribs[i].getAllElement() || attribs[i].getChoiceElement() ) + && !attribs[i].isArray()) + writer.write(", bool deep = true"); + + writer.write(");\n"); } } - - if (isElementNillable(i) || attribs[i].isArray()) { - if ( attribs[i].isAnyType()){ - anyCounter += 1; - - writer - .write("\t" - + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) - + " * get" - + methodName - + Integer.toString(anyCounter) - + "();\n"); - - writer - .write("\t" - + "void set" - + methodName - + Integer.toString(anyCounter) - + "(" - + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) - + " * pInValue);\n\n"); - } - else { - writer - .write("\t" - + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) - + " * get" - + methodName - + "();\n"); - - writer - .write("\t" - + "void set" - + methodName - + "(" - + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) - + " * pInValue);\n\n"); - - } - - } else { - // FJP Nillable ^^ - - if ( attribs[i].isAnyType()){ - anyCounter += 1; - writer - .write("\t" - + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) - + " get" - + methodName - + Integer.toString(anyCounter) - + "();\n"); - - writer - .write("\t" - + "void set" - + methodName - + Integer.toString(anyCounter) - + "(" - + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) - + " InValue);\n\n"); - } - else { - - - - /** - * Dushshantha: Write setter - */ - - writer - .write("\t" - + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) - + " get" - + methodName - + "();\n"); - - /** - * Dushshantha: Write getter - */ - - writer - .write("\t" - + "void set" - + methodName - + "(" - + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) - + " InValue);\n\n"); - } - } - } - } catch (IOException e) { - throw new WrapperFault(e); - } - } - - protected void writeConstructors() throws WrapperFault { - try { - writer.write("\t" + classname + "();\n"); - writeReset(); - } catch (IOException e) { - throw new WrapperFault(e); - } - } + else if ( attribs[i].isAnyType()) + { + anyCounter += 1; + writer.write("\t" + + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) + + " get" + methodName + Integer.toString(anyCounter) + "();\n"); + + writer.write("\t" + + "void set" + methodName + Integer.toString(anyCounter) + "(" + + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) + + " InValue);\n\n"); + } + else + { + writer.write("\n\t" + + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) + + " get" + methodName + "();\n"); + + writer.write("\t" + + "void set" + methodName + "(" + + getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]) + + " InValue"); + + Type type = attribs[i].getType(); + boolean isPointerType = false; + + if (type.isSimpleType()) + isPointerType = CUtils.isPointerType(CUtils.getclass4qname(type.getBaseType())); + else + isPointerType = CUtils.isPointerType(getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i])); + + if ( (attribs[i].getAllElement() || attribs[i].getChoiceElement() || isPointerType) + && (attribs[i].isSimpleType() || attribs[i].getType().isSimpleType())) + writer.write(", bool deep = true"); + + writer.write(");\n"); + } + } + } + catch (IOException e) + { + throw new WrapperFault(e); + } + } + + protected void writeConstructors() throws WrapperFault + { + try + { + writer.write("\n\t" + classname + "();\n"); + writer.write("\t" + classname + "(const " + classname + " & original);\n"); + writeReset(); + } + catch (IOException e) + { + throw new WrapperFault(e); + } + } protected void writeReset() throws WrapperFault { try { - writer.write("\tvoid reset();\n"); - } catch (IOException e) + writer.write("\n\tvoid reset();\n"); + } + catch (IOException e) + { + throw new WrapperFault(e); + } + } + + protected void writeDestructors() throws WrapperFault + { + try + { + if (this.type.isFault()) + writer.write("\tvirtual ~" + classname + "() throw();\n"); + else + writer.write("\tvirtual ~" + classname + "();\n"); + } + catch (IOException e) { throw new WrapperFault(e); } } - protected void writeDestructors() throws WrapperFault { - try { - if (this.type.isFault()) - writer.write("\tvirtual ~" + classname + "() throw();\n"); - else - writer.write("\tvirtual ~" + classname + "();\n"); - //damitha added virtual - } catch (IOException e) { - throw new WrapperFault(e); - } - } - - protected void writeMethods() throws WrapperFault { - } - - protected File getFilePath() throws WrapperFault { - return this.getFilePath(false); - } - - protected File getFilePath(boolean useServiceName) throws WrapperFault { - String targetOutputLocation = this.wscontext.getWrapInfo() - .getTargetOutputLocation(); - if (targetOutputLocation.endsWith("/")) { - targetOutputLocation = targetOutputLocation.substring(0, - targetOutputLocation.length() - 1); - } - new File(targetOutputLocation).mkdirs(); - - String fileName = targetOutputLocation + "/" + classname - + CUtils.CPP_HEADER_SUFFIX; - - if (useServiceName) { - fileName = targetOutputLocation + "/" - + this.wscontext.getSerInfo().getServicename() + "_" - + classname + CUtils.CPP_HEADER_SUFFIX; - } - - return new File(fileName); - } - - /* - * (non-Javadoc) - * - * @see org.apache.axis.wsdl.wsdl2ws.cpp.BasicFileWriter#writePreprocssorStatements() - */ - protected void writePreprocessorStatements() throws WrapperFault { - try { - writer.write("#include \n"); - writer.write("#include \n"); - if (this.type.isFault()) { - writer.write("#include \n"); - writer.write("using namespace std;\n"); - } - writer.write("AXIS_CPP_NAMESPACE_USE \n\n"); - HashSet typeSet = new HashSet(); - for (int i = 0; i < attribs.length; i++) { - if ((attribs[i].isArray()) && (!attribs[i].isSimpleType())) { - typeSet.add(attribs[i].getTypeName() + "_Array"); - } - if (!(attribs[i].isSimpleType() || attribs[i].isAnyType())) { - typeSet.add(attribs[i].getTypeName()); - } - - } - Iterator itr = typeSet.iterator(); - while (itr.hasNext()) { - writer.write("#include \"" + itr.next().toString() - + CUtils.CPP_HEADER_SUFFIX + "\"\n"); - } - - //Local name and the URI for the type - writer.write("/*Local name and the URI for the type*/\n"); - writer.write("static const char* Axis_URI_" + classname + " = \"" - + type.getName().getNamespaceURI() + "\";\n"); - writer.write("static const char* Axis_TypeName_" + classname - + " = \"" + type.getName().getLocalPart() + "\";\n\n"); - - // Define class to avoid compilation issue (cycle in includes). - typeSet = new HashSet(); - for (int i = 0; i < attribs.length; i++) { - //if (!attribs[i].isArray() && !attribs[i].isSimpleType()) - if (!attribs[i].isArray() && !attribs[i].isSimpleType() - && !attribs[i].isAnyType()) { - typeSet.add(attribs[i].getTypeName()); - } - } - itr = typeSet.iterator(); - while (itr.hasNext()) { - writer.write("class " + itr.next().toString() + ";\n"); - } - } catch (IOException e) { - throw new WrapperFault(e); - } - } - - protected String getFileType() { - return "Param"; - } + protected void writeMethods() throws WrapperFault + { + } + + protected File getFilePath() throws WrapperFault + { + return this.getFilePath(false); + } + + protected File getFilePath(boolean useServiceName) throws WrapperFault + { + String targetOutputLocation = this.wscontext.getWrapInfo().getTargetOutputLocation(); + if (targetOutputLocation.endsWith("/")) + targetOutputLocation = targetOutputLocation.substring(0,targetOutputLocation.length() - 1); + + new File(targetOutputLocation).mkdirs(); + + String fileName = targetOutputLocation + "/" + classname + CUtils.CPP_HEADER_SUFFIX; + + if (useServiceName) + { + fileName = targetOutputLocation + "/" + + this.wscontext.getSerInfo().getServicename() + "_" + + classname + CUtils.CPP_HEADER_SUFFIX; + } + + return new File(fileName); + } + + /* + * (non-Javadoc) + * + * @see org.apache.axis.wsdl.wsdl2ws.cpp.BasicFileWriter#writePreprocssorStatements() + */ + protected void writePreprocessorStatements() throws WrapperFault + { + try + { + writer.write("#include \n"); + writer.write("#include \n"); + + if (this.type.isFault()) + { + writer.write("#include \n"); + writer.write("using namespace std;\n"); + } + + writer.write("AXIS_CPP_NAMESPACE_USE \n\n"); + HashSet typeSet = new HashSet(); + for (int i = 0; i < attribs.length; i++) + { + if ((attribs[i].isArray()) && + !(attribs[i].isSimpleType() || attribs[i].getType().isSimpleType())) + typeSet.add(attribs[i].getTypeName() + "_Array"); + + if (!(attribs[i].isSimpleType() || attribs[i].isAnyType())) + typeSet.add(attribs[i].getTypeName()); + } + + Iterator itr = typeSet.iterator(); + while (itr.hasNext()) + { + writer.write("#include \"" + itr.next().toString() + CUtils.CPP_HEADER_SUFFIX + "\"\n"); + } + + //Local name and the URI for the type + writer.write("/*Local name and the URI for the type*/\n"); + writer.write("static const char* Axis_URI_" + classname + " = \"" + + type.getName().getNamespaceURI() + "\";\n"); + writer.write("static const char* Axis_TypeName_" + classname + + " = \"" + type.getName().getLocalPart() + "\";\n\n"); + + // Define class to avoid compilation issues (cycle in includes). + // This is a must for complex wsdl files. + typeSet = new HashSet(); + for (int i = 0; i < attribs.length; i++) + { + if (!attribs[i].isArray() && + !(attribs[i].isSimpleType() || attribs[i].getType().isSimpleType()) + && !attribs[i].isAnyType()) + typeSet.add(attribs[i].getTypeName()); + } + + itr = typeSet.iterator(); + while (itr.hasNext()) + { + writer.write("class " + itr.next().toString() + ";\n"); + } + + } + catch (IOException e) + { + throw new WrapperFault(e); + } + } + + protected String getFileType() + { + return "Param"; + } }