Hoist version string to namespace level

This commit is contained in:
Nik Bougalis
2016-07-27 10:04:56 -07:00
parent 3b58e36621
commit 08ea245101
3 changed files with 10 additions and 33 deletions

View File

@@ -57,9 +57,6 @@ getCurrentProtocol();
/** The oldest protocol version we will accept. */ /** The oldest protocol version we will accept. */
ProtocolVersion const& getMinimumProtocol (); ProtocolVersion const& getMinimumProtocol ();
char const*
getRawVersionString();
} // BuildInfo (DEPRECATED) } // BuildInfo (DEPRECATED)
std::string std::string

View File

@@ -27,22 +27,15 @@ namespace ripple {
namespace BuildInfo { namespace BuildInfo {
char const* getRawVersionString () //------------------------------------------------------------------------------
{ char const* const versionString =
static char const* const rawText =
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// // The build version number. You must edit this for each release
// The build version number (edit this for each release) // and follow the format described here at http://semver.org/
// //
"0.32.1" "0.32.1"
//
// Must follow the format described here:
//
// http://semver.org/
//
#if defined(DEBUG) || defined(SANITIZER) #if defined(DEBUG) || defined(SANITIZER)
"+" "+"
#ifdef DEBUG #ifdef DEBUG
@@ -60,9 +53,6 @@ char const* getRawVersionString ()
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
; ;
return rawText;
}
ProtocolVersion const& ProtocolVersion const&
getCurrentProtocol () getCurrentProtocol ()
{ {
@@ -108,18 +98,19 @@ std::string const&
getVersionString () getVersionString ()
{ {
static std::string const value = [] { static std::string const value = [] {
std::string const versionString = getRawVersionString (); std::string const s = versionString;
beast::SemanticVersion v; beast::SemanticVersion v;
if (!v.parse (versionString) || v.print () != versionString) if (!v.parse (s) || v.print () != s)
LogicError (versionString + ": Bad server version string"); LogicError (s + ": Bad server version string");
return versionString; return s;
}(); }();
return value; return value;
} }
std::string const& getFullVersionString () std::string const& getFullVersionString ()
{ {
static std::string const value = "rippled-" + getVersionString (); static std::string const value =
"rippled-" + getVersionString();
return value; return value;
} }

View File

@@ -27,16 +27,6 @@ namespace ripple {
class BuildInfo_test : public beast::unit_test::suite class BuildInfo_test : public beast::unit_test::suite
{ {
public: public:
void testVersion ()
{
testcase ("version");
beast::SemanticVersion v;
BEAST_EXPECT(v.parse (BuildInfo::getRawVersionString ()));
}
ProtocolVersion ProtocolVersion
from_version (std::uint16_t major, std::uint16_t minor) from_version (std::uint16_t major, std::uint16_t minor)
{ {
@@ -97,7 +87,6 @@ public:
void run () void run ()
{ {
testVersion ();
testValues (); testValues ();
testStringVersion (); testStringVersion ();
testVersionPacking (); testVersionPacking ();