CppCommon  1.0.4.1
C++ Common Library
Public Member Functions | List of all members
CppCommon::UtcTimestamp Class Reference

UTC timestamp. More...

#include <timestamp.h>

Inheritance diagram for CppCommon::UtcTimestamp:
CppCommon::Timestamp

Public Member Functions

 UtcTimestamp ()
 Initialize UTC timestamp with a current UTC time. More...
 
 UtcTimestamp (const Timestamp &timestamp)
 Initialize UTC timestamp with another timestamp value. More...
 
 Timestamp () noexcept
 Initialize timestamp with an epoch time. More...
 
 Timestamp (uint64_t timestamp) noexcept
 Initialize timestamp with a given time moment in nanoseconds. More...
 
template<class Clock , class Duration >
 Timestamp (const std::chrono::time_point< Clock, Duration > &time_point) noexcept
 Initialize timestamp with a given std::chrono time point. More...
 
 Timestamp (const Timestamp &) noexcept=default
 
 Timestamp (Timestamp &&) noexcept=default
 
- Public Member Functions inherited from CppCommon::Timestamp
 Timestamp () noexcept
 Initialize timestamp with an epoch time. More...
 
 Timestamp (uint64_t timestamp) noexcept
 Initialize timestamp with a given time moment in nanoseconds. More...
 
template<class Clock , class Duration >
 Timestamp (const std::chrono::time_point< Clock, Duration > &time_point) noexcept
 Initialize timestamp with a given std::chrono time point. More...
 
 Timestamp (const Timestamp &) noexcept=default
 
 Timestamp (Timestamp &&) noexcept=default
 
 ~Timestamp () noexcept=default
 
Timestampoperator= (uint64_t timestamp) noexcept
 
Timestampoperator= (const Timestamp &) noexcept=default
 
Timestampoperator= (Timestamp &&) noexcept=default
 
Timestampoperator+= (int64_t offset) noexcept
 
Timestampoperator+= (const Timespan &offset) noexcept
 
Timestampoperator-= (int64_t offset) noexcept
 
Timestampoperator-= (const Timespan &offset) noexcept
 
std::chrono::system_clock::time_point chrono () const noexcept
 Convert timestamp to the std::chrono time point. More...
 
uint64_t days () const noexcept
 Get total days of the current timestamp. More...
 
uint64_t hours () const noexcept
 Get total hours of the current timestamp. More...
 
uint64_t minutes () const noexcept
 Get total minutes of the current timestamp. More...
 
uint64_t seconds () const noexcept
 Get total seconds of the current timestamp. More...
 
uint64_t milliseconds () const noexcept
 Get total milliseconds of the current timestamp. More...
 
uint64_t microseconds () const noexcept
 Get total microseconds of the current timestamp. More...
 
uint64_t nanoseconds () const noexcept
 Get total nanoseconds of the current timestamp. More...
 
uint64_t total () const noexcept
 Get total value of the current timestamp (total nanoseconds) More...
 
void swap (Timestamp &timestamp) noexcept
 Swap two instances. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from CppCommon::Timestamp
static Timestamp days (int64_t days) noexcept
 Create the timestamp based on the given days value. More...
 
static Timestamp hours (int64_t hours) noexcept
 Create the timestamp based on the given hours value. More...
 
static Timestamp minutes (int64_t minutes) noexcept
 Create the timestamp based on the given minutes value. More...
 
static Timestamp seconds (int64_t seconds) noexcept
 Create the timestamp based on the given seconds value. More...
 
static Timestamp milliseconds (int64_t milliseconds) noexcept
 Create the timestamp based on the given milliseconds value. More...
 
static Timestamp microseconds (int64_t microseconds) noexcept
 Create the timestamp based on the given microseconds value. More...
 
static Timestamp nanoseconds (int64_t nanoseconds) noexcept
 Create the timestamp based on the given nanoseconds value. More...
 
static uint64_t epoch () noexcept
 Get the epoch timestamp. More...
 
static uint64_t utc ()
 Get the UTC timestamp. More...
 
static uint64_t local ()
 Get the local timestamp. More...
 
static uint64_t nano ()
 Get the high resolution timestamp. More...
 
static uint64_t rdts ()
 Get the current value of RDTS (Read Time Stamp Counter) More...
 
- Protected Attributes inherited from CppCommon::Timestamp
uint64_t _timestamp
 Timestamp value. More...
 

Detailed Description

UTC timestamp.

Examples
algorithms_token_bucket.cpp, and time_timestamp.cpp.

Definition at line 247 of file timestamp.h.

Constructor & Destructor Documentation

◆ UtcTimestamp() [1/2]

CppCommon::UtcTimestamp::UtcTimestamp ( )
inline

Initialize UTC timestamp with a current UTC time.

Definition at line 253 of file timestamp.h.

◆ UtcTimestamp() [2/2]

CppCommon::UtcTimestamp::UtcTimestamp ( const Timestamp timestamp)
inline

Initialize UTC timestamp with another timestamp value.

Definition at line 255 of file timestamp.h.

Member Function Documentation

◆ Timestamp() [1/5]

CppCommon::Timestamp::Timestamp
inlinenoexcept

Initialize timestamp with an epoch time.

Definition at line 33 of file timestamp.h.

◆ Timestamp() [2/5]

template<class Clock , class Duration >
CppCommon::Timestamp::Timestamp ( class Clock  ,
class Duration   
)
inlineexplicitnoexcept

Initialize timestamp with a given std::chrono time point.

Parameters
time_point- std::chrono time point

Definition at line 44 of file timestamp.h.

◆ Timestamp() [3/5]

CppCommon::Timestamp::Timestamp
defaultnoexcept

◆ Timestamp() [4/5]

CppCommon::Timestamp::Timestamp
defaultnoexcept

◆ Timestamp() [5/5]

CppCommon::Timestamp::Timestamp
inlineexplicitnoexcept

Initialize timestamp with a given time moment in nanoseconds.

Parameters
timestamp- Time moment in nanoseconds

Definition at line 38 of file timestamp.h.


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