Utility functions and classes¶
pni::io::nexus::Version
¶
-
class
pni::io::nexus
::
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 numberminor
: the minor version numberpatch
: 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
-
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.
- Return
a new instance of Version
- Exceptions
std::runtime_error
: in the case of a malformed input string
- Parameters
str
: the string with the version number
Related
-
PNIIO_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.
- Return
modified version of std::ostream
- See
- Parameters
stream
: the stream where to write the versionversion
: reference to the Version to write
-
PNIIO_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.
- Return
modified input stream
- See
- Parameters
stream
: reference to the stream from which to read the Versionversion
: reference to the version to which to read
-
PNIIO_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.
- Return
true if versions are equal, false otherwise
- Parameters
lhs
: reference to the left hand side versionrhs
: reference to the right hand side version
-
PNIIO_EXPORT bool
operator!=
(const Version &lhs, const Version &rhs)¶ checks if two versions are not equal
- Return
true if versions are not equal, false otherwise
- Parameters
lhs
: reference to the left hand side versionrhs
: reference to the right hand side version
-
PNIIO_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 versionrhs
: reference to the right hand side version
-
using
pni::io::nexus::DateTime
¶
-
class
pni::io::nexus
::
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
-
std::string
get_date_time_str
()¶ date-time now
Returns a string with a Nexus compliant date-time string for now.
- Return
Nexus date-time string
-
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.
- Return
Nexus date-time string
- Parameters
t
: time as time_t
-
std::string