|
xentara-workbench-plugin v1.0.1
The Xentara Workbench Plugin Framework
|
A time duration decomposed into value and units. More...
#include <xentara/workbench/chrono/Duration.hpp>
Classes | |
| struct | Zero |
| A special class that can be used to compare a duration with 0. More... | |
Public Types | |
| enum class | Units { Nanoseconds , Microseconds , Milliseconds , Seconds , Minutes , Hours } |
| Supported time units. More... | |
Public Member Functions | |
| constexpr | Duration () noexcept=default |
| Default constructor that creates a duration of 0s. | |
| constexpr | Duration (double value, Units units) noexcept |
| Constructor that sets the value. | |
| template<typename Repetitions , typename Period > | |
| constexpr | Duration (std::chrono::duration< Repetitions, Period > duration) noexcept |
| Conversion constructor from a chrono duration. | |
| template<typename Repetitions , typename Period > | |
| constexpr | operator std::chrono::duration< Repetitions, Period > () const noexcept |
| conversion to an std::chrono::duration | |
| auto | save (utils::json::encoder::Value &jsonValue) const -> void |
| Writes the time duration to a JSON value. | |
| auto | saveTo (utils::json::encoder::Object &jsonObject, std::string_view name) const -> void |
| Adds the time duration to a JSON object. | |
| auto | saveTo (utils::json::encoder::Array &jsonArray) const -> void |
| Writes the time duration to a JSON array. | |
| constexpr auto | units () const noexcept -> Units |
| Return the time unit component of the time value. | |
| constexpr auto | value () const noexcept -> double |
| Return the time value component of the time value. | |
Static Public Member Functions | |
| static consteval auto | zero () -> Zero |
| returns a value that can be used to compare a duration with 0 | |
| static auto | load (utils::json::decoder::Value &jsonValue) -> Duration |
| Loads the time duration from a JSON value. | |
| static auto | load (utils::json::decoder::Value &jsonValue, xentara::utils::json::decoder::AllowLegacyMicrosecondsTag) -> Duration |
| Loads the time duration from a JSON value, with support for legacy configurations that contain microseconds. | |
A time duration decomposed into value and units.
|
strong |
|
constexprdefaultnoexcept |
Default constructor that creates a duration of 0s.
|
constexprnoexcept |
Constructor that sets the value.
| value | The value |
| units | The units the value is in |
|
constexprnoexcept |
Conversion constructor from a chrono duration.
This constructor can be used to initialize a Duration object from a chrono literal.
Example:
|
static |
Loads the time duration from a JSON value.
| jsonValue | The value |
|
static |
Loads the time duration from a JSON value, with support for legacy configurations that contain microseconds.
| jsonValue | The value |
|
constexprnoexcept |
conversion to an std::chrono::duration
| auto xentara::workbench::chrono::Duration::save | ( | utils::json::encoder::Value & | jsonValue | ) | const -> void |
Writes the time duration to a JSON value.
| jsonValue | The value |
| auto xentara::workbench::chrono::Duration::saveTo | ( | utils::json::encoder::Array & | jsonArray | ) | const -> void |
Writes the time duration to a JSON array.
| jsonArray | The array |
| auto xentara::workbench::chrono::Duration::saveTo | ( | utils::json::encoder::Object & | jsonObject, |
| std::string_view | name | ||
| ) | const -> void |
Adds the time duration to a JSON object.
| jsonObject | The object |
| name | The member name |
|
constexprnoexcept |
Return the time unit component of the time value.
|
constexprnoexcept |
Return the time value component of the time value.
|
static |
returns a value that can be used to compare a duration with 0