![]() |
RedFlame v0.1.1
A high intensity flame eminating from software
|
Captured information about a program's build. More...
#include <BuildInfo.h>
Public Member Functions | |
Lifecycle | |
BuildInfo (std::string_view appName) | |
BuildInfo (std::string_view appName, unsigned bldMajor, unsigned bldMinor, unsigned bldPatch, unsigned bldNumber, unsigned bldEpochSecs, std::string_view bldDateTime, std::string_view bldCreator, std::string_view bldBranch, std::string_view bldCommitHash) | |
~BuildInfo () | |
Observers | |
std::string_view | appName () const |
std::string_view | quadlet () const |
std::string_view | triplet () const |
std::string_view | doublet () const |
std::string_view | dateTime () const |
std::string_view | creator () const |
std::string_view | branch () const |
std::string_view | commitHash () const |
unsigned | major () const |
unsigned | minor () const |
unsigned | patch () const |
unsigned | bldnum () const |
unsigned | epoch () const |
std::string | shortInfo () const |
std::string | fullInfo () const |
Captured information about a program's build.
Build information is specified at constructor time. This class makes build information available to the program in several forms.
The calling program is responsible for obtaining and supplying initial build information to the constructor.
BuildInfo::BuildInfo | ( | std::string_view | appName | ) |
Construct a BuildInfo object with information obtained from BuildInfoDefs.h, an autogenerated file created by CMake.
If values in BuildInfoDefs.h are not appropriate for your application then an application can use the other constructor which lets you set all the values explicitly.
appName | The name of the application. |
BuildInfo::BuildInfo | ( | std::string_view | appName, |
unsigned | bldMajor, | ||
unsigned | bldMinor, | ||
unsigned | bldPatch, | ||
unsigned | bldNumber, | ||
unsigned | bldEpochSecs, | ||
std::string_view | bldDateTime, | ||
std::string_view | bldCreator, | ||
std::string_view | bldBranch, | ||
std::string_view | bldCommitHash ) |
Construct a BuildInfo object with the supplied build info.
appName | The name of the application. |
bldMajor | The major version. |
bldMinor | The minor version. |
bldPatch | The patch version |
bldNumber | The build number. For reproducible builds a changing build number should be avoided, in which case it is recommended to set this bldNumber to same value as bldEpochSecs. |
bldEpochSecs | Supply the build date and time as a Unix time stamp in seconds. For reproducible builds this value might come from the Unix timestamp of the last code commit in a git repository, not the actual time of the build as given by the build system or C preprocessor. |
bldDateTime | The date and time of the build in string format in accordance with RFC 3339 format. For reproducible builds this value should be the string representation the bldEpochSecs in RFC3339. |
bldCreator | The name of the user that performs the build. Usually this comes from environment variable ${LOGUSER} during the build process. |
bldBranch | The name of the repository branch the build is associated. |
bldCommitHash | The hash of the last commit associated with this build. |
BuildInfo::~BuildInfo | ( | ) |
Destructor.
std::string_view BuildInfo::appName | ( | ) | const |
Returns the application's name.
unsigned BuildInfo::bldnum | ( | ) | const |
Returns the build number.
std::string_view BuildInfo::branch | ( | ) | const |
Returns the Git branch the associated with this build.
std::string_view BuildInfo::commitHash | ( | ) | const |
Returns the hash of the last commit on this branch at the time the build was triggered.
std::string_view BuildInfo::creator | ( | ) | const |
Returns the user that triggered the build.
std::string_view BuildInfo::dateTime | ( | ) | const |
Returns the date & time of the build as a string formated in accordance with RFC 3339 (https://tools.ietf.org/html/rfc3339) which is itself a subset of ISO 8601 date time interchange format.
std::string_view BuildInfo::doublet | ( | ) | const |
Returns the string major.minor
unsigned BuildInfo::epoch | ( | ) | const |
Returns the epoch in seconds.
std::string BuildInfo::fullInfo | ( | ) | const |
Returns a long formatted string of version and build info.
Example formatted output looks like this:
unsigned BuildInfo::major | ( | ) | const |
Returns the major version.
unsigned BuildInfo::minor | ( | ) | const |
Returns the minor version.
unsigned BuildInfo::patch | ( | ) | const |
Returns the patch version.
std::string_view BuildInfo::quadlet | ( | ) | const |
Returns the string major.minor.patch-bldNum
std::string BuildInfo::shortInfo | ( | ) | const |
Returns a short formatted string containing version info.
This is just the quadlet prepended with the application name.
Example formatted output looks like this:
AppName v2.3.1-1608191117
std::string_view BuildInfo::triplet | ( | ) | const |
Returns the string major.minor.patch.