glc_attributes.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00023
00024 #ifndef GLC_ATTRIBUTES_H_
00025 #define GLC_ATTRIBUTES_H_
00026
00027 #include <QString>
00028 #include <QList>
00029 #include <QHash>
00030
00031 #include "../glc_config.h"
00032
00035
00036
00037 class GLC_LIB_EXPORT GLC_Attributes
00038 {
00039
00041
00043
00044 public:
00046 GLC_Attributes();
00047
00049 GLC_Attributes(const GLC_Attributes&);
00050
00052 GLC_Attributes& operator=(const GLC_Attributes&);
00053
00055 virtual ~GLC_Attributes();
00056
00058
00060
00062
00063 public:
00065 inline bool isEmpty() const
00066 {return m_AttributesHash.isEmpty();}
00067
00069 inline int size() const
00070 {return m_AttributesHash.size();}
00071
00073 bool contains(const QString& name) const
00074 {return m_AttributesHash.contains(name);}
00075
00077 inline QList<QString> names() const
00078 {return m_AttributesList;}
00079
00081
00082 inline QString value(const QString& name) const
00083 {return m_AttributesHash.value(name);}
00084
00086
00087 inline QString name(int at) const
00088 {return m_AttributesList.value(at);}
00089
00091
00093
00095
00096 public:
00098 inline void insert(const QString& name, const QString& value)
00099 {
00100 if ((!m_AttributesHash.contains(name))) m_AttributesList.append(name);
00101 m_AttributesHash.insert(name, value);
00102 }
00103
00105 inline void remove(const QString& name)
00106 {
00107 Q_ASSERT(m_AttributesHash.contains(name));
00108 m_AttributesHash.remove(name);
00109 m_AttributesList.removeOne(name);
00110 }
00111
00113 inline void clear()
00114 {
00115 m_AttributesHash.clear();
00116 m_AttributesList.clear();
00117 }
00118
00120
00122
00124
00125 public:
00126
00128 inline bool operator==(const GLC_Attributes& attr) const
00129 {return m_AttributesHash == attr.m_AttributesHash;}
00130
00132
00133
00135 private:
00137 QHash<QString, QString> m_AttributesHash;
00138
00140 QList<QString> m_AttributesList;
00141
00142 };
00143
00144 #endif