1543288deebf01c1bb886a087a98595635c59148
[shibboleth/cpp-sp.git] / shibsp / attribute / ExtensibleAttribute.h
1 /*
2  *  Copyright 2009 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/attribute/ExtensibleAttribute.h
19  *
20  * An Attribute whose values are arbitrary structures.
21  */
22
23 #ifndef __shibsp_extattr_h__
24 #define __shibsp_extattr_h__
25
26 #include <shibsp/attribute/Attribute.h>
27
28 namespace shibsp {
29
30 #if defined (_MSC_VER)
31     #pragma warning( push )
32     #pragma warning( disable : 4251 )
33 #endif
34
35     /**
36      * An Attribute whose values are arbitrary structures.
37      */
38     class SHIBSP_API ExtensibleAttribute : public Attribute
39     {
40     public:
41         /**
42          * Constructor.
43          *
44          * @param ids       array with primary identifier in first position, followed by any aliases
45          * @param formatter template for serialization of values
46          */
47         ExtensibleAttribute(const std::vector<std::string>& ids, const char* formatter);
48
49         /**
50          * Constructs based on a remoted ExtensibleAttribute.
51          *
52          * @param in    input object containing marshalled ExtensibleAttribute
53          */
54         ExtensibleAttribute(DDF& in);
55
56         virtual ~ExtensibleAttribute();
57
58         /**
59          * Returns the set of values in a DDF list.
60          *
61          * @return  a mutable list object containing the values
62          */
63         DDF getValues();
64
65         // Virtual function overrides.
66         size_t valueCount() const;
67         void clearSerializedValues();
68         const char* getString(size_t index) const;
69         const char* getScope(size_t index) const;
70         void removeValue(size_t index);
71         const std::vector<std::string>& getSerializedValues() const;
72         DDF marshall() const;
73
74     private:
75         mutable DDF m_obj;
76     };
77
78 #if defined (_MSC_VER)
79     #pragma warning( pop )
80 #endif
81
82 };
83
84 #endif /* __shibsp_nameidattr_h__ */