XSDSchemaParser.hpp 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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::vector<std::string> &cfgParms) override;
  33. virtual void parseXSD(const pt::ptree &tree);
  34. virtual void parseXSD(const std::string &filename);
  35. virtual std::string getXSDAttributeValue(const pt::ptree &tree, const std::string &attriName, bool throwIfNotPresent=true, const std::string &defaultVal = (std::string(""))) const;
  36. virtual void parseAttributeGroup(const pt::ptree &attributeTree);
  37. virtual void parseAttribute(const pt::ptree &attr);
  38. virtual void parseSimpleType(const pt::ptree &typeTree);
  39. virtual void parseComplexType(const pt::ptree &typeTree);
  40. virtual void parseElement(const pt::ptree &elemTree);
  41. virtual void parseAnnotation(const pt::ptree &elemTree);
  42. virtual void parseAppInfo(const pt::ptree &elemTree);
  43. virtual std::shared_ptr<SchemaType> getSchemaType(const pt::ptree &typeTree, bool nameRequired=true);
  44. virtual std::shared_ptr<SchemaValue> getSchemaValue(const pt::ptree &attr);
  45. virtual void parseKey(const pt::ptree &keyTree);
  46. virtual void parseKeyRef(const pt::ptree &keyTree);
  47. virtual void parseIntegerTypeLimits(const pt::ptree &restrictTree, std::shared_ptr<SchemaTypeIntegerLimits> &pIntegerLimits);
  48. virtual void parseStringTypeLimits(const pt::ptree &restrictTree, std::shared_ptr<SchemaTypeStringLimits> &pStringLimits);
  49. virtual 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_