ECSTASY
All in the name
Loading...
Searching...
No Matches
util::serialization::TomlConversion Class Reference

#include <TomlConversion.hpp>

Static Public Member Functions

static toml::date toToml (const INode::Date &date) noexcept
 Convert a INode::Date to a toml::date.
 
static toml::time toToml (const INode::Time &time) noexcept
 Convert a INode::Time to a toml::time.
 
static toml::date_time toToml (const INode::DateTime &dateTime) noexcept
 Convert a INode::DateTime to a toml::date_time.
 
static INode::Date fromToml (const toml::date &date) noexcept
 Convert a toml::date to a INode::Date.
 
static INode::Time fromToml (const toml::time &time) noexcept
 Convert a toml::time to a INode::Time.
 
static INode::DateTime fromToml (const toml::date_time &dateTime) noexcept
 Convert a toml::date_time to a INode::DateTime.
 

Private Member Functions

 TomlConversion ()=default
 

Detailed Description

Definition at line 20 of file TomlConversion.hpp.

Constructor & Destructor Documentation

◆ TomlConversion()

util::serialization::TomlConversion::TomlConversion ( )
privatedefault

Member Function Documentation

◆ fromToml() [1/3]

INode::Date util::serialization::TomlConversion::fromToml ( const toml::date date)
staticnoexcept

Convert a toml::date to a INode::Date.

Parameters
[in]datetoml date.
Returns
INode::Date Equivalent serialize date.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-09)

Definition at line 45 of file TomlConversion.cpp.

46 {
48 }
std::chrono::year_month_day Date
Type::Date underlying type.
Definition INode.hpp:58
uint8_t month
uint8_t day
uint16_t year

◆ fromToml() [2/3]

INode::DateTime util::serialization::TomlConversion::fromToml ( const toml::date_time dateTime)
staticnoexcept

Convert a toml::date_time to a INode::DateTime.

Parameters
[in]dateTimetoml date time.
Returns
INode::DateTime Equivalent serializer date time.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-09)

Definition at line 58 of file TomlConversion.cpp.

59 {
60 return INode::DateTime(
61 static_cast<std::chrono::sys_days>(fromToml(dateTime.date)).time_since_epoch() + fromToml(dateTime.time));
62 }
std::chrono::high_resolution_clock::time_point DateTime
Type::DateTime underlying type.
Definition INode.hpp:64
static INode::Date fromToml(const toml::date &date) noexcept
Convert a toml::date to a INode::Date.
toml::time time
toml::date date

◆ fromToml() [3/3]

INode::Time util::serialization::TomlConversion::fromToml ( const toml::time time)
staticnoexcept

Convert a toml::time to a INode::Time.

Parameters
[in]timetoml time.
Returns
INode::Time Equivalent serializer time.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-09)

Definition at line 50 of file TomlConversion.cpp.

51 {
52 return INode::Time(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::hours(time.hour))
53 + std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::minutes(time.minute))
54 + std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::seconds(time.second))
55 + std::chrono::nanoseconds(time.nanosecond));
56 }
std::chrono::nanoseconds Time
Type::Time underlying type.
Definition INode.hpp:61
T time(T... args)

◆ toToml() [1/3]

toml::date util::serialization::TomlConversion::toToml ( const INode::Date date)
staticnoexcept

Convert a INode::Date to a toml::date.

Parameters
[in]datecommon serializer date.
Returns
toml::date Equivalent toml date.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-09)

Definition at line 16 of file TomlConversion.cpp.

17 {
18 return toml::date(static_cast<int>(date.year()), static_cast<unsigned int>(date.month()),
19 static_cast<unsigned int>(date.day()));
20 }

◆ toToml() [2/3]

toml::date_time util::serialization::TomlConversion::toToml ( const INode::DateTime dateTime)
staticnoexcept

Convert a INode::DateTime to a toml::date_time.

Parameters
[in]dateTimecommon serializer date time.
Returns
toml::date_time Equivalent toml date time.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-09)

Definition at line 30 of file TomlConversion.cpp.

31 {
32#ifdef _MSC_VER
33 std::chrono::system_clock::time_point t2(
34 std::chrono::duration_cast<std::chrono::microseconds>(dateTime.time_since_epoch()));
35 auto dp = floor<std::chrono::days>(t2);
36
37 return toml::date_time(toToml(INode::Date(dp)), toToml(dateTime - floor<std::chrono::days>(dateTime)));
38
39#else
40 auto dp = floor<std::chrono::days>(dateTime);
41 return toml::date_time(toToml(INode::Date(dp)), toToml(dateTime - dp));
42#endif
43 }
static toml::date toToml(const INode::Date &date) noexcept
Convert a INode::Date to a toml::date.

◆ toToml() [3/3]

toml::time util::serialization::TomlConversion::toToml ( const INode::Time time)
staticnoexcept

Convert a INode::Time to a toml::time.

Parameters
[in]timecommon serializer time.
Returns
toml::time Equivalent toml time.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-09)

Definition at line 22 of file TomlConversion.cpp.

23 {
25
26 return toml::time(
27 time.hours().count(), time.minutes().count(), time.seconds().count(), time.subseconds().count());
28 }

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