TrueReality  v0.1.1912
VersionUtil.h
Go to the documentation of this file.
1 /*
2 * True Reality Open Source Game and Simulation Engine
3 * Copyright © 2021 Acid Rain Studios LLC
4 *
5 * This library is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Lesser General Public License as published by the Free
7 * Software Foundation; either version 3.0 of the License, or (at your option)
8 * any later version.
9 *
10 * This library is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this library; if not, write to the Free Software Foundation, Inc.,
17 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * @author Maxim Serebrennik
20 */
21 
22 #pragma once
23 
24 #include <trUtil/Export.h>
25 
26 #include <trUtil/StringUtils.h>
27 #include <trUtil/JSON/File.h>
28 
29 #include <string>
30 
36 namespace trUtil
37 {
46  {
47  public:
48 
49  const static std::string VERSION_FILE_NAME;
50  const static std::string MAJ_VERSION;
51  const static std::string MIN_VERSION;
52  const static std::string YYMM_VERSION;
53  const static std::string BUILD_VERSION;
54 
60  VersionUtil();
61 
69  VersionUtil(std::string fileName);
70 
79  VersionUtil(std::string fileName, std::string filePath);
80 
90  VersionUtil(std::string fileName, std::string filePath, std::string repoPath);
91 
97  ~VersionUtil();
98 
104  void SaveVersionFile();
105 
116  void SetVersion(int maj, int min, std::string yymm, int build);
117 
128  void SetVersion(int maj, int min, int yymm, int build);
129 
135  void GenerateVersionStructure();
136 
142  void IncrementVersion();
143 
151  void SetMajorVersion(int maj);
152 
160  int GetMajorVersion();
161 
169  void SetMinorVersion(int min);
170 
178  int GetMinorVersion();
179 
187  std::string GetYYMMVersion();
188 
196  void SetYYMMVersion(std::string yymm);
197 
205  void SetYYMMVersion(int yymm);
206 
214  void SetBuildVersion(int build);
215 
223  int GetBuildVersion();
224 
232  std::string GetVersionString();
233 
239  void UpdateVersion();
240 
241  private:
243 
244  std::string mRepoPath = trUtil::StringUtils::STR_BLANK;
245 
253  std::string GetTodaysVersionDate();
254 
265  int GetCurrentCommitNum();
266  };
267 }
static const std::string BUILD_VERSION
Definition: VersionUtil.h:53
A file.
Definition: File.h:45
static const std::string MIN_VERSION
Definition: VersionUtil.h:51
static const std::string MAJ_VERSION
Definition: VersionUtil.h:50
static const std::string YYMM_VERSION
Definition: VersionUtil.h:52
static const std::string STR_BLANK("")
Constant value for a blank String.
static const std::string VERSION_FILE_NAME
Definition: VersionUtil.h:49
A utility to read and control the engines version numbers.
Definition: VersionUtil.h:45
void SetVersion(trUtil::VersionUtil &ver, int maj, int min, std::string yymm, int build)
Sets all the version numbers.
void UpdateVersion(trUtil::VersionUtil &ver)
Updates the version from the current .hg revision and YYMM.
A class that represents date time utility.
JSON::File mVersion
Definition: VersionUtil.h:242
Namespace that holds various utility classes for the engine.
Definition: SmrtPtr.h:208