Celeritas 0.7.0-9+develop.0ac2b625d
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends | List of all members
celeritas::Version Class Reference

Simple version comparison. More...

#include <Version.hh>

Public Types

Type aliases
using size_type = unsigned int
 
using ArrayT = std::array< size_type, 3 >
 

Public Member Functions

constexpr Version (size_type major, size_type minor=0, size_type patch=0)
 Construct from x.y.z integers.
 
constexpr Version ()
 Default (false) version.
 
Accessors
constexpr ArrayT const & value () const
 Get version as an array.
 
constexpr size_type major () const
 Get major version.
 
constexpr size_type minor () const
 Get minor version.
 
constexpr size_type patch () const
 Get patch version.
 
constexpr operator bool () const
 Whether the version is defined.
 

Static Public Member Functions

static Version from_string (std::string_view sv)
 Construct from a string "1.2.3".
 
static Version from_package (std::string_view p)
 Construct from a Celeritas-configured package name "vecgeom"/"VecGeom".
 
static constexpr Version from_hex_xxyyzz (size_type value)
 Construct from an 0xXXYYZZ integer.
 
static constexpr Version from_dec_xyz (size_type value)
 Construct from a decimal with XYZ or XXYZ.
 

Friends

bool operator== (Version const &lhs, Version const &rhs)
 
bool operator!= (Version const &lhs, Version const &rhs)
 
bool operator< (Version const &lhs, Version const &rhs)
 
bool operator> (Version const &lhs, Version const &rhs)
 
bool operator<= (Version const &lhs, Version const &rhs)
 
bool operator>= (Version const &lhs, Version const &rhs)
 
std::ostream & operator<< (std::ostream &, Version const &)
 Write to a stream.
 

Detailed Description

Simple version comparison.

This is intended to be constructed with version numbers from celeritas_cmake_strings.hh and used in unit tests. It can be used in if constexpr expressions with preprocessor macros. In the constructor documentation, x/y/z correspond to major/minor/patch.

Versions evaluate to false with the default constructor or when constructed from a Celeritas package that is disabled.

Constructors

With Geant4 enabled, these should all produce the same Version object:

Version::from_package("Geant4"); // [1]
Version::from_hex_xxyyzz(CELERITAS_GEANT4_VERSION); // [1, 2]
Version::from_dec_xyz(G4VERSION_NUMBER); // [2, 3]
static Version from_package(std::string_view p)
Construct from a Celeritas-configured package name "vecgeom"/"VecGeom".
Definition Version.cc:61
static constexpr Version from_hex_xxyyzz(size_type value)
Construct from an 0xXXYYZZ integer.
Definition src/corecel/sys/Version.hh:145
static constexpr Version from_dec_xyz(size_type value)
Construct from a decimal with XYZ or XXYZ.
Definition src/corecel/sys/Version.hh:156

but note that:

Example
assert(Version(4) == Version(4.0) == Version(4.0.0));
assert(Version(3.1) > Version(3));
constexpr Version()
Default (false) version.
Definition src/corecel/sys/Version.hh:88

Member Function Documentation

◆ from_dec_xyz()

constexpr Version celeritas::Version::from_dec_xyz ( size_type  value)
inlinestaticconstexpr

Construct from a decimal with XYZ or XXYZ.

This version scheme is used by Geant4.

◆ from_hex_xxyyzz()

constexpr Version celeritas::Version::from_hex_xxyyzz ( size_type  value)
inlinestaticconstexpr

Construct from an 0xXXYYZZ integer.

This version scheme is used by Celeritas. (The leading 0x prevents version 01 from turning the expression into an octal.)

◆ from_package()

Version celeritas::Version::from_package ( std::string_view  p)
static

Construct from a Celeritas-configured package name "vecgeom"/"VecGeom".

  • Invalid packages will raise RuntimeError.
  • Non-configured or unknown-version packages will return a false version.
  • Version suffixes (dev, beta, rc) will be truncated.

◆ from_string()

Version celeritas::Version::from_string ( std::string_view  sv)
static

Construct from a string "1.2.3".

Ignore prerelease and build metadata suffixes introduced by '-' or '+'. Empty strings will raise a RuntimeError.


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