rippled
SemanticVersion.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of Beast: https://github.com/vinniefalco/Beast
4  Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #ifndef BEAST_MODULE_CORE_DIAGNOSTIC_SEMANTICVERSION_H_INCLUDED
21 #define BEAST_MODULE_CORE_DIAGNOSTIC_SEMANTICVERSION_H_INCLUDED
22 
23 #include <string>
24 #include <vector>
25 
26 namespace beast {
27 
36 {
37 public:
39 
43 
46 
48 
49  SemanticVersion(std::string const& version);
50 
55  bool
56  parse(std::string const& input);
57 
60  print() const;
61 
62  inline bool
63  isRelease() const noexcept
64  {
66  }
67  inline bool
68  isPreRelease() const noexcept
69  {
70  return !isRelease();
71  }
72 };
73 
77 int
78 compare(SemanticVersion const& lhs, SemanticVersion const& rhs);
79 
80 inline bool
82 {
83  return compare(lhs, rhs) == 0;
84 }
85 
86 inline bool
88 {
89  return compare(lhs, rhs) != 0;
90 }
91 
92 inline bool
94 {
95  return compare(lhs, rhs) >= 0;
96 }
97 
98 inline bool
100 {
101  return compare(lhs, rhs) <= 0;
102 }
103 
104 inline bool
106 {
107  return compare(lhs, rhs) > 0;
108 }
109 
110 inline bool
112 {
113  return compare(lhs, rhs) < 0;
114 }
115 
116 } // namespace beast
117 
118 #endif
beast::SemanticVersion::isRelease
bool isRelease() const noexcept
Definition: SemanticVersion.h:63
std::string
STL class.
beast::operator==
bool operator==(LockFreeStackIterator< Container, LhsIsConst > const &lhs, LockFreeStackIterator< Container, RhsIsConst > const &rhs)
Definition: LockFreeStack.h:115
vector
beast::SemanticVersion::print
std::string print() const
Produce a string from semantic version components.
Definition: SemanticVersion.cpp:236
beast::operator<=
bool operator<=(SemanticVersion const &lhs, SemanticVersion const &rhs)
Definition: SemanticVersion.h:99
beast::operator>
bool operator>(SemanticVersion const &lhs, SemanticVersion const &rhs)
Definition: SemanticVersion.h:105
beast::compare
int compare(SemanticVersion const &lhs, SemanticVersion const &rhs)
Compare two SemanticVersions against each other.
Definition: SemanticVersion.cpp:259
beast::SemanticVersion::isPreRelease
bool isPreRelease() const noexcept
Definition: SemanticVersion.h:68
beast::SemanticVersion
A Semantic Version number.
Definition: SemanticVersion.h:35
beast::operator>=
bool operator>=(SemanticVersion const &lhs, SemanticVersion const &rhs)
Definition: SemanticVersion.h:93
beast::SemanticVersion::SemanticVersion
SemanticVersion()
Definition: SemanticVersion.cpp:156
beast::operator!=
bool operator!=(LockFreeStackIterator< Container, LhsIsConst > const &lhs, LockFreeStackIterator< Container, RhsIsConst > const &rhs)
Definition: LockFreeStack.h:124
beast::SemanticVersion::minorVersion
int minorVersion
Definition: SemanticVersion.h:41
beast::SemanticVersion::preReleaseIdentifiers
identifier_list preReleaseIdentifiers
Definition: SemanticVersion.h:44
beast::SemanticVersion::metaData
identifier_list metaData
Definition: SemanticVersion.h:45
beast::SemanticVersion::majorVersion
int majorVersion
Definition: SemanticVersion.h:40
beast::SemanticVersion::parse
bool parse(std::string const &input)
Parse a semantic version string.
Definition: SemanticVersion.cpp:168
beast::operator<
bool operator<(SemanticVersion const &lhs, SemanticVersion const &rhs)
Definition: SemanticVersion.h:111
beast::SemanticVersion::patchVersion
int patchVersion
Definition: SemanticVersion.h:42
std::vector::empty
T empty(T... args)
beast
Definition: base_uint.h:641
string