Shift property set logging to its own category.
[shibboleth/sp.git] / shibsp / util / DOMPropertySet.h
1 /*
2  *  Copyright 2001-2007 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/DOMPropertySet.h
19  * 
20  * DOM-based property set implementation.
21  */
22
23 #ifndef __shibsp_dompropset_h__
24 #define __shibsp_dompropset_h__
25
26 #include <shibsp/util/PropertySet.h>
27 #include <xmltooling/logging.h>
28
29 namespace shibsp {
30
31     /**
32      * DOM-based property set implementation.
33      */
34     class SHIBSP_API DOMPropertySet : public virtual PropertySet
35     {
36     public:
37         DOMPropertySet() : m_parent(NULL), m_root(NULL) {}
38         
39         virtual ~DOMPropertySet();
40
41         const PropertySet* getParent() const {
42             return m_parent;
43         }
44
45         void setParent(const PropertySet* parent) {
46             m_parent = parent;
47         }
48
49         std::pair<bool,bool> getBool(const char* name, const char* ns=NULL) const;
50         std::pair<bool,const char*> getString(const char* name, const char* ns=NULL) const;
51         std::pair<bool,const XMLCh*> getXMLString(const char* name, const char* ns=NULL) const;
52         std::pair<bool,unsigned int> getUnsignedInt(const char* name, const char* ns=NULL) const;
53         std::pair<bool,int> getInt(const char* name, const char* ns=NULL) const;
54         void getAll(std::map<std::string,const char*>& properties) const;
55         const PropertySet* getPropertySet(const char* name, const char* ns="urn:mace:shibboleth:2.0:native:sp:config") const;
56
57         const xercesc::DOMElement* getElement() const {
58             return m_root;
59         }
60
61         /**
62          * Loads the property set from a DOM element.
63          * 
64          * @param e         root element of property set
65          * @param log       optional log object for tracing
66          * @param filter    optional filter controls what child elements to include as nested PropertySets
67          * @param remapper  optional map of property rename rules for legacy property support
68          */
69         void load(
70             const xercesc::DOMElement* e,
71             xmltooling::logging::Category* log=NULL,
72             xercesc::DOMNodeFilter* filter=NULL,
73             const std::map<std::string,std::string>* remapper=NULL
74             );
75
76     private:
77         const PropertySet* m_parent;
78         const xercesc::DOMElement* m_root;
79         std::map<std::string,std::pair<char*,const XMLCh*> > m_map;
80         std::map<std::string,DOMPropertySet*> m_nested;
81     };
82
83 };
84
85 #endif /* __shibsp_dompropset_h__ */