From cd739ce7fd4b05dca2404e4f5a0177b69027b7ca Mon Sep 17 00:00:00 2001 From: Laurent Perron Date: Sun, 28 Nov 2021 12:57:35 +0100 Subject: [PATCH] [INIT] move VersionString code to base/version --- ortools/base/version.cc | 8 ++++++++ ortools/base/version.h | 6 ++++++ ortools/init/init.h | 5 +---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ortools/base/version.cc b/ortools/base/version.cc index 1d120dae8d..625b1a1a00 100644 --- a/ortools/base/version.cc +++ b/ortools/base/version.cc @@ -13,10 +13,18 @@ #include +#include "absl/strings/str_cat.h" + namespace operations_research { int OrToolsMajorVersion() { return OR_TOOLS_MAJOR; } + int OrToolsMinorVersion() { return OR_TOOLS_MINOR; } + int OrToolsPatchVersion() { return OR_TOOLS_PATCH; } +std::string OrToolsVersionString() { + return absl::StrCat(OR_TOOLS_MAJOR, ".", OR_TOOLS_MINOR, ".", OR_TOOLS_PATCH); +} + } // namespace operations_research diff --git a/ortools/base/version.h b/ortools/base/version.h index 4340aea67b..6781704df1 100644 --- a/ortools/base/version.h +++ b/ortools/base/version.h @@ -14,12 +14,18 @@ #ifndef OR_TOOLS_BASE_VERSION_H_ #define OR_TOOLS_BASE_VERSION_H_ +#include + namespace operations_research { int OrToolsMajorVersion(); + int OrToolsMinorVersion(); + int OrToolsPatchVersion(); +std::string OrToolsVersionString(); + } // namespace operations_research #endif // OR_TOOLS_BASE_VERSION_H_ diff --git a/ortools/init/init.h b/ortools/init/init.h index becb0991c9..c4b34499f8 100644 --- a/ortools/init/init.h +++ b/ortools/init/init.h @@ -18,7 +18,6 @@ #include #include "absl/flags/flag.h" -#include "absl/strings/str_cat.h" #include "ortools/base/logging.h" #include "ortools/base/version.h" #include "ortools/gurobi/environment.h" @@ -153,9 +152,7 @@ class OrToolsVersion { * Returns the string version of OR-Tools. */ static std::string VersionString() { - return absl::StrCat(::operations_research::OrToolsMajorVersion(), ".", - ::operations_research::OrToolsMinorVersion(), ".", - ::operations_research::OrToolsPatchVersion(), "."); + return ::operations_research::OrToolsVersionString(); } };