libbmq b6028b29b733bc7541593d2905a5f79a9f0192fc
Loading...
Searching...
No Matches
bmqt_version.h
Go to the documentation of this file.
1// Copyright 2014-2023 Bloomberg Finance L.P.
2// SPDX-License-Identifier: Apache-2.0
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16// bmqt_version.h -*-C++-*-
17#ifndef INCLUDED_BMQT_VERSION
18#define INCLUDED_BMQT_VERSION
19
44
45// BMQ
46
47// BDE
48#include <bsl_iosfwd.h>
49
50namespace BloombergLP {
51namespace bmqt {
52
53// =============
54// class Version
55// =============
56
58class Version {
59 private:
60 // DATA
61 unsigned char d_major; // Major part of the version
62 unsigned char d_minor; // Minor part of the version
63
64 public:
65 // CREATORS
66
69 Version();
70
73 Version(unsigned char major, unsigned char minor);
74
75 // MANIPULATORS
76
79 Version& setMajor(unsigned char value);
80
83 Version& setMinor(unsigned char value);
84
85 // ACCESSORS
86
98 bsl::ostream&
99 print(bsl::ostream& stream, int level = 0, int spacesPerLevel = 4) const;
100
102 unsigned char major() const;
103
105 unsigned char minor() const;
106};
107
108// FREE OPERATORS
109
112bsl::ostream& operator<<(bsl::ostream& stream, const Version& rhs);
113
116bool operator==(const Version& lhs, const Version& rhs);
117
121bool operator!=(const Version& lhs, const Version& rhs);
122
125bool operator<(const Version& lhs, const Version& rhs);
126
127// ============================================================================
128// INLINE DEFINITIONS
129// ============================================================================
130
131// -------------
132// class Version
133// -------------
134
135// CREATORS
137: d_major(0)
138, d_minor(0)
139{
140 // NOTHING
141}
142
143inline Version::Version(unsigned char major, unsigned char minor)
144: d_major(major)
145, d_minor(minor)
146{
147 // NOTHING
148}
149
150// MANIPULATORS
151inline Version& Version::setMajor(unsigned char value)
152{
153 d_major = value;
154 return *this;
155}
156
157inline Version& Version::setMinor(unsigned char value)
158{
159 d_minor = value;
160 return *this;
161}
162
163// ACCESSORS
164inline unsigned char Version::major() const
165{
166 return d_major;
167}
168
169inline unsigned char Version::minor() const
170{
171 return d_minor;
172}
173
174} // close package namespace
175
176// FREE OPERATORS
177inline bsl::ostream& bmqt::operator<<(bsl::ostream& stream,
178 const bmqt::Version& rhs)
179{
180 return rhs.print(stream, 0, -1);
181}
182
183inline bool bmqt::operator==(const bmqt::Version& lhs,
184 const bmqt::Version& rhs)
185{
186 return lhs.major() == rhs.major() && lhs.minor() == rhs.minor();
187}
188
189inline bool bmqt::operator!=(const bmqt::Version& lhs,
190 const bmqt::Version& rhs)
191{
192 return lhs.major() != rhs.major() || lhs.minor() != rhs.minor();
193}
194
195inline bool bmqt::operator<(const bmqt::Version& lhs, const bmqt::Version& rhs)
196{
197 return lhs.major() < rhs.major() ||
198 (lhs.major() == rhs.major() && lhs.minor() < rhs.minor());
199}
200
201} // close enterprise namespace
202
203#endif
A version consisting of a major and minor version number.
Definition bmqt_version.h:58
unsigned char major() const
Return the major part of the version.
Definition bmqt_version.h:164
Version & setMajor(unsigned char value)
Definition bmqt_version.h:151
unsigned char minor() const
Return the minor part of the version.
Definition bmqt_version.h:169
Version()
Definition bmqt_version.h:136
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
Version & setMinor(unsigned char value)
Definition bmqt_version.h:157
bsl::ostream & operator<<(bsl::ostream &stream, CompressionAlgorithmType::Enum value)
Definition bmqt_compressionalgorithmtype.h:141
bool operator!=(const CorrelationId &lhs, const CorrelationId &rhs)
Definition bmqt_correlationid.h:582
bool operator==(const CorrelationId &lhs, const CorrelationId &rhs)
Definition bmqt_correlationid.h:576
bool operator<(const CorrelationId &lhs, const CorrelationId &rhs)
Definition bmqt_correlationid.h:588
Definition bmqa_abstractsession.h:42