attribute.h
Go to the documentation of this file.
1 /*
2  * This library is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU Lesser General Public
4  * License as published by the Free Software Foundation; either
5  * version 2.1 of the License, or (at your option) any later version.
6  *
7  * As a special exception, you may use this file as part of a free
8  * software library without restriction. Specifically, if other files
9  * instantiate templates or use macros or inline functions from this
10  * file, or you compile this file and link it with other files to
11  * produce an executable, this file does not by itself cause the
12  * resulting executable to be covered by the GNU General Public
13  * License. This exception does not however invalidate any other
14  * reasons why the executable file might be covered by the GNU Library
15  * General Public License.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25  */
26 #ifndef cxxtools_xml_Attribute_h
27 #define cxxtools_xml_Attribute_h
28 
29 #include <cxxtools/string.h>
30 #include <cxxtools/date.h>
31 #include <cxxtools/time.h>
32 #include <cxxtools/datetime.h>
33 #include <vector>
34 
35 namespace cxxtools {
36 
37 namespace xml {
38 
50  class Attribute
51  {
52  public:
55  { }
56 
63  Attribute(const String& name, const String& value)
64  : _name(name), _value(value)
65  { }
66 
67  Attribute(const String& name, const Date& value)
68  : _name(name), _value(value.toString("%Y-%m-%d"))
69  { }
70 
71  Attribute(const String& name, const Time& value)
72  : _name(name), _value(value.toString("%H:%M:%S"))
73  { }
74 
76  : _name(name), _value(value.toString("%Y-%m-%dT%H:%M:%S"))
77  { }
78 
83  const String& name() const
84  { return _name; }
85 
87  { return _name; }
88 
93  void setName(const String& name)
94  { _name = name; }
95 
100  const String& value() const
101  { return _value; }
102 
104  { return _value; }
105 
110  void setValue(const String& value)
111  { _value = value; }
112 
113  void clear()
114  { _name.clear(); _value.clear(); }
115 
116  private:
118  String _name;
119 
121  String _value;
122  };
123 
124  typedef std::vector<Attribute> Attributes;
125 }
126 
127 }
128 
129 #endif