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     };
00109     enum type_whichIsBigger {
00110       first_one,
00111       second_one,
00112       both_are_equal
00113     };
00114 
00115     // members
00120     QString theString;
00123     numberWithPointsAndDashes epoch;
00126     numberWithPointsAndDashes version_and_release;
00127 
00128     // methods
00130     void helper_copyFromHere(const VersionNumber & value);
00134     void helper_setValue(const QString & value);
00137     static VersionNumber::characterType helper_characterType(const QChar & value);
00140     static VersionNumber::simpleNumber helper_createSimpleNumber(const QString & value);
00143     static VersionNumber::numberWithPoints helper_createNumberWithPoints(const QString & value);
00146     static VersionNumber::numberWithPointsAndDashes helper_createNumberWithPointsAndDashes(
00147       const QString & value);
00149     static VersionNumber::type_whichIsBigger whichIsBigger(const VersionNumber & firstValue,
00150                                                             const VersionNumber & secondValue);
00152     static VersionNumber::type_whichIsBigger whichIsBigger(
00153       const numberWithPointsAndDashes & firstValue,
00154       const numberWithPointsAndDashes & secondValue);
00156     static VersionNumber::type_whichIsBigger whichIsBigger(const numberWithPoints & firstValue,
00157                                                             const numberWithPoints & secondValue);
00159     static VersionNumber::type_whichIsBigger whichIsBigger(const simpleNumber & firstValue,
00160                                                             const simpleNumber & secondValue);
00163     static VersionNumber::type_whichIsBigger whichIsBigger(const QString & firstValue,
00164                                                             const QString & secondValue);
00166     static VersionNumber::type_whichIsBigger helper_whichNumberIsBigger(
00167       const QString & firstValue,
00168       const QString & secondValue);
00170     static VersionNumber::type_whichIsBigger helper_whichStringIsBigger(
00171       const QString & firstValue,
00172       const QString & secondValue);
00173 
00174 };
00175 
00176 Q_DECLARE_METATYPE(VersionNumber)
00177 
00178 #endif

Generated on Sat May 2 10:43:44 2009 for kradioripper by  doxygen 1.5.6