Utility functions and classes¶
pni::nexus::Version
¶
-
class Version¶
a 3 number version class
Describes a version number.
Public Types
-
using NumberType = unsigned long¶
the number type used to represent version numbers
Public Functions
-
Version() noexcept¶
default constructor
Set all three version numbers to 0
-
Version(NumberType major, NumberType minor, NumberType patch) noexcept¶
constructor
- Parameters:
major – the major version number
minor – the minor version number
patch – the patch version number
-
Version(const Version&) = default¶
copy constructor
We can use the compiler provided default implementation here as all members are trivially copyable.
-
NumberType major() const noexcept¶
return the major version number
-
NumberType minor() const noexcept¶
return the minor version number
-
NumberType patch() const noexcept¶
return the patch version number
Public Static Functions
-
static Version from_string(const std::string &str)¶
read version from a string
The string must be formated as MAJOR.MINOR.PATCH. Otherwise a runtime exception will be thrown. Incomplete version numbers are permitted starting from MAJOR downwards. Non-existing elements of the version are assumed to be 0.
- Throws:
std::runtime_error – in the case of a malformed input string
- Parameters:
str – the string with the version number
- Returns:
a new instance of Version
-
PNINEXUS_EXPORT std::ostream &operator<<(std::ostream &stream, const Version &version)¶
output stream operator
Writes an instance of Version to a std::ostream. The output format is the same as for Version::to_string.
See also
- Parameters:
stream – the stream where to write the version
version – reference to the Version to write
- Returns:
modified version of std::ostream
-
PNINEXUS_EXPORT std::istream &operator>>(std::istream &stream, Version &version)¶
input stream operator
Read an instance of Version from a stream. The input format expected is the same as for Version::from_string.
See also
- Parameters:
stream – reference to the stream from which to read the Version
version – reference to the version to which to read
- Returns:
modified input stream
-
PNINEXUS_EXPORT bool operator==(const Version &lhs, const Version &rhs)¶
checks two version for equality
Two version are considered equal if all of their parts are equal.
- Parameters:
lhs – reference to the left hand side version
rhs – reference to the right hand side version
- Returns:
true if versions are equal, false otherwise
-
PNINEXUS_EXPORT bool operator!=(const Version &lhs, const Version &rhs)¶
checks if two versions are not equal
- Parameters:
lhs – reference to the left hand side version
rhs – reference to the right hand side version
- Returns:
true if versions are not equal, false otherwise
-
PNINEXUS_EXPORT bool operator<(const Version &lhs, const Version &rhs)¶
checks if the left version is strictly small than the right
- Parameters:
lhs – reference to the left hand side version
rhs – reference to the right hand side version
-
using NumberType = unsigned long¶
pni::nexus::DateTime
¶
-
class DateTime¶
date time factory
nxdate_time provides static methods to create date-time strings which are compliant to the Nexus standard. It is highly important for this class to work properly that the time zone setup is correct. Time-zone information can come either directly from the host machine the program is running on or can be configured manually if this setup is not correct.
Public Static Functions
-
static std::string get_date_time_str()¶
date-time now
Returns a string with a Nexus compliant date-time string for now.
- Returns:
Nexus date-time string
-
static std::string get_date_time_str(const time_t &t)¶
date-time at t
Converts a given time in time_t format to a Nexus date-time string.
- Parameters:
t – time as time_t
- Returns:
Nexus date-time string
-
static std::string get_date_time_str()¶