SchemaDocumentation.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 "jptree.hpp"
  14. #include "jstring.hpp"
  15. #include "SchemaDocumentation.hpp"
  16. #include "DocumentationMarkup.hpp"
  17. using namespace CONFIGURATOR;
  18. void CDocumentation::dump(::std::ostream& cout, unsigned int offset) const
  19. {
  20. offset+= STANDARD_OFFSET_1;
  21. QuickOutHeader(cout, XSD_DOCUMENTATION_STR, offset);
  22. QUICK_OUT(cout, XSDXPath, offset);
  23. QUICK_OUT(cout,Documentation, offset);
  24. QuickOutFooter(cout, XSD_DOCUMENTATION_STR, offset);
  25. }
  26. CDocumentation* CDocumentation::load(CXSDNodeBase* pParentNode, const IPropertyTree *pSchemaRoot, const char* xpath)
  27. {
  28. if (pSchemaRoot == NULL)
  29. return NULL;
  30. if (pSchemaRoot->queryPropTree(xpath) == NULL)
  31. return NULL; // no documentation node
  32. StringBuffer strDoc;
  33. if (xpath && *xpath)
  34. strDoc.append(pSchemaRoot->queryPropTree(xpath)->queryProp(""));
  35. CDocumentation *pDocumentation = new CDocumentation(pParentNode, strDoc.str());
  36. pDocumentation->setXSDXPath(xpath);
  37. return pDocumentation;
  38. }
  39. void CDocumentation::getDocumentation(StringBuffer &strDoc) const
  40. {
  41. strDoc.appendf("%s%s%s", DM_PARA_BEGIN, this->getDocString(), DM_PARA_END);
  42. }