1 /* Copyright (c) 2015, 2021, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is also distributed with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software Foundation,
21 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
22
23 #include "member_version.h"
24
Member_version(unsigned int version)25 Member_version::Member_version(unsigned int version)
26 {
27 this->version= version;
28 }
29
30 uint32
get_version() const31 Member_version::get_version() const
32 {
33 return this->version;
34 }
35
36 uint32
get_major_version() const37 Member_version::get_major_version() const
38 {
39 return this->version >> 16;
40 }
41
42 uint32
get_minor_version() const43 Member_version::get_minor_version() const
44 {
45 return (this->version >> 8) & 0xff;
46 }
47
48 uint32
get_patch_version() const49 Member_version::get_patch_version() const
50 {
51 return this->version & 0xff;
52 }
53
54 bool
operator ==(const Member_version & other) const55 Member_version::operator ==(const Member_version &other) const
56 {
57 return get_version() == other.get_version();
58 }
59
60 bool
operator <(const Member_version & other) const61 Member_version::operator <(const Member_version &other) const
62 {
63 if (*this == other)
64 return false;
65
66 if (get_major_version() < other.get_major_version())
67 {
68 return true;
69 }
70 else if (get_major_version() > other.get_major_version())
71 {
72 return false;
73 }
74 else //major version are the same
75 {
76 if (get_minor_version() < other.get_minor_version())
77 {
78 return true;
79 }
80 else if (get_minor_version() > other.get_minor_version())
81 {
82 return false;
83 }
84 else //minor version are the same
85 {
86 if (get_patch_version() < other.get_patch_version())
87 {
88 return true;
89 }
90 }
91 }
92
93 return false;
94 }
95
96 bool
operator >(const Member_version & other) const97 Member_version::operator >(const Member_version &other) const
98 {
99 if (*this == other)
100 return false;
101
102 return !(*this < other);
103 }
104
105 bool
operator >=(const Member_version & other) const106 Member_version::operator >=(const Member_version &other) const
107 {
108 return (*this == other || *this > other);
109 }
110
111 bool
operator <=(const Member_version & other) const112 Member_version::operator <=(const Member_version &other) const
113 {
114 return (*this == other || *this < other);
115 }
116
~Member_version()117 Member_version::~Member_version()
118 {
119 }
120
121