Skip to content

Latest commit

 

History

History
90 lines (57 loc) · 2.01 KB

File metadata and controls

90 lines (57 loc) · 2.01 KB

DataItem structure

A wrapper for KwargsValue, similar to std::optional.

Syntax

struct DataItem;

Members

Constructors

Name Description
DataItem Constructor.

Functions

Name Description
valueOr Returns the stored value or a default.
hasValue Checks whether a value is present.

Operators

Name Description
operator-> Accesses the stored KwargsValue.

DataItem

Constructor.

constexpr DataItem(const KwargsValue* __that = nullptr) noexcept;

operator->

Returns a pointer to the stored data.

constexpr const KwargsValue* operator->() const noexcept;

hasValue

Checks if a value is present for the corresponding key. Returns true if there is a value; otherwise, returns false.

constexpr bool hasValue() const noexcept;

valueOr

Returns the stored value if available; otherwise, constructs and returns a default value.

template<typename _ValueType, typename... _Args>
constexpr _ValueType valueOr(_Args&&... __args) const noexcept;
  • _ValueType The desired return type. Must be specified explicitly. If the actual value type is different, the built-in type converter will attempt conversion.

  • _Args Types of the arguments to be forwarded.

  • __args Arguments forwarded to construct the default value if no stored value is present.

Example

dataItem.valueOr<std::string>(5, 'c');

If dataItem has no stored value, this will return std::string(5, 'c'), which is equivalent to "ccccc".