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/XMLAttribute.h
20 * An Attribute whose values are serialized XML.
23 #ifndef __shibsp_xmlattr_h__
24 #define __shibsp_xmlattr_h__
26 #include <shibsp/attribute/Attribute.h>
31 * An Attribute whose values are serialized XML.
33 class SHIBSP_API XMLAttribute : public Attribute
39 * @param ids array with primary identifier in first position, followed by any aliases
41 XMLAttribute(const std::vector<std::string>& ids) : Attribute(ids) {}
44 * Constructs based on a remoted XMLAttribute.
46 * @param in input object containing marshalled XMLAttribute
48 XMLAttribute(DDF& in) : Attribute(in) {
49 DDF val = in.first().first();
50 while (val.string()) {
51 m_values.push_back(val.string());
52 val = in.first().next();
56 virtual ~XMLAttribute() {}
59 * Returns the set of values encoded as XML.
61 * @return a mutable vector of the values
63 std::vector<std::string>& getValues() {
68 * Returns the set of values encoded as XML.
70 * @return an immutable vector of the values
72 const std::vector<std::string>& getValues() const {
76 size_t valueCount() const {
77 return m_values.size();
80 void clearSerializedValues() {
84 const char* getString(size_t index) const {
85 return m_values[index].c_str();
88 void removeValue(size_t index) {
89 Attribute::removeValue(index);
90 if (index < m_values.size())
91 m_values.erase(m_values.begin() + index);
94 const std::vector<std::string>& getSerializedValues() const;
96 DDF marshall() const {
97 DDF ddf = Attribute::marshall();
99 DDF vlist = ddf.first();
100 for (std::vector<std::string>::const_iterator i=m_values.begin(); i!=m_values.end(); ++i)
101 vlist.add(DDF(NULL).string(i->c_str()));
106 std::vector<std::string> m_values;
111 #endif /* __shibsp_xmlattr_h__ */