VS10 solution files, convert from NULL macro to nullptr.
[shibboleth/sp.git] / shibsp / util / PropertySet.h
1 /*
2  *  Copyright 2001-2010 Internet2
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /**
18  * @file shibsp/util/PropertySet.h
19  * 
20  * Interface to a generic set of typed properties or a DOM container of additional data.
21  */
22
23 #ifndef __shibsp_propset_h__
24 #define __shibsp_propset_h__
25
26 #include <shibsp/util/SPConstants.h>
27
28 #include <map>
29 #include <string>
30 #include <xercesc/dom/DOM.hpp>
31
32 namespace shibsp {
33
34     /**
35      * Interface to a generic set of typed properties or a DOM container of additional data.
36      */
37     class SHIBSP_API PropertySet
38     {
39         MAKE_NONCOPYABLE(PropertySet);
40     protected:
41         PropertySet();
42     public:
43         virtual ~PropertySet();
44
45         /**
46          * Returns parent of this PropertySet, if any.
47          *
48          * @return the parent object, or nullptr
49          */
50         virtual const PropertySet* getParent() const=0;
51
52         /**
53          * Establishes a "parent" PropertySet to supply inherited settings.
54          *
55          * @param parent    the parent PropertySet to use
56          */
57         virtual void setParent(const PropertySet* parent)=0;
58
59         /**
60          * Returns a boolean-valued property.
61          * 
62          * @param name  property name
63          * @param ns    property namespace, or nullptr
64          * @return a pair consisting of a nullptr indicator and the property value iff the indicator is true
65          */
66         virtual std::pair<bool,bool> getBool(const char* name, const char* ns=nullptr) const=0;
67
68         /**
69          * Returns a string-valued property.
70          * 
71          * @param name  property name
72          * @param ns    property namespace, or nullptr
73          * @return a pair consisting of a nullptr indicator and the property value iff the indicator is true
74          */
75         virtual std::pair<bool,const char*> getString(const char* name, const char* ns=nullptr) const=0;
76
77         /**
78          * Returns a Unicode string-valued property.
79          * 
80          * @param name  property name
81          * @param ns    property namespace, or nullptr
82          * @return a pair consisting of a nullptr indicator and the property value iff the indicator is true
83          */
84         virtual std::pair<bool,const XMLCh*> getXMLString(const char* name, const char* ns=nullptr) const=0;
85
86         /**
87          * Returns an unsigned integer-valued property.
88          * 
89          * @param name  property name
90          * @param ns    property namespace, or nullptr
91          * @return a pair consisting of a nullptr indicator and the property value iff the indicator is true
92          */
93         virtual std::pair<bool,unsigned int> getUnsignedInt(const char* name, const char* ns=nullptr) const=0;
94
95         /**
96          * Returns an integer-valued property.
97          * 
98          * @param name  property name
99          * @param ns    property namespace, or nullptr
100          * @return a pair consisting of a nullptr indicator and the property value iff the indicator is true
101          */
102         virtual std::pair<bool,int> getInt(const char* name, const char* ns=nullptr) const=0;
103
104         /**
105          * Returns a map of all known properties in string form.
106          *
107          * @param properties    map to populate
108          */
109         virtual void getAll(std::map<std::string,const char*>& properties) const=0;
110
111         /**
112          * Returns a nested property set.
113          * 
114          * @param name  nested property set name
115          * @param ns    nested property set namespace, or nullptr
116          * @return the nested property set, or nullptr
117          */        
118         virtual const PropertySet* getPropertySet(const char* name, const char* ns=shibspconstants::ASCII_SHIB2SPCONFIG_NS) const=0;
119         
120         /**
121          * Returns a DOM element representing the property container, if any.
122          * 
123          * @return a DOM element, or nullptr
124          */
125         virtual const xercesc::DOMElement* getElement() const=0;
126     };
127 };
128
129 #endif /* __shibsp_propset_h__ */