SchemaType.hpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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_CFGTYPE_HPP_
  14. #define _CONFIG2_CFGTYPE_HPP_
  15. #include <string>
  16. #include <memory>
  17. #include <map>
  18. #include <vector>
  19. #include "SchemaTypeLimits.hpp"
  20. #include "platform.h"
  21. class DECL_EXPORT SchemaType
  22. {
  23. public:
  24. SchemaType(const std::string &name) : m_name(name), m_pLimits(std::make_shared<SchemaTypeLimits>()) { }
  25. SchemaType() : SchemaType("") { }
  26. virtual ~SchemaType() { }
  27. std::shared_ptr<SchemaTypeLimits> &getLimits() { return m_pLimits; }
  28. void setLimits(const std::shared_ptr<SchemaTypeLimits> &pLimits) { m_pLimits = pLimits; }
  29. bool isValid() const { return m_pLimits!=nullptr; }
  30. const std::string &getName() const { return m_name; }
  31. void setName(const std::string &name) { m_name = name; }
  32. bool isValueValid(const std::string &testValue) const { return m_pLimits->isValueValid(testValue); }
  33. bool isEnumerated() const { return m_pLimits->isEnumerated(); }
  34. const std::vector<AllowedValue> getEnumeratedValues() const { return m_pLimits->getEnumeratedValues(); }
  35. const std::string getLimitString() const { return m_pLimits->getLimitString(); }
  36. const std::string &getValidateMsg() const { return m_pLimits->getValidateMsg(); }
  37. const std::string &getValidateMsgType() const { return m_pLimits->getValidateMsgType(); }
  38. private:
  39. std::string m_name;
  40. std::shared_ptr<SchemaTypeLimits> m_pLimits;
  41. };
  42. #endif // _CONFIG2_CFGTYPE_HPP_