[INIT] move VersionString code to base/version

This commit is contained in:
Laurent Perron
2021-11-28 12:57:35 +01:00
parent faf7cb9c8d
commit cd739ce7fd
3 changed files with 15 additions and 4 deletions

View File

@@ -13,10 +13,18 @@
#include <string>
#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

View File

@@ -14,12 +14,18 @@
#ifndef OR_TOOLS_BASE_VERSION_H_
#define OR_TOOLS_BASE_VERSION_H_
#include <string>
namespace operations_research {
int OrToolsMajorVersion();
int OrToolsMinorVersion();
int OrToolsPatchVersion();
std::string OrToolsVersionString();
} // namespace operations_research
#endif // OR_TOOLS_BASE_VERSION_H_

View File

@@ -18,7 +18,6 @@
#include <vector>
#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();
}
};