libcommonc++  0.7
Version.h++
Go to the documentation of this file.
1 /* ---------------------------------------------------------------------------
2  commonc++ - A C++ Common Class Library
3  Copyright (C) 2005-2014 Mark A Lindner
4 
5  This file is part of commonc++.
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public
18  License along with this library; if not, write to the Free
19  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  ---------------------------------------------------------------------------
21 */
22 
23 #ifndef __ccxx_Version_hxx
24 #define __ccxx_Version_hxx
25 
26 #include <commonc++/Common.h++>
27 #include <commonc++/String.h++>
28 
29 namespace ccxx {
30 
58 {
59  public:
60 
68  Version(const String& version);
69 
79  Version(uint_t current = 0, uint_t revision = 0, uint_t age = 0);
80 
82  Version(const Version& other);
83 
85  virtual ~Version();
86 
97  bool satisfies(const Version& requested) const;
98 
108  bool satisfiedBy(const Version& available) const;
109 
111  inline uint_t getCurrent() const
112  { return(_current); }
113 
115  inline uint_t getRevision() const
116  { return(_revision); }
117 
119  inline uint_t getAge() const
120  { return(_age); }
121 
123  void interfacesAdded();
124 
126  void interfacesRemoved();
127 
132  void interfacesChanged();
133 
135  void implementationChanged();
136 
138  String toString() const;
139 
141  String toCRAString() const;
142 
144  void fromString(const String& version);
145 
147  bool operator==(const Version& other) const;
148 
150  inline bool operator!=(const Version& other) const
151  { return(! operator==(other)); }
152 
154  bool operator<(const Version& other) const;
155 
157  inline bool operator<=(const Version& other) const
158  { return(operator<(other) || operator==(other)); }
159 
161  bool operator>(const Version& other) const;
162 
164  inline bool operator>=(const Version& other) const
165  { return(operator>(other) || operator==(other)); }
166 
168  Version& operator=(const Version& other);
169 
170  private:
171 
172  uint_t _current;
173  uint_t _revision;
174  uint_t _age;
175  mutable String _str;
176  mutable String _vstr;
177 };
178 
179 inline std::ostream& operator<<(std::ostream& stream, const Version& v)
180 {
181  CString cstr_v = v.toString().toUTF8();
182  return(stream << cstr_v.data());
183 }
184 
185 } // namespace ccxx
186 
187 #endif // __ccxx_Version_hxx
A class representing an interface version number.
Definition: Version.h++:57
bool operator>=(const Version &other) const
Determine if this Version is newer than or equal to another version.
Definition: Version.h++:164
const char * data() const
Get a pointer to the character array.
Definition: CString.h++:58
bool operator!=(const Version &other) const
Inequality operator.
Definition: Version.h++:150
bool operator==(const Blob &b1, const Blob &b2)
Definition: Blob.h++:344
unsigned int uint_t
An alias for unsigned int.
Definition: Integers.h++:74
bool operator<=(const Version &other) const
Determine if this Version is older than or equal to another version.
Definition: Version.h++:157
uint_t getRevision() const
Get the revision component of the version.
Definition: Version.h++:115
uint_t getAge() const
Get the age component of the version.
Definition: Version.h++:119
std::ostream & operator<<(std::ostream &stream, const BitSet &bs)
Definition: BitSet.h++:383
String toString() const
Get a String representation of the version, in C-A.A.R form.
Definition: Version.c++:166
uint_t getCurrent() const
Get the current component of the version.
Definition: Version.h++:111
#define COMMONCPP_API
Definition: Common.h++:126
A flexible, reference counted, copy-on-write, thread-safe, nullable string.
Definition: String.h++:50
An implicitly shared, reference-counted container for an immutable, NUL-terminated C string...
Definition: CString.h++:39
bool operator<(const Blob &b1, const Blob &b2)
Definition: Blob.h++:350
CString toUTF8() const
Return the contents of the string as an immutable C string.
Definition: String.c++:1143
Definition: AllocationMap.c++:25
bool operator>(const Blob &b1, const Blob &b2)
Definition: Blob.h++:353