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 namespace IGNITION_MATH_VERSION_NAMESPACE
31  {
32  // Forward declare private data class
33  class SemanticVersionPrivate;
34 
40  class IGNITION_MATH_VISIBLE SemanticVersion
41  {
44  public: SemanticVersion();
45 
48  public: explicit SemanticVersion(const std::string &_v);
49 
52  public: SemanticVersion(const SemanticVersion &_copy);
53 
57  public: SemanticVersion &operator=(const SemanticVersion &_other);
58 
65  public: SemanticVersion(const unsigned int _major,
66  const unsigned int _minor = 0,
67  const unsigned int _patch = 0,
68  const std::string &_prerelease = "",
69  const std::string &_build = "");
70 
72  public: ~SemanticVersion();
73 
78  public: bool Parse(const std::string &_versionStr);
79 
82  public: std::string Version() const;
83 
86  public: unsigned int Major() const;
87 
90  public: unsigned int Minor() const;
91 
94  public: unsigned int Patch() const;
95 
99  public: std::string Prerelease() const;
100 
105  public: std::string Build() const;
106 
110  public: bool operator<(const SemanticVersion &_other) const;
111 
115  public: bool operator<=(const SemanticVersion &_other) const;
116 
120  public: bool operator>(const SemanticVersion &_other) const;
121 
125  public: bool operator>=(const SemanticVersion &_other) const;
126 
130  public: bool operator==(const SemanticVersion &_other) const;
131 
135  public: bool operator!=(const SemanticVersion &_other) const;
136 
141  public: friend std::ostream &operator<<(std::ostream &_out,
142  const SemanticVersion &_v)
143  {
144  _out << _v.Version();
145  return _out;
146  }
147 
148 #ifdef _WIN32
149 // Disable warning C4251 which is triggered by
150 // std::unique_ptr
151 #pragma warning(push)
152 #pragma warning(disable: 4251)
153 #endif
154  private: std::unique_ptr<SemanticVersionPrivate> dataPtr;
156 #ifdef _WIN32
157 #pragma warning(pop)
158 #endif
159  };
160  }
161  }
162 }
163 #endif
std::string Version() const
Returns the version as a string.
ignition/math/SemanticVersion.hh
Definition: SemanticVersion.hh:40
friend std::ostream & operator<<(std::ostream &_out, const SemanticVersion &_v)
Stream insertion operator.
Definition: SemanticVersion.hh:141
Definition: Angle.hh:39