36 using ID = std::string;
48 throw std::runtime_error(
"Serialization not implemented for type " +
id);
55 throw std::runtime_error(
"Deserialization not implemented for type " +
id);
69 throw std::runtime_error(
"Validation not implemented for type " +
id);
74 std::optional<std::string>
isValid(
const std::any &obj)
const {
78 }
catch (
const std::runtime_error &e) {
96 std::vector<std::tuple<std::string, Direction, const Type *>>;
104 std::pair<const Type *, Direction>
findChannel(std::string name)
const;
119 void ensureValid(
const std::any &obj)
const override;
135 void ensureValid(
const std::any &obj)
const override;
169 void ensureValid(
const std::any &obj)
const override;
184 using IntegerType::IntegerType;
187 void ensureValid(
const std::any &obj)
const override;
195 using IntegerType::IntegerType;
198 void ensureValid(
const std::any &obj)
const override;
206 using FieldVector = std::vector<std::pair<std::string, const Type *>>;
214 std::ptrdiff_t size = 0;
216 std::ptrdiff_t fieldSize = ty->getBitWidth();
224 void ensureValid(
const std::any &obj)
const override;
255 return elementSize *
size;
258 void ensureValid(
const std::any &obj)
const override;
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.
MutableBitVector serialize(const std::any &obj) const override
Serialize an object to a MutableBitVector (LSB-first stream).
void ensureValid(const std::any &obj) const override
Ensure that a std::any object is valid for this type.
std::any deserialize(BitVector &data) const override
Deserialize from a BitVector stream (LSB-first).
const Type * getElementType() const
std::ptrdiff_t getBitWidth() const override
ArrayType(const ID &id, const Type *elementType, uint64_t size, bool reverse=true)
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
A lightweight, non-owning bit vector view backed by a byte array span.
Bits are just an array of bits.
void ensureValid(const std::any &obj) const override
Ensure that a std::any object is valid for this type.
std::any deserialize(BitVector &data) const override
Deserialize from a BitVector stream (LSB-first).
MutableBitVector serialize(const std::any &obj) const override
Serialize an object to a MutableBitVector (LSB-first stream).
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.
MutableBitVector serialize(const std::any &obj) const override
Serialize an object to a MutableBitVector (LSB-first stream).
ChannelType(const ID &id, const Type *inner)
const Type * getInner() const
std::any deserialize(BitVector &data) const override
Deserialize from a BitVector stream (LSB-first).
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.
A mutable bit vector that owns its underlying storage.
std::any deserialize(BitVector &data) const override
Deserialize from a BitVector stream (LSB-first).
MutableBitVector serialize(const std::any &obj) const override
Serialize an object to a MutableBitVector (LSB-first stream).
void ensureValid(const std::any &obj) const override
Ensure that a std::any object is valid for this type.
Structs are an ordered collection of fields, each with a name and a type.
std::ptrdiff_t getBitWidth() const override
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
MutableBitVector serialize(const std::any &obj) const override
Serialize an object to a MutableBitVector (LSB-first stream).
StructType(const ID &id, const FieldVector &fields, bool reverse=true)
const FieldVector & getFields() const
std::any deserialize(BitVector &data) const override
Deserialize from a BitVector stream (LSB-first).
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
std::any deserialize(const MessageData &data) const
virtual std::any deserialize(BitVector &data) const
Deserialize from a BitVector stream (LSB-first).
std::optional< std::string > isValid(const std::any &obj) const
virtual MutableBitVector serialize(const std::any &obj) const
Serialize an object to a MutableBitVector (LSB-first stream).
std::any deserialize(BitVector &data) const override
Deserialize from a BitVector stream (LSB-first).
MutableBitVector serialize(const std::any &obj) const override
Serialize an object to a MutableBitVector (LSB-first stream).
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.
std::any deserialize(BitVector &data) const override
Deserialize from a BitVector stream (LSB-first).
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
MutableBitVector serialize(const std::any &obj) const override
Serialize an object to a MutableBitVector (LSB-first stream).