|
CeresEngine 0.2.0
A game development framework
|
The Value class represents a data holder in the CBOR encoder or decoder.
More...
#include <CeresEngine/Foundation/CBOR.hpp>
Public Member Functions | |
| Value () | |
| ValueType | getType () const noexcept |
| Gets the type of the stored value. | |
| String | toString () const |
| Converts the type into a string format. | |
| bool | isUInt64 () const noexcept |
Checks if the type is UInt64. | |
| bool | isInt64 () const noexcept |
Checks if the type is Int64. | |
| bool | isFloat () const noexcept |
Checks if the type is float. | |
| bool | isDouble () const noexcept |
Checks if the type is double. | |
| bool | isBoolean () const noexcept |
Checks if the type is bool. | |
| bool | isString () const noexcept |
Checks if the type is String. | |
| bool | isBinary () const noexcept |
Checks if the type is Binary. | |
| bool | isNull () const noexcept |
Checks if the type is nullptr. | |
| bool | isUndefined () const noexcept |
Checks if the type is undefined. | |
| bool | isArray () const noexcept |
Checks if the type is Array. | |
| bool | isMap () const noexcept |
Checks if the type is Map. | |
| bool | isTag () const noexcept |
Checks if the type is Tag. | |
| bool | isBreak () const noexcept |
Checks if the type is Break. | |
| bool | isUnknown () const noexcept |
Checks if the type is Unknown. | |
| UInt64 | asUInt64 () const noexcept |
Gets the value as type UInt64. | |
| Int64 | asInt64 () const noexcept |
Gets the value as type Int64. | |
| float | asFloat () const noexcept |
Gets the value as type float. | |
| double | asDouble () const noexcept |
Gets the value as type double. | |
| bool | asBoolean () const noexcept |
Gets the value as type bool. | |
| const String & | asString () const noexcept |
Gets the value as type String. | |
| const Binary & | asBinary () const &noexcept |
Gets the value as type Binary. | |
| Binary && | asBinary () &&noexcept |
Gets the value as type Binary. | |
| StringView | asStringView () const noexcept |
Gets the value as type asStringView. | |
| const Array & | asArray () const noexcept |
Gets the value as type Array. | |
| const Map & | asMap () const noexcept |
Gets the value as type Map. | |
| const Tag & | asTag () const noexcept |
Gets the value as type Tag. | |
| const Unknown & | asUnknown () const noexcept |
Gets the value as type Unknown. | |
| template<typename T > requires std::is_enum_v<T> | |
| T | asEnum () const |
| Gets the value as an enum type. | |
Private Types | |
| using | super = Variant< UInt64, Int64, float, double, bool, String, Binary, std::nullptr_t, Undefined, Array, Map, Tag, Break, Unknown > |
The Value class represents a data holder in the CBOR encoder or decoder.
It can encapsulate data of various types and provides a convenient way to represent values parsed from, or to be encoded into, CBOR data.
UInt64 and Int64), floating point values (float and double), boolean, String, Binary, nullptr_t, Undefined, Array, Map, Tag, Break and Unknown.asEnum() template function is provided.A Value instance can be created with a value of any supported type from it's constructor.
A value can be retrieved using the type-specific as<T>() function calls. These functions will retrieve the value only if it is of a corresponding type.
The type of a value currently held by an instance can be checked using the type-specific is<T>() function calls.
The getType() function provides the specific ValueType enumeration representative of the type of value currently held by the Value instance. This is useful to use in a switch context.
The toString() function converts the value to a string representation, regardless of its actual type.
Overall, the Value class acts as a user-friendly interface for handling diverse data types in the CBOR handling process. It provides convenient type checking and safe type-specific access to values, ensuring the robustness of the CBOR encoding and decoding operations.
|
private |
|
inline |
Gets the value as type Array.
Gets the value as type Binary.
|
inlinenoexcept |
Gets the value as type bool.
|
inlinenoexcept |
Gets the value as type double.
|
inline |
Gets the value as an enum type.
|
inlinenoexcept |
Gets the value as type float.
|
inlinenoexcept |
Gets the value as type Int64.
Gets the value as type String.
|
inlinenoexcept |
Gets the value as type asStringView.
|
inlinenoexcept |
Gets the value as type UInt64.
Gets the value as type Unknown.
|
noexcept |
Gets the type of the stored value.
|
inlinenoexcept |
Checks if the type is bool.
|
inlinenoexcept |
Checks if the type is double.
|
inlinenoexcept |
Checks if the type is float.
|
inlinenoexcept |
Checks if the type is Int64.
|
inlinenoexcept |
Checks if the type is nullptr.
|
inlinenoexcept |
Checks if the type is String.
|
inlinenoexcept |
Checks if the type is UInt64.
|
inlinenoexcept |
Checks if the type is undefined.
| String CeresEngine::CBOR::Value::toString | ( | ) | const |
Converts the type into a string format.