284 class Value :
public Variant<UInt64, Int64, float, double, bool, String, Binary, std::nullptr_t, Undefined, Array, Map, Tag, Break, Unknown> {
285 using super =
Variant<UInt64, Int64, float, double, bool, String, Binary, std::nullptr_t, Undefined, Array, Map, Tag, Break, Unknown>;
418 template<
typename T>
requires std::is_enum_v<T>
465 template<
typename Callback>
void map(
const Value& value, Callback&& callback) {
467 if(
map.isIndeterminate()) {
479 callback(*
this, value.as<
Map>(), index,
read(),
read());
497 template<
typename Callback>
void array(
const Value& value, Callback&& callback) {
499 if(
array.isIndeterminate()) {
500 for(
const UInt64 index :
range(std::numeric_limits<UInt64>::max())) {
506 callback(*
this,
array, index, std::move(element));
527 template<
typename Callback>
void tag(
const Value& value, Callback&& callback) {
529 callback(*
this, value.as<
Tag>(),
read());
666 template<
typename Func>
void map(
Func&& func) {
693 void binary(
const void* data,
size_t length);
736 template<
typename T>
requires std::is_enum_v<T>
738 using UnderlyingType = std::underlying_type_t<T>;
739 constexpr bool isSigned = std::is_signed_v<UnderlyingType>;
#define CE_ASSERT_UNDEFINED()
Definition Macros.hpp:326
#define CE_ASSERT(...)
Definition Macros.hpp:323
A filtered OutputStream that caches read and write operations to it's underlying OutputStream.
Definition Stream.Buffered.hpp:53
bool flush() final
In the stream is buffered, invalidates any buffered write data from to stream.
The Decoder class is a CBOR (Concise Binary Object Representation) decoder that provides an abstracti...
Definition CBOR.hpp:441
Generator< Pair< Value, Value > > map(const Map &value)
Decodes the contents of a map from the CBOR value stream.
void array(const Value &value, Callback &&callback)
Decodes the contents of an array from the CBOR value stream.
Definition CBOR.hpp:497
void map(const Value &value, Callback &&callback)
Decodes the contents of a map from the CBOR value stream.
Definition CBOR.hpp:465
Value read()
Decodes the next object from the CBOR stream.
void tag(const Value &value, Callback &&callback)
Decodes the contents of a tag from the CBOR value stream.
Definition CBOR.hpp:527
BufferedInputStream mStream
The stream to read from.
Definition CBOR.hpp:447
Decoder(IInputStream &inputStream)
Creates a new CBOR decoder from an IInputStream.
Definition CBOR.hpp:454
Decoder(InputStream inputStream)
Creates a new CBOR decoder from an InputStream.
Definition CBOR.hpp:451
Generator< Value > array(const Array &value)
Decodes the contents of an array from the CBOR value stream.
The Encoder class is a CBOR (Concise Binary Object Representation) encoder that provides an abstracti...
Definition CBOR.hpp:541
void write(Map value)
Encodes a map header into the CBOR stream.
void map(const UInt64 size, Func &&func)
Encodes a map header into the CBOR stream.
Definition CBOR.hpp:647
void write(std::nullptr_t value)
Encodes a nullptr into the CBOR stream.
Encoder(IOutputStream &outputStream)
Creates a new CBOR encoder from an IOutputStream.
Definition CBOR.hpp:554
void write(Value &&value)
Encodes a value into the CBOR stream.
void map()
Encodes an map header into the CBOR stream.
Definition CBOR.hpp:658
void write(Binary value)
Encodes a Binary into the CBOR stream.
void map(const UInt64 size)
Encodes an map header into the CBOR stream.
Definition CBOR.hpp:642
void binary(const FunctionView< void(OutputStream &) const > &func)
Encodes binary data into the CBOR stream.
void map(Func &&func)
Encodes a map header into the CBOR stream.
Definition CBOR.hpp:666
void write(Array value)
Encodes an array header into the CBOR stream.
void array(const UInt64 size)
Encodes an array header into the CBOR stream.
Definition CBOR.hpp:604
bool flush()
Definition CBOR.hpp:732
void tag(const UInt64 id)
Encodes an tag header into the CBOR stream.
Definition CBOR.hpp:679
void write(Undefined value)
Encodes an undefined into the CBOR stream.
void write(bool value)
Encodes a bool into the CBOR stream.
BufferedOutputStream mStream
The stream to write to.
Definition CBOR.hpp:547
void write(Int64 value)
Encodes a signed integer into the CBOR stream.
void write(StringView value)
Encodes a StringView into the CBOR stream.
void write(double value)
Encodes a double into the CBOR stream.
void array(Func &&func)
Encodes an array header into the CBOR stream.
Definition CBOR.hpp:628
void tag(const UInt64 id, Func &&func)
Encodes a tag header into the CBOR stream.
Definition CBOR.hpp:684
void binary(UInt64 length, const FunctionView< void(OutputStream &) const > &func)
Encodes binary data into the CBOR stream.
void write(UInt64 value)
Encodes an unsigned integer into the CBOR stream.
void write(const char *value)
Encodes a const char* into the CBOR stream.
Definition CBOR.hpp:579
Encoder(OutputStream outputStream)
Creates a new CBOR encoder from an OutputStream.
Definition CBOR.hpp:551
void write(Tag value)
Encodes a tag header into the CBOR stream.
void break_()
Encodes an Break into the CBOR stream.
Definition CBOR.hpp:594
void write(T value)
Encodes an enum value into the CBOR stream.
Definition CBOR.hpp:737
void write(float value)
Encodes a float into the CBOR stream.
void binary(const MemoryView< const Byte > &data)
Encodes binary data into the CBOR stream.
Definition CBOR.hpp:696
void binary(const void *data, size_t length)
Encodes binary data into the CBOR stream.
void write(Break value)
Encodes an Break into the CBOR stream.
void write(const String &value)
Encodes a String into the CBOR stream.
Definition CBOR.hpp:576
void array(const UInt64 size, Func &&func)
Encodes an array header into the CBOR stream.
Definition CBOR.hpp:609
void array()
Encodes an array header into the CBOR stream.
Definition CBOR.hpp:620
The Value class represents a data holder in the CBOR encoder or decoder.
Definition CBOR.hpp:284
bool isBoolean() const noexcept
Checks if the type is bool.
Definition CBOR.hpp:312
bool isBinary() const noexcept
Checks if the type is Binary.
Definition CBOR.hpp:318
bool isString() const noexcept
Checks if the type is String.
Definition CBOR.hpp:315
bool isMap() const noexcept
Checks if the type is Map.
Definition CBOR.hpp:330
const Unknown & asUnknown() const noexcept
Gets the value as type Unknown.
Definition CBOR.hpp:412
Binary && asBinary() &&noexcept
Gets the value as type Binary.
Definition CBOR.hpp:385
const String & asString() const noexcept
Gets the value as type String.
Definition CBOR.hpp:373
bool isTag() const noexcept
Checks if the type is Tag.
Definition CBOR.hpp:333
double asDouble() const noexcept
Gets the value as type double.
Definition CBOR.hpp:361
ValueType getType() const noexcept
Gets the type of the stored value.
Value()
Definition CBOR.hpp:289
const Tag & asTag() const noexcept
Gets the value as type Tag.
Definition CBOR.hpp:406
const Array & asArray() const noexcept
Gets the value as type Array.
Definition CBOR.hpp:394
bool isInt64() const noexcept
Checks if the type is Int64.
Definition CBOR.hpp:303
const Map & asMap() const noexcept
Gets the value as type Map.
Definition CBOR.hpp:400
bool isUInt64() const noexcept
Checks if the type is UInt64.
Definition CBOR.hpp:300
bool isBreak() const noexcept
Checks if the type is Break.
Definition CBOR.hpp:336
T asEnum() const
Gets the value as an enum type.
Definition CBOR.hpp:419
bool isDouble() const noexcept
Checks if the type is double.
Definition CBOR.hpp:309
String toString() const
Converts the type into a string format.
bool isUndefined() const noexcept
Checks if the type is undefined.
Definition CBOR.hpp:324
bool isUnknown() const noexcept
Checks if the type is Unknown.
Definition CBOR.hpp:339
const Binary & asBinary() const &noexcept
Gets the value as type Binary.
Definition CBOR.hpp:379
StringView asStringView() const noexcept
Gets the value as type asStringView.
Definition CBOR.hpp:391
UInt64 asUInt64() const noexcept
Gets the value as type UInt64.
Definition CBOR.hpp:343
bool isFloat() const noexcept
Checks if the type is float.
Definition CBOR.hpp:306
bool isArray() const noexcept
Checks if the type is Array.
Definition CBOR.hpp:327
bool isNull() const noexcept
Checks if the type is nullptr.
Definition CBOR.hpp:321
bool asBoolean() const noexcept
Gets the value as type bool.
Definition CBOR.hpp:367
Int64 asInt64() const noexcept
Gets the value as type Int64.
Definition CBOR.hpp:349
float asFloat() const noexcept
Gets the value as type float.
Definition CBOR.hpp:355
Concise Binary Object Representation (CBOR)
Definition CBOR.hpp:37
ValueType
An enumeration of all possible types.
Definition CBOR.hpp:199
@ Float
The value is of Float type.
@ String
The value is of String type.
@ Boolean
The value is of Boolean type.
@ UInt64
The value is of UInt64 type.
@ Null
The value is of Null type.
@ Double
The value is of Double type.
@ Int64
The value is of Int64 type.
A generator represents a coroutine type that produces a sequence of values of type T,...
Definition Generator.hpp:50
A stream that provides write-only stream functionality.
Definition Stream.hpp:233
A data stream that reads or writes data into a memory buffer.
Definition Stream.hpp:693
A memory view is a class which attaches to an chunk of memory and provides a view to it (optionally c...
Definition MemoryView.hpp:62
A stream that provides write-only stream functionality.
Definition Stream.hpp:307
Definition Variant.hpp:15
Definition Application.hpp:19
Byte
Definition DataTypes.hpp:40
std::uint64_t UInt64
Definition DataTypes.hpp:26
auto range()
Returns an iterator that increases it's value from 0 to end by 1 for each step.
Definition Iterator.hpp:350
BasicStringView< char > StringView
Narrow string view used for handling narrow encoded text in UTF-8.
Definition String.hpp:190
auto move(Vector3 position)
Moves a entity to the given position.
Definition Helpers.hpp:22
FunctionBase< false, true, fu2::capacity_default, true, false, Signatures... > FunctionView
A non owning copyable function wrapper for arbitrary callable types.
Definition Function.hpp:64
std::uint8_t UInt8
Definition DataTypes.hpp:17
std::int64_t Int64
Definition DataTypes.hpp:24
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Represents a CBOR array.
Definition CBOR.hpp:57
UInt64 size
The number of items in the array.
Definition CBOR.hpp:59
bool isIndeterminate() const noexcept
Determines if the array is indeterminate.
Definition CBOR.hpp:62
Represents a CBOR byte string (or binary).
Definition CBOR.hpp:146
InputStream stream
The stream that contains the binary data either being written or read.
Definition CBOR.hpp:149
Binary(InputStream stream)
Creates a new binary object from a input stream.
Definition CBOR.hpp:152
Binary(InputStream stream, const UInt64 limit)
Creates a new limited read stream.
Definition CBOR.hpp:158
Binary(const MemoryView< const Byte > &data)
Creates a new binary from a memory view.
Definition CBOR.hpp:155
Represents a CBOR break.
Definition CBOR.hpp:174
Represents a CBOR map.
Definition CBOR.hpp:81
bool isIndeterminate() const noexcept
Determines if the array is indeterminate.
Definition CBOR.hpp:86
UInt64 size
The number of key-pair items in the map.
Definition CBOR.hpp:83
Represents a CBOR tag.
Definition CBOR.hpp:114
UInt64 id
The tag unique identifier.
Definition CBOR.hpp:116
Represents a CBOR undefined type.
Definition CBOR.hpp:166
Represents an unknown CBOR opcode.
Definition CBOR.hpp:188
UInt64 minor
Represents the minor type of the unknown CBOR opcode.
Definition CBOR.hpp:195