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 
25 namespace ignition
26 {
27  namespace math
28  {
29  // Forward declare private data class
30  class SemanticVersionPrivate;
31 
38  {
41  public: SemanticVersion();
42 
45  // cppcheck-suppress noExplicitConstructor
46  public: SemanticVersion(const std::string &_v);
47 
50  public: SemanticVersion(const SemanticVersion &_copy);
51 
55  public: SemanticVersion &operator=(const SemanticVersion &_other);
56 
63  public: SemanticVersion(const unsigned int _major,
64  const unsigned int _minor = 0,
65  const unsigned int _patch = 0,
66  const std::string &_prerelease = "",
67  const std::string &_build = "");
68 
70  public: ~SemanticVersion();
71 
76  public: bool Parse(const std::string &_versionStr);
77 
80  public: std::string Version() const;
81 
84  public: unsigned int Major() const;
85 
88  public: unsigned int Minor() const;
89 
92  public: unsigned int Patch() const;
93 
97  public: std::string Prerelease() const;
98 
103  public: std::string Build() const;
104 
108  public: bool operator<(const SemanticVersion &_other) const;
109 
113  public: bool operator<=(const SemanticVersion &_other) const;
114 
118  public: bool operator>(const SemanticVersion &_other) const;
119 
123  public: bool operator>=(const SemanticVersion &_other) const;
124 
128  public: bool operator==(const SemanticVersion &_other) const;
129 
133  public: bool operator!=(const SemanticVersion &_other) const;
134 
139  public: friend std::ostream &operator<<(std::ostream &_out,
140  const SemanticVersion &_v)
141  {
142  _out << _v.Version();
143  return _out;
144  }
145 
146 #ifdef _WIN32
147 // Disable warning C4251 which is triggered by
148 // std::unique_ptr
149 #pragma warning(push)
150 #pragma warning(disable: 4251)
151 #endif
152  private: std::unique_ptr<SemanticVersionPrivate> dataPtr;
154 #ifdef _WIN32
155 #pragma warning(pop)
156 #endif
157  };
158  }
159 }
160 #endif
std::string Version() const
Returns the version as a string.
ignition/math/SemanticVersion.hh
Definition: SemanticVersion.hh:37
#define IGNITION_VISIBLE
Use to represent "symbol visible" if supported.
Definition: System.hh:59
friend std::ostream & operator<<(std::ostream &_out, const SemanticVersion &_v)
Stream insertion operator.
Definition: SemanticVersion.hh:139
Definition: Angle.hh:38