esdl2cpp_srvhpp.xslt 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. ##############################################################################
  4. # HPCC SYSTEMS software Copyright (C) 2015 HPCC Systems.
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License");
  7. # you may not use this file except in compliance with the License.
  8. # You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. ##############################################################################
  18. -->
  19. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  20. <xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
  21. <xsl:template match="esxdl">
  22. <xsl:variable name="servicename"><xsl:value-of select="EsdlService/@name"/></xsl:variable>
  23. <xsl:variable name="upperService"><xsl:value-of select="translate(EsdlService/@name, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/></xsl:variable>
  24. <xsl:text>#ifndef </xsl:text><xsl:value-of select="$upperService"/>SERVICE_HPP__
  25. <xsl:text>#define </xsl:text><xsl:value-of select="$upperService"/>SERVICE_HPP__
  26. #include "jlib.hpp"
  27. #include "<xsl:value-of select="$servicename"/>ServiceBase.hpp"
  28. using namespace std;
  29. <xsl:apply-templates select="EsdlService"/>
  30. #endif
  31. </xsl:template>
  32. <xsl:template match="EsdlService">
  33. <xsl:variable name="servicename" select="@name"/>
  34. class <xsl:value-of select="$servicename"/>Service : public <xsl:value-of select="$servicename"/>ServiceBase
  35. {
  36. public:
  37. <xsl:for-each select="EsdlMethod">
  38. <xsl:text> virtual </xsl:text><xsl:value-of select="@response_type"/>*<xsl:text> </xsl:text><xsl:value-of select="@name"/>(EsdlContext* context, <xsl:value-of select="@request_type"/><xsl:text>* request);
  39. </xsl:text>
  40. </xsl:for-each>
  41. <xsl:for-each select="EsdlMethod">
  42. <xsl:text> </xsl:text><xsl:text>virtual int </xsl:text><xsl:value-of select="@name"/>(const char* CtxStr, const char* ReqStr, StringBuffer&amp; RespStr)
  43. {
  44. return <xsl:value-of select="$servicename"/>ServiceBase::<xsl:value-of select="@name"/>(CtxStr, ReqStr, RespStr);
  45. }<xsl:text>
  46. </xsl:text>
  47. </xsl:for-each>
  48. <xsl:text>};
  49. </xsl:text>
  50. </xsl:template>
  51. </xsl:stylesheet>