SchemaAnnotation.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2015 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #include <cassert>
  14. #include "XMLTags.h"
  15. #include "jptree.hpp"
  16. #include "SchemaAnnotation.hpp"
  17. #include "SchemaDocumentation.hpp"
  18. #include "SchemaAppInfo.hpp"
  19. using namespace CONFIGURATOR;
  20. #define StringBuffer ::StringBuffer
  21. #define IPropertyTree ::IPropertyTree
  22. CAnnotation* CAnnotation::load(CXSDNodeBase* pParentNode, const IPropertyTree *pSchemaRoot, const char* xpath)
  23. {
  24. assert(pSchemaRoot != nullptr);
  25. if (pSchemaRoot == nullptr)
  26. return nullptr;
  27. StringBuffer strXPathExt(xpath);
  28. strXPathExt.append("/").append(XSD_TAG_DOCUMENTATION);
  29. CDocumentation *pDocumentation = CDocumentation::load(nullptr, pSchemaRoot, strXPathExt.str());
  30. strXPathExt.setf("%s/%s", xpath, XSD_TAG_APP_INFO);
  31. CAppInfo *pAnnInfo = CAppInfo::load(nullptr, pSchemaRoot, strXPathExt.str());
  32. CAnnotation *pAnnotation = new CAnnotation(pParentNode, pDocumentation, pAnnInfo);
  33. pAnnotation->setXSDXPath(xpath);
  34. SETPARENTNODE(pDocumentation, pAnnotation);
  35. SETPARENTNODE(pAnnInfo, pAnnotation);
  36. return pAnnotation;
  37. }
  38. void CAnnotation::dump(::std::ostream& cout, unsigned int offset) const
  39. {
  40. offset+= STANDARD_OFFSET_1;
  41. quickOutHeader(cout, XSD_ANNOTATION_STR, offset);
  42. QUICK_OUT(cout, XSDXPath, offset);
  43. if (m_pAppInfo != nullptr)
  44. m_pAppInfo->dump(cout, offset);
  45. if (m_pDocumentation != nullptr)
  46. m_pDocumentation->dump(cout, offset);
  47. quickOutFooter(cout, XSD_ANNOTATION_STR, offset);
  48. }
  49. void CAnnotation::getDocumentation(StringBuffer &strDoc) const
  50. {
  51. if (m_pAppInfo != nullptr)
  52. m_pAppInfo->getDocumentation(strDoc);
  53. if (m_pDocumentation != nullptr)
  54. m_pDocumentation->getDocumentation(strDoc);
  55. }
  56. void CAnnotation::loadXMLFromEnvXml(const IPropertyTree *pEnvTree)
  57. {
  58. if (m_pAppInfo != nullptr)
  59. m_pAppInfo->loadXMLFromEnvXml(pEnvTree);
  60. if (m_pDocumentation != nullptr)
  61. m_pDocumentation->loadXMLFromEnvXml(pEnvTree);
  62. }