GLC_lib  2.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
glc_attributes.h
Go to the documentation of this file.
1 /****************************************************************************
2 
3  This file is part of the GLC-lib library.
4  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
5  http://glc-lib.sourceforge.net
6 
7  GLC-lib is free software; you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation; either version 3 of the License, or
10  (at your option) any later version.
11 
12  GLC-lib is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with GLC-lib; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21  *****************************************************************************/
23 
24 #ifndef GLC_ATTRIBUTES_H_
25 #define GLC_ATTRIBUTES_H_
26 
27 #include <QString>
28 #include <QList>
29 #include <QHash>
30 
31 #include "../glc_config.h"
32 
35 
36 
38 {
39 
41 
43 
44 public:
47 
50 
52  GLC_Attributes& operator=(const GLC_Attributes&);
53 
55  virtual ~GLC_Attributes();
56 
58 
60 
62 
63 public:
65  inline bool isEmpty() const
66  {return m_AttributesHash.isEmpty();}
67 
69  inline int size() const
70  {return m_AttributesHash.size();}
71 
73  bool contains(const QString& name) const
74  {return m_AttributesHash.contains(name);}
75 
77  inline QList<QString> names() const
78  {return m_AttributesList;}
79 
81 
82  inline QString value(const QString& name) const
83  {return m_AttributesHash.value(name);}
84 
86 
87  inline QString name(int at) const
88  {return m_AttributesList.value(at);}
89 
91 
93 
95 
96 public:
98  inline void insert(const QString& name, const QString& value)
99  {
100  if ((!m_AttributesHash.contains(name))) m_AttributesList.append(name);
101  m_AttributesHash.insert(name, value);
102  }
103 
105  inline void remove(const QString& name)
106  {
107  Q_ASSERT(m_AttributesHash.contains(name));
108  m_AttributesHash.remove(name);
109  m_AttributesList.removeOne(name);
110  }
111 
113  inline void clear()
114  {
115  m_AttributesHash.clear();
116  m_AttributesList.clear();
117  }
118 
120 
122 
124 
125 public:
126 
128  inline bool operator==(const GLC_Attributes& attr) const
129  {return m_AttributesHash == attr.m_AttributesHash;}
130 
132 
133 // Private members
135 private:
137  QHash<QString, QString> m_AttributesHash;
138 
140  QList<QString> m_AttributesList;
141 
142 };
143 
144 #endif /* GLC_ATTRIBUTES_H_ */

©2005-2013 Laurent Ribon