2 * Copyright 2009 Internet2
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file shibsp/attribute/ExtensibleAttribute.h
20 * An Attribute whose values are arbitrary structures.
23 #ifndef __shibsp_extattr_h__
24 #define __shibsp_extattr_h__
26 #include <shibsp/attribute/Attribute.h>
27 #include <xmltooling/exceptions.h>
31 #if defined (_MSC_VER)
32 #pragma warning( push )
33 #pragma warning( disable : 4251 )
37 * An Attribute whose values are arbitrary structures.
39 class SHIBSP_API ExtensibleAttribute : public Attribute
45 * @param ids array with primary identifier in first position, followed by any aliases
46 * @param formatter template for serialization of values
48 ExtensibleAttribute(const std::vector<std::string>& ids, const char* formatter) : Attribute(ids) {
49 m_obj = Attribute::marshall();
50 m_obj.name("Extensible");
51 m_obj.addmember("_formatter").string(formatter);
55 * Constructs based on a remoted ExtensibleAttribute.
57 * @param in input object containing marshalled ExtensibleAttribute
59 ExtensibleAttribute(DDF& in) : Attribute(in), m_obj(in.copy()) {
62 virtual ~ExtensibleAttribute() {
67 * Returns the set of values in a DDF list.
69 * @return a mutable list object containing the values
75 size_t valueCount() const {
76 return m_obj.first().integer();
79 void clearSerializedValues() {
83 const char* getString(size_t index) const {
84 return m_obj.first()[static_cast<unsigned long>(index)].string();
87 const char* getScope(size_t index) const {
91 void removeValue(size_t index) {
92 Attribute::removeValue(index);
93 DDF vals = m_obj.first();
94 if (index < static_cast<size_t>(vals.integer()))
95 vals[static_cast<unsigned long>(index)].remove().destroy();
98 const std::vector<std::string>& getSerializedValues() const;
100 DDF marshall() const {
101 if (!isCaseSensitive())
102 m_obj.addmember("case_insensitive");
104 m_obj.addmember("internal");
112 #if defined (_MSC_VER)
113 #pragma warning( pop )
118 #endif /* __shibsp_nameidattr_h__ */