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 <vector>
24 #include <string>
25 
26 namespace beast {
27 
36 {
37 public:
39 
43 
46 
47  SemanticVersion ();
48 
49  SemanticVersion (std::string const& version);
50 
55  bool parse (std::string const& input);
56 
58  std::string print () const;
59 
60  inline bool isRelease () const noexcept
61  {
63  }
64  inline bool isPreRelease () const noexcept
65  {
66  return !isRelease ();
67  }
68 };
69 
73 int compare (SemanticVersion const& lhs, SemanticVersion const& rhs);
74 
75 inline bool
77 {
78  return compare (lhs, rhs) == 0;
79 }
80 
81 inline bool
83 {
84  return compare (lhs, rhs) != 0;
85 }
86 
87 inline bool
89 {
90  return compare (lhs, rhs) >= 0;
91 }
92 
93 inline bool
95 {
96  return compare (lhs, rhs) <= 0;
97 }
98 
99 inline bool
101 {
102  return compare (lhs, rhs) > 0;
103 }
104 
105 inline bool
107 {
108  return compare (lhs, rhs) < 0;
109 }
110 
111 } // beast
112 
113 #endif
beast::SemanticVersion::isRelease
bool isRelease() const noexcept
Definition: SemanticVersion.h:60
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:228
beast::operator<=
bool operator<=(SemanticVersion const &lhs, SemanticVersion const &rhs)
Definition: SemanticVersion.h:94
beast::operator>
bool operator>(SemanticVersion const &lhs, SemanticVersion const &rhs)
Definition: SemanticVersion.h:100
beast::compare
int compare(SemanticVersion const &lhs, SemanticVersion const &rhs)
Compare two SemanticVersions against each other.
Definition: SemanticVersion.cpp:251
beast::SemanticVersion::isPreRelease
bool isPreRelease() const noexcept
Definition: SemanticVersion.h:64
beast::SemanticVersion
A Semantic Version number.
Definition: SemanticVersion.h:35
beast::operator>=
bool operator>=(SemanticVersion const &lhs, SemanticVersion const &rhs)
Definition: SemanticVersion.h:88
beast::SemanticVersion::SemanticVersion
SemanticVersion()
Definition: SemanticVersion.cpp:148
beast::operator!=
bool operator!=(LockFreeStackIterator< Container, LhsIsConst > const &lhs, LockFreeStackIterator< Container, RhsIsConst > const &rhs)
Definition: LockFreeStack.h:122
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:162
beast::operator<
bool operator<(SemanticVersion const &lhs, SemanticVersion const &rhs)
Definition: SemanticVersion.h:106
beast::SemanticVersion::patchVersion
int patchVersion
Definition: SemanticVersion.h:42
std::vector::empty
T empty(T... args)
beast
Definition: base_uint.h:582
string