ddc
ddcVersion.h
Go to the documentation of this file.
1 /*-*- Mode: C++ -*-*/
2 #ifndef DDC_version_h
3 #define DDC_version_h
4 
5 #include "ddcConfig.h" /*-- moo --*/
6 #include "utilit.h"
7 #include "DDCInternalError.h"
8 #include <sstream>
9 
10 //======================================================================
12 class DDCVersionT {
13 
14  //--------------------------------------------------------------
15 public:
19 
20 public:
21  //--------------------------------------------------------------
22  DDCVersionT(DWORD vmajor=0, DWORD vminor=0, DWORD vmicro=0)
23  : v_major(vmajor), v_minor(vminor), v_micro(vmicro)
24  {};
25 
27  : v_major(v.v_major), v_minor(v.v_minor), v_micro(v.v_micro)
28  {};
29 
30  DDCVersionT(const std::string& s)
31  { fromString(s); };
32 
34  inline static DDCVersionT current()
36 
37  //--------------------------------------------------------------
38  inline void clear(void)
39  {
40  v_major=0;
41  v_minor=0;
42  v_micro=0;
43  };
44 
45  //--------------------------------------------------------------
46  inline bool empty(void)
47  {
48  return v_major==0 && v_minor==0 && v_micro==0;
49  };
50 
51  //--------------------------------------------------------------
52  inline bool operator==(const DDCVersionT x) const
53  {
54  return (v_major==x.v_major && v_minor==x.v_minor && v_micro==x.v_micro);
55  };
56 
57  //--------------------------------------------------------------
58  inline bool operator<(const DDCVersionT x) const
59  {
60  return (v_major < x.v_major
61  || (v_major == x.v_major && (v_minor < x.v_minor
62  || (v_minor == x.v_minor && (v_micro < x.v_micro)))));
63  };
64 
65  //--------------------------------------------------------------
66  inline bool operator<=(const DDCVersionT x) const
67  {
68  return (*this==x || *this < x);
69  };
70 
71  //--------------------------------------------------------------
72  inline bool operator>(const DDCVersionT x) const
73  { return x < *this; };
74 
75  //--------------------------------------------------------------
76  inline bool operator>=(const DDCVersionT x) const
77  { return x <= *this; };
78 
79  //--------------------------------------------------------------
80  inline friend std::ostream& operator<< (std::ostream &out, DDCVersionT v)
81  {
82  out << v.v_major << "." << v.v_minor << "." << v.v_micro;
83  return out;
84  };
85 
86  //--------------------------------------------------------------
87  inline friend std::istream& operator>> (std::istream &in, DDCVersionT &v)
88  {
89  in >> v.v_major;
90  if (in.peek() == '.') { in.get(); in >> v.v_minor; }
91  if (in.peek() == '.') { in.get(); in >> v.v_micro; }
92  return in;
93  };
94 
95  //--------------------------------------------------------------
96  inline void toString(std::string &s) const
97  {
98  ostringstream os;
99  os << *this;
100  s = os.str();
101  };
102 
103  //--------------------------------------------------------------
104  inline std::string str(void) const
105  {
106  std::string s;
107  toString(s);
108  return s;
109  };
110 
111  //--------------------------------------------------------------
112  inline void fromString(const std::string &s)
113  {
114  istringstream is(s);
115  clear();
116  is >> *this;
117  };
118 };
119 
122 
124 const char* DDCVersionString();
125 
127 const DDCVersionT DDCVersionMinR(2,0,0);
128 
130 const DDCVersionT DDCVersionMinW(2,1,13);
131 
144 void ddc_parse_format_version(const char *s, DDCVersionT &version, DDCVersionT &version_min);
145 
150 void ddc_format_version_check(const char *s, const char *label=NULL);
151 
152 #endif
153 
154 /*--- emacs style variables ---
155  * Local Variables:
156  * mode: C++
157  * c-file-style: "ellemtel"
158  * c-basic-offset: 4
159  * tab-width: 8
160  * indent-tabs-mode: nil
161  * End:
162  */
const char * DDCVersionString()
Definition: ddcVersion.cpp:22
void ddc_format_version_check(const char *s, const char *label=NULL)
Definition: ddcVersion.cpp:43
DDCVersionT(DWORD vmajor=0, DWORD vminor=0, DWORD vmicro=0)
Definition: ddcVersion.h:22
friend std::ostream & operator<<(std::ostream &out, DDCVersionT v)
Definition: ddcVersion.h:80
const DDCVersionT DDCVersionMinR(2, 0, 0)
bool operator<=(const DDCVersionT x) const
Definition: ddcVersion.h:66
const DDCVersionT DDCVersion(2, 2, 8)
bool empty(void)
Definition: ddcVersion.h:46
DWORD v_micro
Definition: ddcVersion.h:18
bool operator>=(const DDCVersionT x) const
Definition: ddcVersion.h:76
DWORD v_minor
Definition: ddcVersion.h:17
DDCVersionT(const DDCVersionT &v)
Definition: ddcVersion.h:26
void ddc_parse_format_version(const char *s, DDCVersionT &version, DDCVersionT &version_min)
Definition: ddcVersion.cpp:28
void clear(void)
Definition: ddcVersion.h:38
friend std::istream & operator>>(std::istream &in, DDCVersionT &v)
Definition: ddcVersion.h:87
DDCVersionT(const std::string &s)
Definition: ddcVersion.h:30
static DDCVersionT current()
return version of current DDC library (for use in initializers)
Definition: ddcVersion.h:34
bool operator==(const DDCVersionT x) const
Definition: ddcVersion.h:52
DWORD v_major
Definition: ddcVersion.h:16
const DDCVersionT DDCVersionMinW(2, 1, 13)
void fromString(const std::string &s)
Definition: ddcVersion.h:112
void toString(std::string &s) const
Definition: ddcVersion.h:96
#define DDC_VERSION_MINOR
Definition: ddcConfigAuto.h:46
Definition: ddcVersion.h:12
bool operator>(const DDCVersionT x) const
Definition: ddcVersion.h:72
#define DDC_VERSION_MICRO
Definition: ddcConfigAuto.h:43
uint32_t DWORD
Definition: utilit.h:105
bool operator<(const DDCVersionT x) const
Definition: ddcVersion.h:58
std::string str(void) const
Definition: ddcVersion.h:104
#define DDC_VERSION_MAJOR
Definition: ddcConfigAuto.h:40