Ignition Math

API Reference

6.4.0
SemanticVersion.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Open Source Robotics Foundation
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 */
17 
18 #ifndef IGNITION_MATH_SEMANTICVERSION_HH_
19 #define IGNITION_MATH_SEMANTICVERSION_HH_
20 
21 #include <memory>
22 #include <string>
23 #include <ignition/math/Helpers.hh>
24 #include <ignition/math/config.hh>
25 
26 namespace ignition
27 {
28  namespace math
29  {
30  // Inline bracket to help doxygen filtering.
31  inline namespace IGNITION_MATH_VERSION_NAMESPACE {
32  //
33  // Forward declare private data class
34  class SemanticVersionPrivate;
35 
41  class IGNITION_MATH_VISIBLE SemanticVersion
42  {
45  public: SemanticVersion();
46 
49  public: explicit SemanticVersion(const std::string &_v);
50 
53  public: SemanticVersion(const SemanticVersion &_copy);
54 
58  public: SemanticVersion &operator=(const SemanticVersion &_other);
59 
66  public: SemanticVersion(const unsigned int _major,
67  const unsigned int _minor = 0,
68  const unsigned int _patch = 0,
69  const std::string &_prerelease = "",
70  const std::string &_build = "");
71 
73  public: ~SemanticVersion();
74 
79  public: bool Parse(const std::string &_versionStr);
80 
83  public: std::string Version() const;
84 
87  public: unsigned int Major() const;
88 
91  public: unsigned int Minor() const;
92 
95  public: unsigned int Patch() const;
96 
100  public: std::string Prerelease() const;
101 
106  public: std::string Build() const;
107 
111  public: bool operator<(const SemanticVersion &_other) const;
112 
116  public: bool operator<=(const SemanticVersion &_other) const;
117 
121  public: bool operator>(const SemanticVersion &_other) const;
122 
126  public: bool operator>=(const SemanticVersion &_other) const;
127 
131  public: bool operator==(const SemanticVersion &_other) const;
132 
136  public: bool operator!=(const SemanticVersion &_other) const;
137 
142  public: friend std::ostream &operator<<(std::ostream &_out,
143  const SemanticVersion &_v)
144  {
145  _out << _v.Version();
146  return _out;
147  }
148 
149 #ifdef _WIN32
150 // Disable warning C4251 which is triggered by
151 // std::unique_ptr
152 #pragma warning(push)
153 #pragma warning(disable: 4251)
154 #endif
157 #ifdef _WIN32
158 #pragma warning(pop)
159 #endif
160  };
161  }
162  }
163 }
164 #endif
std::string Version() const
Returns the version as a string.
STL class.
Version comparison class based on Semantic Versioning 2.0.0 http://semver.org/ Compares versions and ...
Definition: SemanticVersion.hh:41
friend std::ostream & operator<<(std::ostream &_out, const SemanticVersion &_v)
Stream insertion operator.
Definition: SemanticVersion.hh:142
Definition: Angle.hh:42
STL class.