Sleeping Wombat Common Library  0.50.0
swCommonLibrary
Version.h
Go to the documentation of this file.
1 #pragma once
2 
9 
10 #include <string>
11 
12 
17 struct Version
18 {
19  uint32 Major;
20  uint32 Minor;
21  uint32 Revision;
22  uint32 Build;
23 
24 // ================================ //
25 //
28  {
29  Major = 1;
30  Minor = 0;
31  Revision = 0;
32  Build = 0;
33  }
34 
36  Version ( const std::string& version )
37  {
38  std::sscanf( version.c_str(), "%d.%d.%d.%d", &Major, &Minor, &Revision, &Build );
39  if( Major < 0 ) Major = 0;
40  if( Minor < 0 ) Minor = 0;
41  if( Revision < 0 ) Revision = 0;
42  if( Build < 0 ) Build = 0;
43  }
44 
46  bool operator< ( const Version& other )
47  {
48  if( Major < other.Major )
49  return true;
50  else if( Major == other.Major )
51  {
52  if( Minor < other.Minor )
53  return true;
54  else if( Minor == other.Minor )
55  {
56  if( Revision < other.Revision )
57  return true;
58  else if( Build == other.Build && Build < other.Build )
59  return true;
60  }
61  }
62 
63  return false;
64  }
65 
67  bool operator== ( const Version& other )
68  {
69  return Major == other.Major
70  && Minor == other.Minor
71  && Revision == other.Revision
72  && Build == other.Build;
73  }
74 
76  friend std::ostream& operator<< ( std::ostream& stream, const Version& ver )
77  {
78  stream << ver.Major;
79  stream << '.';
80  stream << ver.Minor;
81  stream << '.';
82  stream << ver.Revision;
83  stream << '.';
84  stream << ver.Build;
85  return stream;
86  }
87 };
88 
bool operator==(const Version &other)
Version comparision.
Definition: Version.h:67
Plik zawiera definicje podstawowych typów zmiennych.
bool operator<(const Version &other)
Version comparision.
Definition: Version.h:46
Version()
Contructs Lowest version.
Definition: Version.h:27
Standard version structure.
Definition: Version.h:17