glc_attributes.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  This file is part of the GLC-lib library.
00004  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
00005  http://glc-lib.sourceforge.net
00006 
00007  GLC-lib is free software; you can redistribute it and/or modify
00008  it under the terms of the GNU Lesser General Public License as published by
00009  the Free Software Foundation; either version 3 of the License, or
00010  (at your option) any later version.
00011 
00012  GLC-lib is distributed in the hope that it will be useful,
00013  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  GNU Lesser General Public License for more details.
00016 
00017  You should have received a copy of the GNU Lesser General Public License
00018  along with GLC-lib; if not, write to the Free Software
00019  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
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 // Private members
00135 private:
00137         QHash<QString, QString> m_AttributesHash;
00138 
00140         QList<QString> m_AttributesList;
00141 
00142 };
00143 
00144 #endif /* GLC_ATTRIBUTES_H_ */

SourceForge.net Logo

©2005-2011 Laurent Ribon