35 using ID = std::string;
46 throw std::runtime_error(
"Serialization not implemented for type " +
id);
51 virtual std::pair<std::any, std::span<const uint8_t>>
53 throw std::runtime_error(
"Deserialization not implemented for type " +
id);
59 throw std::runtime_error(
"Validation not implemented for type " +
id);
64 std::optional<std::string>
isValid(
const std::any &obj)
const {
68 }
catch (
const std::runtime_error &e) {
86 std::vector<std::tuple<std::string, Direction, const Type *>>;
94 std::pair<const Type *, Direction>
findChannel(std::string name)
const;
108 void ensureValid(
const std::any &obj)
const override;
110 std::pair<std::any, std::span<const uint8_t>>
111 deserialize(std::span<const uint8_t> data)
const override;
124 void ensureValid(
const std::any &obj)
const override;
126 std::pair<std::any, std::span<const uint8_t>>
127 deserialize(std::span<const uint8_t> data)
const override;
158 void ensureValid(
const std::any &obj)
const override;
160 std::pair<std::any, std::span<const uint8_t>>
174 using IntegerType::IntegerType;
176 void ensureValid(
const std::any &obj)
const override;
178 std::pair<std::any, std::span<const uint8_t>>
185 using IntegerType::IntegerType;
187 void ensureValid(
const std::any &obj)
const override;
189 std::pair<std::any, std::span<const uint8_t>>
196 using FieldVector = std::vector<std::pair<std::string, const Type *>>;
203 std::ptrdiff_t size = 0;
205 std::ptrdiff_t fieldSize = ty->getBitWidth();
213 void ensureValid(
const std::any &obj)
const override;
215 std::pair<std::any, std::span<const uint8_t>>
242 return elementSize *
size;
245 void ensureValid(
const std::any &obj)
const override;
247 std::pair<std::any, std::span<const uint8_t>>
The "any" type is a special type which can be used to represent any type, as identified by the type i...
std::ptrdiff_t getBitWidth() const override
Arrays have a compile time specified (static) size and an element type.
MessageData serialize(const std::any &obj) const override
Serialize an object to MessageData.
void ensureValid(const std::any &obj) const override
Ensure that a std::any object is valid for this type.
ArrayType(const ID &id, const Type *elementType, uint64_t size)
const Type * getElementType() const
std::pair< std::any, std::span< const uint8_t > > deserialize(std::span< const uint8_t > data) const override
Deserialize from a span of bytes to an object.
std::ptrdiff_t getBitWidth() const override
Bit vectors include signed, unsigned, and signless integers.
BitVectorType(const ID &id, uint64_t width)
std::ptrdiff_t getBitWidth() const override
uint64_t getWidth() const
Bits are just an array of bits.
std::pair< std::any, std::span< const uint8_t > > deserialize(std::span< const uint8_t > data) const override
Deserialize from a span of bytes to an object.
void ensureValid(const std::any &obj) const override
Ensure that a std::any object is valid for this type.
MessageData serialize(const std::any &obj) const override
Serialize an object to MessageData.
Bundles represent a collection of channels.
BundleType(const ID &id, const ChannelVector &channels)
std::ptrdiff_t getBitWidth() const override
const ChannelVector & getChannels() const
std::vector< std::tuple< std::string, Direction, const Type * > > ChannelVector
std::pair< const Type *, Direction > findChannel(std::string name) const
Channels are the basic communication primitives.
void ensureValid(const std::any &obj) const override
Ensure that a std::any object is valid for this type.
MessageData serialize(const std::any &obj) const override
Serialize an object to MessageData.
ChannelType(const ID &id, const Type *inner)
const Type * getInner() const
std::pair< std::any, std::span< const uint8_t > > deserialize(std::span< const uint8_t > data) const override
Deserialize from a span of bytes to an object.
std::ptrdiff_t getBitWidth() const override
Integers are bit vectors which may be signed or unsigned and are interpreted as numbers.
A logical chunk of data representing serialized data.
std::pair< std::any, std::span< const uint8_t > > deserialize(std::span< const uint8_t > data) const override
Deserialize from a span of bytes to an object.
void ensureValid(const std::any &obj) const override
Ensure that a std::any object is valid for this type.
MessageData serialize(const std::any &obj) const override
Serialize an object to MessageData.
Structs are an ordered collection of fields, each with a name and a type.
std::ptrdiff_t getBitWidth() const override
MessageData serialize(const std::any &obj) const override
Serialize an object to MessageData.
void ensureValid(const std::any &obj) const override
Ensure that a std::any object is valid for this type.
std::vector< std::pair< std::string, const Type * > > FieldVector
std::pair< std::any, std::span< const uint8_t > > deserialize(std::span< const uint8_t > data) const override
Deserialize from a span of bytes to an object.
StructType(const ID &id, const FieldVector &fields, bool reverse=true)
const FieldVector & getFields() const
Root class of the ESI type system.
virtual void ensureValid(const std::any &obj) const
Ensure that a std::any object is valid for this type.
virtual std::ptrdiff_t getBitWidth() const
virtual MessageData serialize(const std::any &obj) const
Serialize an object to MessageData.
virtual std::pair< std::any, std::span< const uint8_t > > deserialize(std::span< const uint8_t > data) const
Deserialize from a span of bytes to an object.
std::optional< std::string > isValid(const std::any &obj) const
std::pair< std::any, std::span< const uint8_t > > deserialize(std::span< const uint8_t > data) const override
Deserialize from a span of bytes to an object.
MessageData serialize(const std::any &obj) const override
Serialize an object to MessageData.
void ensureValid(const std::any &obj) const override
Ensure that a std::any object is valid for this type.
The "void" type is a special type which can be used to represent no type.
void ensureValid(const std::any &obj) const override
Ensure that a std::any object is valid for this type.
std::ptrdiff_t getBitWidth() const override
std::pair< std::any, std::span< const uint8_t > > deserialize(std::span< const uint8_t > data) const override
Deserialize from a span of bytes to an object.
MessageData serialize(const std::any &obj) const override
Serialize an object to MessageData.