RedFlame v0.1.1
A high intensity flame eminating from software
Loading...
Searching...
No Matches
Gen::BuildInfo Class Reference

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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ BuildInfo() [1/2]

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.

Parameters
appNameThe name of the application.

◆ BuildInfo() [2/2]

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.

Parameters
appNameThe name of the application.
bldMajorThe major version.
bldMinorThe minor version.
bldPatchThe patch version
bldNumberThe 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.
bldEpochSecsSupply 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.
bldDateTimeThe 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.
bldCreatorThe name of the user that performs the build. Usually this comes from environment variable ${LOGUSER} during the build process.
bldBranchThe name of the repository branch the build is associated.
bldCommitHashThe hash of the last commit associated with this build.

◆ ~BuildInfo()

BuildInfo::~BuildInfo ( )

Destructor.

Member Function Documentation

◆ appName()

std::string_view BuildInfo::appName ( ) const

Returns the application's name.

Returns
The app name.

◆ bldnum()

unsigned BuildInfo::bldnum ( ) const

Returns the build number.

Returns
The build number.

◆ branch()

std::string_view BuildInfo::branch ( ) const

Returns the Git branch the associated with this build.

Returns
The name of the branch.

◆ commitHash()

std::string_view BuildInfo::commitHash ( ) const

Returns the hash of the last commit on this branch at the time the build was triggered.

Returns
The commit hash.

◆ creator()

std::string_view BuildInfo::creator ( ) const

Returns the user that triggered the build.

Returns
The user name that triggered the build.

◆ dateTime()

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.

Returns
The date and time of the build.

◆ doublet()

std::string_view BuildInfo::doublet ( ) const

Returns the string major.minor

Returns
major.minor as a string

◆ epoch()

unsigned BuildInfo::epoch ( ) const

Returns the epoch in seconds.

Returns
The epoch in seconds.

◆ fullInfo()

std::string BuildInfo::fullInfo ( ) const

Returns a long formatted string of version and build info.

Example formatted output looks like this:

SampleApp v2.3.1-1608191117
Built by: Elvis
Build date: 2020-12-17T07:45:17Z
Build epoch: 1608191117
Build branch: empty (not in a repo)
Last commit hash: empty (not in a repo)
Returns
A long form of version info.

◆ major()

unsigned BuildInfo::major ( ) const

Returns the major version.

Returns
The major version number.

◆ minor()

unsigned BuildInfo::minor ( ) const

Returns the minor version.

Returns
The minor version number.

◆ patch()

unsigned BuildInfo::patch ( ) const

Returns the patch version.

Returns
The patch version number.

◆ quadlet()

std::string_view BuildInfo::quadlet ( ) const

Returns the string major.minor.patch-bldNum

Returns
major.minor.patch.bldNum as a string

◆ shortInfo()

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
Returns
A short form of version info.

◆ triplet()

std::string_view BuildInfo::triplet ( ) const

Returns the string major.minor.patch.

Returns
major.minor.patch as a string

The documentation for this class was generated from the following files: