versionnumber.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2008  Tim Fechtner < urwald at users dot sourceforge dot net >
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 
00068 class VersionNumber
00069 {
00070 
00071   public:
00072     VersionNumber();
00073     VersionNumber(const VersionNumber & value); // copy constructor
00074     VersionNumber(const QString & value);
00075     VersionNumber(const qint64 & value);
00076     virtual ~VersionNumber();
00077     QString toString() const;
00078     VersionNumber operator=(const VersionNumber & value);
00079     VersionNumber operator=(const QString & value);
00080     VersionNumber operator=(const qint64 & value);
00081     bool operator<(const VersionNumber & value) const;
00082     bool operator<=(const VersionNumber & value) const;
00083     bool operator>(const VersionNumber & value) const;
00084     bool operator>=(const VersionNumber & value) const;
00085     bool operator==(const VersionNumber & value) const;
00086     bool operator!=(const VersionNumber & value) const;
00087 
00088   private:
00089     // typedefs
00091     typedef QStringList simpleNumber;
00093     typedef QList< simpleNumber > numberWithPoints;
00095     typedef QList< numberWithPoints > numberWithPointsAndDashes;
00100     enum characterType {
00101       letter,
00102       digit,
00103       other
00104     };
00105 
00106   public:
00111     enum type_whichIsBigger {
00112       first_one,
00113       second_one,
00114       both_are_equal
00115     };
00116 
00117   private:
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);
00166     static VersionNumber::type_whichIsBigger whichIsBigger(const QString & firstValue,
00167                                                             const QString & secondValue);
00169     static VersionNumber::type_whichIsBigger helper_whichNumberIsBigger(
00170       const QString & firstValue,
00171       const QString & secondValue);
00173     static VersionNumber::type_whichIsBigger helper_whichStringIsBigger(
00174       const QString & firstValue,
00175       const QString & secondValue);
00176 
00177 };
00178 
00179 Q_DECLARE_METATYPE(VersionNumber)
00180 
00181 #endif

Generated on Sat Jan 24 16:55:04 2009 for qt-extensions by  doxygen 1.5.6