OnixS C++ CME MDP Streamlined Market Data Handler  1.2.0
API Documentation
Version.h
Go to the documentation of this file.
1 // Copyright Onix Solutions Limited [OnixS]. All rights reserved.
2 //
3 // This software owned by Onix Solutions Limited [OnixS] and is
4 // protected by copyright law and international copyright treaties.
5 //
6 // Access to and use of the software is governed by the terms of the applicable
7 // OnixS Software Services Agreement (the Agreement) and Customer end user license
8 // agreements granting a non-assignable, non-transferable and non-exclusive license
9 // to use the software for it's own data processing purposes under the terms defined
10 // in the Agreement.
11 //
12 // Except as otherwise granted within the terms of the Agreement, copying or
13 // reproduction of any part of this source code or associated reference material
14 // to any other location for further reproduction or redistribution, and any
15 // amendments to this copyright notice, are expressly prohibited.
16 //
17 // Any reproduction or redistribution for sale or hiring of the Software not in
18 // accordance with the terms of the Agreement is a violation of copyright law.
19 //
20 
21 #pragma once
22 
23 #include <string>
24 
27 
29 
30 /// Identifies version of the product.
31 ///
32 /// Provides access to single components
33 /// which compound whole version, comparing
34 /// and serialization/deserialization facilities.
36 {
37 public:
38  /// Alias for the numeric component of version.
39  typedef UInt16 Component;
40 
41  /// Initializes instances from all the components.
43  Component major,
44  Component minor,
45  Component patch)
46  : major_(major)
47  , minor_(minor)
48  , patch_(patch)
49  {
50  }
51 
52  /// Initializes as clone of other instance.
54  const Version& other)
55  : major_(other.major_)
56  , minor_(other.minor_)
57  , patch_(other.patch_)
58  {
59  }
60 
61  /// 'major' component of version.
62  Component major() const
63  {
64  return major_;
65  }
66 
67  /// 'minor' component of version.
68  Component minor() const
69  {
70  return minor_;
71  }
72 
73  /// 'patch' component of version.
74  Component patch() const
75  {
76  return patch_;
77  }
78 
79  /// Re-initializes instance as copy of other one.
80  Version&
81  operator =(
82  const Version& other)
83  {
84  major_ = other.major_;
85  minor_ = other.minor_;
86  patch_ = other.patch_;
87 
88  return *this;
89  }
90 
91  /// Identifies current version of the product.
93  static Version current();
94 
95 private:
96  Component major_;
97  Component minor_;
98  Component patch_;
99 };
100 
101 /// Compares with other instance for equality.
102 inline
103 bool
105  const Version& left,
106  const Version& right)
107 {
108  return
109  (
110  left.major() == right.major() &&
111  left.minor() == right.minor() &&
112  left.patch() == right.patch()
113  );
114 }
115 
116 inline
117 bool
119  const Version& left,
120  const Version& right)
121 {
122  return !(left == right);
123 }
124 
125 inline
126 bool
128  const Version& left,
129  const Version& right)
130 {
131  return (
132  left.major() < right.major()
133  || (
134  left.major() == right.major()
135  &&
136  left.minor() < right.minor())
137  || (
138  left.major() == right.major()
139  &&
140  left.minor() == right.minor()
141  &&
142  left.patch() < right.patch())
143  );
144 }
145 
146 inline
147 bool
149  const Version& left,
150  const Version& right)
151 {
152  return (right < left);
153 }
154 
155 /// Extracts version from point-separated presentation.
156 /// Updates version parameter if buffer is parsed successfully.
158 bool
159 fromStr(
160  const Char*,
161  size_t,
162  Version&);
163 
164 /// Appends point-separated presentation of version to given string.
166 void
167 toStr(
168  std::string&,
169  const Version&);
170 
171 /// Serializes Version instance into point-separated presentation.
172 inline
173 std::string
175  const Version& version)
176 {
177  std::string str;
178 
179  toStr(str, version);
180 
181  return str;
182 }
183 
bool operator<(const Version &left, const Version &right)
Definition: Version.h:127
Identifies version of the product.
Definition: Version.h:35
bool operator!=(const Version &left, const Version &right)
Definition: Version.h:118
Version(const Version &other)
Initializes as clone of other instance.
Definition: Version.h:53
UInt16 UInt16
uInt16.
Definition: Fields.h:179
Component minor() const
&#39;minor&#39; component of version.
Definition: Version.h:68
Component major() const
&#39;major&#39; component of version.
Definition: Version.h:62
UInt16 Component
Alias for the numeric component of version.
Definition: Version.h:39
bool fromStr(const Char *, size_t, Version &)
Extracts version from point-separated presentation.
#define ONIXS_CMESTREAMLINEDMDH_NAMESPACE_END
Definition: Bootstrap.h:173
#define ONIXS_CMESTREAMLINEDMDH_LTWT_CLASS
Definition: Bootstrap.h:111
#define ONIXS_CMESTREAMLINEDMDH_EXPORTED
Definition: Compiler.h:160
char Char
Character type alias.
Definition: String.h:36
bool operator==(const Version &left, const Version &right)
Compares with other instance for equality.
Definition: Version.h:104
#define ONIXS_CMESTREAMLINEDMDH_LTWT_EXPORTED
Definition: Bootstrap.h:119
bool operator>(const Version &left, const Version &right)
Definition: Version.h:148
std::string toStr(const Version &version)
Serializes Version instance into point-separated presentation.
Definition: Version.h:174
Version(Component major, Component minor, Component patch)
Initializes instances from all the components.
Definition: Version.h:42
Component patch() const
&#39;patch&#39; component of version.
Definition: Version.h:74
#define ONIXS_CMESTREAMLINEDMDH_NAMESPACE_BEGIN
Definition: Bootstrap.h:169