Wolframe, 0.0.3

version.hpp
Go to the documentation of this file.
1 /************************************************************************
2 
3  Copyright (C) 2011 - 2014 Project Wolframe.
4  All rights reserved.
5 
6  This file is part of Project Wolframe.
7 
8  Commercial Usage
9  Licensees holding valid Project Wolframe Commercial licenses may
10  use this file in accordance with the Project Wolframe
11  Commercial License Agreement provided with the Software or,
12  alternatively, in accordance with the terms contained
13  in a written agreement between the licensee and Project Wolframe.
14 
15  GNU General Public License Usage
16  Alternatively, you can redistribute this file and/or modify it
17  under the terms of the GNU General Public License as published by
18  the Free Software Foundation, either version 3 of the License, or
19  (at your option) any later version.
20 
21  Wolframe is distributed in the hope that it will be useful,
22  but WITHOUT ANY WARRANTY; without even the implied warranty of
23  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  GNU General Public License for more details.
25 
26  You should have received a copy of the GNU General Public License
27  along with Wolframe. If not, see <http://www.gnu.org/licenses/>.
28 
29  If you have questions regarding the use of this file, please contact
30  Project Wolframe.
31 
32 ************************************************************************/
35 
36 #ifndef _VERSION_HPP_INCLUDED
37 #define _VERSION_HPP_INCLUDED
38 
39 #include <string>
40 
41 namespace _Wolframe {
42 
44 class Version {
45 private:
46  unsigned short m_major;
47  unsigned short m_minor;
48  unsigned short m_revision;
50  unsigned m_build;
51  bool m_hasBuild;
52 public:
57  : m_major( 0 ), m_minor( 0 ),
58  m_revision( 0 ), m_hasRevision( false ),
59  m_build( 0 ), m_hasBuild( false )
60  {}
61  Version( const Version& o)
62  : m_major( o.m_major ), m_minor( o.m_minor ),
65  {}
66 
78  explicit Version( const char* version, const char* format="%M.%m%|.%r%|.%b");
79 
82  Version( unsigned long version );
83  Version( unsigned short M, unsigned short m );
84  Version( unsigned short M, unsigned short m, unsigned short r );
85  Version( unsigned short M, unsigned short m, unsigned short r, unsigned b );
86 
88  unsigned short Major() const { return m_major; }
90  unsigned short Minor() const { return m_minor; }
92  unsigned short Revision() const { return m_revision; }
94  unsigned Build() const { return m_build; }
95 
96  bool operator == ( const Version &other ) const;
97  bool operator != ( const Version &other ) const { return !( *this == other ); }
98 
99  bool operator > ( const Version &other ) const;
100  bool operator >= ( const Version &other ) const { return !( *this < other ); }
101  bool operator < ( const Version &other ) const { return ( other > *this ); }
102  bool operator <= ( const Version &other ) const { return !( *this > other ); }
103 
106  bool isCompatible( const Version &other ) const;
107 
109  std::string toString() const;
110 
113  std::string toString( const char* format ) const;
114 
120  unsigned long toNumber() const;
121 };
122 
123 } // namespace _Wolframe
124 
125 #endif // _VERSION_HPP_INCLUDED
bool m_hasBuild
Is build number present ?
Definition: version.hpp:51
std::string toString() const
Print the version in 'major.minor.revision.build' format.
bool operator<=(const Version &other) const
Definition: version.hpp:102
bool operator<(const Version &other) const
Definition: version.hpp:101
unsigned short m_minor
Minor version.
Definition: version.hpp:47
unsigned short Minor() const
Returns the minor number of the version.
Definition: version.hpp:90
unsigned short m_revision
Revision.
Definition: version.hpp:48
unsigned short m_major
Major version.
Definition: version.hpp:46
bool operator!=(const Version &other) const
Definition: version.hpp:97
unsigned short Revision() const
Returns the revision number of the version.
Definition: version.hpp:92
bool operator>=(const Version &other) const
Definition: version.hpp:100
unsigned short Major() const
Returns the major number of the version.
Definition: version.hpp:88
bool operator>(const Version &other) const
Version()
Empty Version constructor. This will contruct a Version object having major and minor versions set to...
Definition: version.hpp:56
bool isCompatible(const Version &other) const
version class
Definition: version.hpp:44
unsigned m_build
Build number.
Definition: version.hpp:50
bool m_hasRevision
Is revision present ?
Definition: version.hpp:49
unsigned long toNumber() const
Output the version as an unsigned long The format of the output is MMmmrrbbb.
Version(const Version &o)
Definition: version.hpp:61
unsigned Build() const
Returns the build number of the version.
Definition: version.hpp:94
bool operator==(const Version &other) const