OnixS C++ CME MDP Premium Market Data Handler  5.8.9
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 
25 #include <OnixS/CME/MDH/String.h>
26 #include <OnixS/CME/MDH/Integral.h>
27 
29 
30 /// Alias for the version numeric component.
32 
33 /// Identifies version of the product.
34 ///
35 /// Provides access to single components
36 /// which compound whole version, comparing
37 /// and serialization/deserialization facilities.
39 {
40 public:
41  /// Alias for the numeric component.
43 
44  /// Initializes the instance from the given components.
45  Version(Component major, Component minor, Component patch)
46  : major_(major)
47  , minor_(minor)
48  , patch_(patch)
49  {
50  }
51 
52  /// Initializes as a copy of the other instance.
53  Version(const Version& other)
54  : major_(other.major_)
55  , minor_(other.minor_)
56  , patch_(other.patch_)
57  {
58  }
59 
60  /// 'major' component of the version.
61  Component(major)() const
62  {
63  return major_;
64  }
65 
66  /// 'minor' component of the version.
67  Component(minor)() const
68  {
69  return minor_;
70  }
71 
72  /// 'patch' component of the version.
73  Component patch() const
74  {
75  return patch_;
76  }
77 
78  /// Re-initializes the instance
79  /// as a copy of the other one.
80  Version& operator=(const Version& other)
81  {
82  major_ = other.major_;
83  minor_ = other.minor_;
84  patch_ = other.patch_;
85 
86  return *this;
87  }
88 
89  /// Identifies the current version of the product.
91  static Version current();
92 
93 private:
94  VersionComponent major_;
95  VersionComponent minor_;
96  VersionComponent patch_;
97 };
98 
99 /// Checks the given two instances for equality.
100 inline bool operator==(const Version& left, const Version& right)
101 {
102  return ((left.major)() == (right.major)() && (left.minor)() == (right.minor)() && left.patch() == right.patch());
103 }
104 
105 /// Checks the given two instances for inequality.
106 inline bool operator!=(const Version& left, const Version& right)
107 {
108  return !(left == right);
109 }
110 
111 /// Establishes the order
112 /// between the given instances.
113 inline bool operator<(const Version& left, const Version& right)
114 {
115  return (
116  (left.major)() < (right.major)() || ((left.major)() == (right.major)() && (left.minor)() < (right.minor)())
117  || ((left.major)() == (right.major)() && (left.minor)() == (right.minor)() && left.patch() < right.patch())
118  );
119 }
120 
121 /// Establishes the order
122 /// between the given instances.
123 inline bool operator>(const Version& left, const Version& right)
124 {
125  return (right < left);
126 }
127 
128 /// Extracts version from point-separated presentation.
129 /// Updates version parameter if buffer is parsed successfully.
131 bool fromStr(const Char*, size_t, Version&);
132 
133 /// Appends point-separated presentation of version to given string.
135 void toStr(std::string&, const Version&);
136 
137 /// Serializes Version instance into point-separated presentation.
138 inline std::string toStr(const Version& version)
139 {
140  std::string str;
141 
142  toStr(str, version);
143 
144  return str;
145 }
146 
Component() minor() const
&#39;minor&#39; component of the version.
Definition: Version.h:67
UInt16 VersionComponent
Alias for the version numeric component.
Definition: Version.h:31
VersionComponent Component
Alias for the numeric component.
Definition: Version.h:42
bool operator==(const Version &left, const Version &right)
Checks the given two instances for equality.
Definition: Version.h:100
bool operator>(const Version &left, const Version &right)
Establishes the order between the given instances.
Definition: Version.h:123
std::string toStr(const Version &version)
Serializes Version instance into point-separated presentation.
Definition: Version.h:138
#define ONIXS_CMEMDH_LTWT
Definition: Bootstrap.h:46
Version(const Version &other)
Initializes as a copy of the other instance.
Definition: Version.h:53
char Char
Character type alias.
Definition: String.h:36
Version & operator=(const Version &other)
Re-initializes the instance as a copy of the other one.
Definition: Version.h:80
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition: Bootstrap.h:67
bool operator!=(const Version &left, const Version &right)
Checks the given two instances for inequality.
Definition: Version.h:106
#define ONIXS_CMEMDH_EXPORTED
Definition: Compiler.h:160
Component() major() const
&#39;major&#39; component of the version.
Definition: Version.h:61
#define ONIXS_CMEMDH_LTWT_EXPORTED
Definition: Bootstrap.h:47
Identifies version of the product.
Definition: Version.h:38
UInt16 UInt16
uInt16 optional.
Definition: Fields.h:189
Version(Component major, Component minor, Component patch)
Initializes the instance from the given components.
Definition: Version.h:45
bool fromStr(const Char *, size_t, Version &)
Extracts version from point-separated presentation.
Component patch() const
&#39;patch&#39; component of the version.
Definition: Version.h:73
bool operator<(const Version &left, const Version &right)
Establishes the order between the given instances.
Definition: Version.h:113
#define ONIXS_CMEMDH_NAMESPACE_END
Definition: Bootstrap.h:68