versionnumber.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2008-2010  Lukas Sommer < SommerLuk at gmail dot com >
00003 
00004     This program is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU General Public License as
00006     published by the Free Software Foundation; either version 2 of
00007     the License or (at your option) version 3 or any later version
00008     accepted by the membership of KDE e.V. (or its successor approved
00009     by the membership of KDE e.V.), which shall act as a proxy
00010     defined in Section 14 of version 3 of the license.
00011 
00012     This program 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 General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00019 */
00020 
00021 #ifndef VERSIONNUMBER_H
00022 #define VERSIONNUMBER_H
00023 
00024 #include <QStringList>
00025 #include <QMetaType>
00026 
00071 class VersionNumber
00072 {
00073 
00074   public:
00075     VersionNumber();
00076     VersionNumber(const VersionNumber & value); // copy constructor
00077     VersionNumber(const QString & value);
00078     VersionNumber(const qint64 value);
00079     virtual ~VersionNumber();
00080     QString toString() const;
00081     VersionNumber operator=(const VersionNumber & value);
00082     VersionNumber operator=(const QString & value);
00083     VersionNumber operator=(qint64 value);
00084     bool operator<(const VersionNumber & value) const;
00085     bool operator<=(const VersionNumber & value) const;
00086     bool operator>(const VersionNumber & value) const;
00087     bool operator>=(const VersionNumber & value) const;
00088     bool operator==(const VersionNumber & value) const;
00089     bool operator!=(const VersionNumber & value) const;
00090 
00091   private:
00092     // typedefs
00094     typedef QStringList simpleNumber;
00096     typedef QList< simpleNumber > numberWithPoints;
00098     typedef QList< numberWithPoints > numberWithPointsAndDashes;
00103     enum characterType {
00104       letter,
00105       digit,
00106       other
00107     };
00112     enum type_whichIsBigger {
00113       first_one,
00114       second_one,
00115       both_are_equal
00116     };
00117 
00118     // members
00123     QString theString;
00126     numberWithPointsAndDashes epoch;
00129     numberWithPointsAndDashes version_and_release;
00130 
00131     // methods
00133     void helper_copyFromHere(const VersionNumber & value);
00137     void helper_setValue(const QString & value);
00140     static VersionNumber::characterType helper_characterType(const QChar & value);
00143     static VersionNumber::simpleNumber helper_createSimpleNumber(const QString & value);
00146     static VersionNumber::numberWithPoints helper_createNumberWithPoints(const QString & value);
00149     static VersionNumber::numberWithPointsAndDashes helper_createNumberWithPointsAndDashes(
00150       const QString & value);
00152     static VersionNumber::type_whichIsBigger whichIsBigger(const VersionNumber & firstValue,
00153                                                            const VersionNumber & secondValue);
00155     static VersionNumber::type_whichIsBigger whichIsBigger(
00156       const numberWithPointsAndDashes & firstValue,
00157       const numberWithPointsAndDashes & secondValue);
00159     static VersionNumber::type_whichIsBigger whichIsBigger(const numberWithPoints & firstValue,
00160                                                            const numberWithPoints & secondValue);
00162     static VersionNumber::type_whichIsBigger whichIsBigger(const simpleNumber & firstValue,
00163                                                            const simpleNumber & secondValue);
00167     static VersionNumber::type_whichIsBigger whichIsBigger(const QString & firstValue,
00168                                                            const QString & secondValue);
00172     static VersionNumber::type_whichIsBigger helper_whichNumberIsBigger(
00173       const QString & firstValue,
00174       const QString & secondValue);
00176     static VersionNumber::type_whichIsBigger helper_whichStringIsBigger(
00177       const QString & firstValue,
00178       const QString & secondValue);
00179 
00180 };
00181 
00182 Q_DECLARE_METATYPE(VersionNumber)
00183 
00184 #endif

doxygen