XSDSchemaParser.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2017 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. #ifndef _CONFIG2_XSDCONFIGPARSER_HPP_
  14. #define _CONFIG2_XSDCONFIGPARSER_HPP_
  15. #include <string>
  16. #include <memory>
  17. #include <map>
  18. #include <boost/property_tree/ptree.hpp>
  19. #include <boost/property_tree/xml_parser.hpp>
  20. #include "SchemaParser.hpp"
  21. #include "SchemaTypeIntegerLimits.hpp"
  22. #include "SchemaTypeStringLimits.hpp"
  23. namespace pt = boost::property_tree;
  24. class XSDSchemaParser : public SchemaParser
  25. {
  26. public:
  27. XSDSchemaParser(std::shared_ptr<SchemaItem> &pConfig) :
  28. SchemaParser(pConfig) { }
  29. virtual ~XSDSchemaParser() { };
  30. protected:
  31. XSDSchemaParser() { };
  32. virtual bool doParse(const std::string &configPath, const std::string &masterConfigFile, const std::map<std::string, std::string> &cfgParms) override;
  33. void parseXSD(const pt::ptree &tree);
  34. void parseXSD(const std::string &fullyQualifiedPath);
  35. std::string getXSDAttributeValue(const pt::ptree &tree, const std::string &attriName, bool throwIfNotPresent=true, const std::string &defaultVal = (std::string(""))) const;
  36. void parseAttributeGroup(const pt::ptree &attributeTree);
  37. std::shared_ptr<SchemaValue> parseAttribute(const pt::ptree &attr);
  38. void parseSimpleType(const pt::ptree &typeTree);
  39. void parseComplexType(const pt::ptree &typeTree);
  40. void parseElement(const pt::ptree &elemTree);
  41. void parseAnnotation(const pt::ptree &elemTree);
  42. void parseAppInfo(const pt::ptree &elemTree);
  43. void processXSDFiles(const std::string &path, const std::string &ignore);
  44. void processSchemaInsert(const pt::ptree &elemTree);
  45. std::shared_ptr<SchemaType> getType(const pt::ptree &typeTree, bool nameRequired);
  46. std::shared_ptr<SchemaValue> getSchemaValue(const pt::ptree &attr);
  47. void parseIntegerTypeLimits(const pt::ptree &restrictTree, std::shared_ptr<SchemaTypeIntegerLimits> &pIntegerLimits);
  48. void parseStringTypeLimits(const pt::ptree &restrictTree, std::shared_ptr<SchemaTypeStringLimits> &pStringLimits);
  49. void parseAllowedValue(const pt::ptree &allowedValueTree, SchemaTypeLimits *pTypeLimits);
  50. protected:
  51. std::string m_buildsetFilename;
  52. std::string m_basePath;
  53. std::string m_masterXSDFilename;
  54. };
  55. #endif // _CONFIG2_XSDCONFIGPARSER_HPP_