SOIL C++
C++ Unified Device Interface
SOIL::Time Class Reference

SOIL Time. More...

#include <Time.h>

Public Member Functions

DLL std::string rfc3339 (void) const
 RFC3339 representation. More...
 
DLL Time ()
 Uninitialized Constructor. More...
 
DLL Time (std::string value)
 String Constructor. More...
 
DLL Time (boost::posix_time::ptime value)
 Posix Time Construtor. More...
 
DLL ~Time ()
 Destructor. More...
 
bool is_null (void) const
 Is Null? More...
 
void set_null (bool _null=true)
 Set null. More...
 
DLL std::vector< unsigned char > serialize (void) const
 Bytewise serialization. More...
 

Static Public Member Functions

static DLL boost::posix_time::ptime utc_now (void)
 Current Time. More...
 

Friends

DLL bool operator>= (const Time &t1, const Time &t2)
 Friend Operator >=. More...
 
DLL bool operator<= (const Time &t1, const Time &t2)
 Friend Operator <=. More...
 

Detailed Description

Speial Time class for SOIL to implement the necessary functionality.

Definition at line 12 of file Time.h.

Constructor & Destructor Documentation

◆ Time() [1/3]

SOIL::Time::Time ( )

Construct an uninitialized Time instance, where the _null flag is set to true.

Definition at line 27 of file Time.cpp.

◆ Time() [2/3]

SOIL::Time::Time ( std::string  value)

Constructs a Time object from an RFC3339 string. If an empty string is passed, the _null flag is set to true.

The exceptions from the underlying boost implementation are passed through.

Parameters
[in]valueRFC3339 string of the time to set.

Definition at line 31 of file Time.cpp.

◆ Time() [3/3]

SOIL::Time::Time ( boost::posix_time::ptime  value)

Constructs a Time object from a boost::posix_time::ptime. This is useful in conjuction with now().

Parameters
[in]valueTime to set.

Definition at line 46 of file Time.cpp.

◆ ~Time()

SOIL::Time::~Time ( )

Default Destructor, there is no unexpected behaviour.

Definition at line 53 of file Time.cpp.

Member Function Documentation

◆ is_null()

bool SOIL::Time::is_null ( void  ) const
inline

Returns whether the time is set to null.

Returns

Is Null?

Function that returns true if the current data is set to null and false else.

Returns
Null flag

Definition at line 92 of file Time.h.

◆ rfc3339()

std::string SOIL::Time::rfc3339 ( void  ) const

Return a RFC3339 conformant representation of the time, e.g. 2021-06-07T22:01:23.078162Z as string. This is the main time representation used in SOIL.

Returns
RFC3339 string

Definition at line 6 of file Time.cpp.

◆ serialize()

std::vector< unsigned char > SOIL::Time::serialize ( void  ) const

Bytewise serialization of the time for hashing purpose. The components are serialized in the following order:

  • uint16_t of the year
  • uint8_t of the month
  • uint8_t of the day
  • uint8_t of the hour
  • uint8_t of the minute
  • unit8_t of the seconds
  • uint32_t of the nanoseconds
Returns
Serialized Bytestring

Definition at line 62 of file Time.cpp.

◆ set_null()

void SOIL::Time::set_null ( bool  _null = true)
inline

Function to set the null status of the data container

Parameters
[in]_nullBoolean state flag

Definition at line 100 of file Time.h.

◆ utc_now()

boost::posix_time::ptime SOIL::Time::utc_now ( void  )
static

Returns the current UTC time as boost::posix_time::ptime to allow for quick access in implementations using this library. Thanks to the corresponding constructor, this function can also be used in assignments.

Returns
Current UTC time

Definition at line 57 of file Time.cpp.

Friends And Related Function Documentation

◆ operator<=

DLL bool operator<= ( const Time t1,
const Time t2 
)
friend

Friend declaration of the <= operator, needed for correcet implementation.

Lower or equal operation for two Time objects, which is needed for the correct implementation of the Range class.

Returns true if t1 <= t2, otherwise false. If one of the Time objects is set to null, the operation returns false.

Parameters
t1Left hand side time
t2Right hand side time
Returns
Comparison result as boolean

◆ operator>=

DLL bool operator>= ( const Time t1,
const Time t2 
)
friend

Friend declaration of the >= operator, needed for correcet implementation.

Greater or equal operation for two Time objects, which is needed for the correct implementation of the Range class.

Returns true if t1 >= t2, otherwise false. If one of the Time objects is set to null, the operation returns false.

Parameters
t1Left hand side time
t2Right hand side time
Returns
Comparison result as boolean

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