omw  0.1.1
version.h
1 /*
2 author Oliver Blaser
3 date 08.12.2021
4 copyright MIT - Copyright (c) 2021 Oliver Blaser
5 */
6 
7 #ifndef IG_OMW_VERSION_H
8 #define IG_OMW_VERSION_H
9 
10 #include <iostream>
11 #include <string>
12 #include <vector>
13 
14 namespace omw
15 {
16  class Version
17  {
18  public:
19  Version();
20  Version(int major, int minor, int revision);
21  explicit Version(const char* versionStr);
22  explicit Version(const std::string& versionStr);
23 
24  int maj() const;
25  int min() const;
26  int rev() const;
27 
28  const int* data() const;
29  size_t size() const;
30 
31  std::vector<int> toVector() const;
32  std::string toString() const;
33 
34  friend bool operator<(const omw::Version& left, const omw::Version& right);
35  friend bool operator>(const omw::Version& left, const omw::Version& right);
36  friend bool operator<=(const omw::Version& left, const omw::Version& right);
37  friend bool operator>=(const omw::Version& left, const omw::Version& right);
38  friend bool operator==(const omw::Version& left, const omw::Version& right);
39  friend bool operator!=(const omw::Version& left, const omw::Version& right);
40 
41  template<class CharT, class Traits = std::char_traits<CharT>>
42  friend std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os, const omw::Version& v)
43  {
44  // since the version string consists only out of ASCII chars, here is no std::basic_ostream<c,t>::widen() needed.
45  return (os << v.toString().c_str());
46  }
47 
48  private:
49  static constexpr size_t dataSize = 3;
50  int version[dataSize];
51 
52  void setData(const std::string& versionStr);
53  };
54 }
55 
56 #endif // IG_OMW_VERSION_H
std::string
C++ standard string. See std::basic_string for detailed information.
Definition: linkToStd.dox:15
omw::Version
Definition: version.h:17
omw::Version::size
size_t size() const
Definition: version.cpp:77
omw::Version::toString
std::string toString() const
Definition: version.cpp:91
omw
Main namespace.
omw::Version::data
const int * data() const
Definition: version.cpp:70