71 std::string errMsg =
"Version File does not exist, generating a new one...";
74 std::cerr << errMsg << std::endl;
179 std::stringstream ver;
185 LOG_E(
"Version should not be 0.0, something is wrong...")
194 std::stringstream ver;
202 if (temp.size() == 4)
204 ver.str(std::string());
205 ver << temp[2] << temp[3];
214 ver << std::setfill(
'0') << std::setw(2) << date.
GetMonth();
227 std::cerr <<
"\nChecking for an HG repo..." << std::endl;
233 std::cerr <<
"\nChecking for a GIT repo..." << std::endl;
238 LOG_E(
"No .hg or .git folders found at the repo path. \nRepo Path: " +
mRepoPath);
241 std::cerr <<
".hg (HG Repo) or .git (Git Repo) is needed for this to work. Check that an HG or Git command line client is present." << std::endl;
252 return trUtil::StringUtils::FromString<int>(rev);
static const std::string BUILD_VERSION
void SetBuildVersion(int build)
Sets the Build part of the version string.
void SetMinorVersion(int min)
Sets the Minor part of the version string.
This is the exception class used throughout the engine.
void IncrementVersion()
Increments the version number of the build by one and sets the YYMM to current date.
void GenerateVersionStructure()
Generates a copy of the version file in RAM.
virtual bool ReadFromFile(std::string fileName)
Reads from a file and parses the JSON into a Root node.
void UpdateVersion()
Updates the version file to the most recent HG/Git Revision and YTMM.
std::string GetYYMMVersion()
Gets the Year/Month part of the version string.
virtual void SetString(const std::string &key, const std::string &value) override
Sets the String to be stored at the given key.
void SetVersion(int maj, int min, std::string yymm, int build)
Sets the version numbers.
virtual int GetInt(const std::string &key) const override
Returns the Integer value stored at the given key.
TR_UTIL_EXPORT std::string GetRootPath()
Get the root path to the engine (equivalent to the TR_ROOT environment) If the TR_ROOT environment is...
std::string RunCommand(const char *cmd)
Runs a command on the console, and returns the console printout in a form of a string.
static const std::string MIN_VERSION
int GetBuildVersion()
Gets the Build part of the version string.
static const std::string MAJ_VERSION
static const std::string YYMM_VERSION
void SaveVersionFile()
Saves the version file currently in RAM to default location.
static const std::string STR_BLANK("")
Constant value for a blank String.
#define LOG_W(msg)
Log a WARNING message.
int GetCurrentCommitNum()
Returns the current system HG/Git revision number.
virtual bool FileExists()
Returns true if the file name and path exist on the HD.
virtual void SetFilePath(std::string newPath)
Sets the path of where the file will be read from or written to.
void LogException(trUtil::Logging::LogLevel level=trUtil::Logging::LogLevel::LOG_ERROR) const
Logs the exception to the default logger.
int GetMajorVersion()
Gets the Major part of the version string.
virtual std::string GetFilePath() const
Returns the path of where the file is read or written to.
void TR_UTIL_EXPORT FindAndReplace(std::string &modifiedString, const std::string &findWhat, const std::string &replaceWith)
Finds all instances of the findWhat string in the string modifiedString and replaces them with the re...
void SetMajorVersion(int maj)
Sets the Major part of the version string.
static const std::string VERSION_FILE_NAME
virtual const std::string GetString(const std::string &key) const override
Returns the String value stored at the given key.
void TR_UTIL_EXPORT TextColor(TXT_COLOR TextColor)
Changes Text color in the console window....
TR_UTIL_EXPORT std::string GetConfigPath()
Gets configuration path.
virtual void SetInt(const std::string &key, const int &value) override
Sets the Integer value to be stored at the given key.
A utility to read and control the engines version numbers.
#define LOG_E(msg)
Log an ERROR message.
void SetYYMMVersion(std::string yymm)
Sets the Year/Month part of the version string.
std::string GetVersionString()
Returns the full version string.
virtual bool WriteToFile(std::string fileName)
Writes the internal Root Node to a JSON file.
static FileUtils & GetInstance()
Character separating the parts of a file path.
Namespace that holds various utility classes for the engine.
unsigned GetMonth() const
Gets the month.
int GetMinorVersion()
Gets the Minor part of the version string.
unsigned GetYear() const
Gets the year.
virtual void SetFileName(std::string fileName)
Sets a new file name.
std::string GetTodaysVersionDate()
Returns todays date in the YYMM format as string.