[ESI] Add bitvector and arbitrary-width integer classes #9129
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To not constrain ESI C++ serialization to integer types that fit in
cstdinttypes (<64 bits) as well as to allow non-byte aligned fields (e.g. structs with boolean values), this PR introduces the ESIBitVectortype. It is a view on top of astd::span<const uint8_t>which tracks a byte- and bit index, and providing a bitvector view onto that bytearray.Deserialization has then been refactored to use such a
BitVectorview to pop values off of an incomingMessageData.For serialization, we introduce
MutableBitVector, which inherits fromBitVector, but also owns the underlying byte array. This then allows for mutation operators to be implemented, facilitating serialization (e.g. shift-and-or style).Finally, to support arbitrary-width integers,
IntandUIntclasses have been introduces. These contain constructors for their respectivecstdintvalue, as well as conversion operators tocstdintclasses. They do not contain arithmetic operators. Partly motivated by keeping this PR small, partly motivated by not being needed in the immediate usecase that this PR is motivated by.