123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- /*##############################################################################
- HPCC SYSTEMS software Copyright (C) 2015 HPCC Systems®.
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- ############################################################################## */
- #ifndef _SCHEMA_ATTRIBUTES_HPP_
- #define _SCHEMA_ATTRIBUTES_HPP_
- #include "jarray.hpp"
- #include "jatomic.hpp"
- #include "XMLTags.h"
- #include "SchemaCommon.hpp"
- #include "SchemaAnnotation.hpp"
- namespace CONFIGURATOR
- {
- class CSimpleTypeArray;
- class CKeyRefArray;
- class CKeyArray;
- class CKey;
- class CKeyRef;
- class CAttribute : public CXSDNodeWithType
- {
- public:
- CAttribute(CXSDNodeBase* pParentNode, const char* pName = nullptr) : CXSDNodeWithType::CXSDNodeWithType(pParentNode, XSD_ATTRIBUTE), m_strName(pName),
- m_strDefault(""), m_strUse(""), m_pAnnotation(nullptr), m_pSimpleTypeArray(nullptr), m_bInstanceValueValid(false)
- {
- }
- CAttribute(CXSDNodeBase* pParentNode, const char* pName, const char* pType, const char* pDefault, const char* pUse) : CXSDNodeWithType::CXSDNodeWithType(pParentNode, XSD_ATTRIBUTE), m_strName(pName), m_pAnnotation(nullptr),
- m_strDefault(pDefault), m_strUse(pUse), m_pSimpleTypeArray(nullptr), m_bInstanceValueValid(false)
- {
- }
- virtual ~CAttribute();
- GETTERSETTER(Name)
- GETTERSETTER(Default)
- GETTERSETTER(Use)
- GETTERSETTER(InstanceValue)
- const CAnnotation* getAnnotation() const
- {
- return m_pAnnotation;
- }
- const char* getTitle() const;
- virtual const char* getXML(const char* pComponent);
- virtual void dump(::std::ostream& cout, unsigned int offset = 0) const;
- virtual void getDocumentation(::StringBuffer &strDoc) const;
- virtual void getJSON(::StringBuffer &strJSON, unsigned int offset = 0, int idx = -1) const;
- virtual void populateEnvXPath(::StringBuffer strXPath, unsigned int index = 1);
- virtual void loadXMLFromEnvXml(const ::IPropertyTree *pEnvTree);
- const CSimpleTypeArray* getSimpleTypeArray() const
- {
- return m_pSimpleTypeArray;
- }
- static CAttribute* load(CXSDNodeBase* pParentNode, const ::IPropertyTree *pSchemaRoot, const char* xpath = nullptr);
- bool isInstanceValueValid()
- {
- return m_bInstanceValueValid;
- }
- bool isHidden();
- virtual bool setEnvValueFromXML(const char *p);
- void appendReverseKey(const CKey *pKey);
- void appendReverseKeyRef(const CKeyRef *pKeyRef);
- protected:
- void setInstanceAsValid(bool bValid = true)
- {
- m_bInstanceValueValid = bValid;
- }
- void setAnnotation(CAnnotation *pAnnotation)
- {
- assert(pAnnotation != nullptr); // why would this ever be nullptr?
- m_pAnnotation = pAnnotation;
- }
- void setSimpleTypeArray(CSimpleTypeArray *pSimpleTypeArray)
- {
- assert(pSimpleTypeArray != nullptr); // why would this ever be nullptr?
- m_pSimpleTypeArray = pSimpleTypeArray;
- }
- CAnnotation *m_pAnnotation;
- CSimpleTypeArray *m_pSimpleTypeArray;
- ::PointerArray m_ReverseKeyArray;
- ::PointerArray m_ReverseKeyRefArray;
- bool m_bInstanceValueValid;
- private:
- };
- class CAttributeArray : public ::CIArrayOf<CAttribute>, public CInterface, public CXSDNodeBase
- {
- public:
- CAttributeArray(CXSDNodeBase* pParentNode = nullptr) : CXSDNodeBase::CXSDNodeBase(pParentNode, XSD_ATTRIBUTE_ARRAY)
- {
- }
- virtual ~CAttributeArray()
- {
- }
- virtual void dump(::std::ostream& cout, unsigned int offset = 0) const;
- virtual void getDocumentation(::StringBuffer &strDoc) const;
- virtual void getJSON(::StringBuffer &strJSON, unsigned int offset = 0, int idx = -1) const;
- virtual void populateEnvXPath(::StringBuffer strXPath, unsigned int index = 1);
- virtual void loadXMLFromEnvXml(const ::IPropertyTree *pEnvTree);
- virtual const char* getXML(const char* /*pComponent*/);
- const CAttribute* findAttributeWithName(const char *pName, bool bCaseInsensitive = true) const;
- const void getAttributeNames(::StringArray &names, ::StringArray &titles) const;
- static CAttributeArray* load(const char* pSchemaFile);
- static CAttributeArray* load(CXSDNodeBase* pParentNode, const ::IPropertyTree *pSchemaRoot, const char* xpath);
- protected:
- bool getCountOfValueMatches(const char *pValue) const;
- private:
- };
- }
- #endif // _SCHEMA_ATTRIBUTES_HPP_
|