Gazebo Math

API Reference

6.15.1
gz/math/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 GZ_MATH_SEMANTICVERSION_HH_
19 #define GZ_MATH_SEMANTICVERSION_HH_
20 
21 #include <memory>
22 #include <string>
23 #include <gz/math/Helpers.hh>
24 #include <gz/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
unsigned int Major() const
Get the major number.
Definition: gz/math/AdditivelySeparableScalarField3.hh:27
STL class.
SemanticVersion & operator=(const SemanticVersion &_other)
Assignment operator.
bool operator<=(const SemanticVersion &_other) const
Less than or equal comparison operator.
bool operator<(const SemanticVersion &_other) const
Less than comparison operator.
std::string Build() const
Get the build metadata string. Build meta data is not used when determining precedence.
Version comparison class based on Semantic Versioning 2.0.0 http://semver.org/ Compares versions and ...
Definition: gz/math/SemanticVersion.hh:41
std::string Version() const
Returns the version as a string.
unsigned int Minor() const
Get the minor number.
std::string Prerelease() const
Get the prerelease string.
bool operator>=(const SemanticVersion &_other) const
Greater than or equal comparison operator.
STL class.
friend std::ostream & operator<<(std::ostream &_out, const SemanticVersion &_v)
Stream insertion operator.
Definition: gz/math/SemanticVersion.hh:142
bool operator>(const SemanticVersion &_other) const
Greater than comparison operator.
SemanticVersion()
Default constructor. Use the Parse function to populate an instance with version information.
bool Parse(const std::string &_versionStr)
Parse a version string and set the major, minor, patch numbers, and prerelease and build strings.
bool operator!=(const SemanticVersion &_other) const
Inequality comparison operator.
unsigned int Patch() const
Get the patch number.
bool operator==(const SemanticVersion &_other) const
Equality comparison operator.