Update SerializeAdapter #122

Merged
mohr merged 8 commits from mohr_serialize into master 2020-07-10 12:21:15 +02:00
Owner

fixes #38

SerializeIF

The bool bigEndian parameter was changed to enum Endianness streamEndianness to be more clear about the intentian of the parameter. It is now also possible to write to or read from a little endian or machine endian stream. Machine endian means no endian conversion is performed (which is only useful if the serialized data is to be interpreted on the same machine).
Lengths are now expressed as size_t, advancing #12.

EndianSwapper/EndianConverter

EndianSwapper was renamed to EndianConverter. It supports big and little endian now, following the change in SerializeIF. Names and documentation was updated to make its use more clear.

SerializeAdapter

The class is no longer a template, the individual functions are. This allows automatic deduction of template arguments, uint32_t var; SerializeAdapter<uint32_t>::deSerialize(var, ...) can now be written as uint32_t var; ::deSerialize(var, ...).

The Endianness parameter was changed following the update of SerializeIF.

SerializeAdapter_

This class is where the magic of compile time specialization of the serialization happens. It was moved into a private child class of SerializeAdapter to make more clear that it is not to be used on its own.

PoolRawAccess

PoolRawAccess was updated to use the EndianConverter.

Other

During the implementation of the above changes in the framework, a lot of variables were changed to size_t, your friendly compiler will probably remind you of most of them.

Tried using override keyword where applicable.

Helping hands

API Changes can mostly be applied via the following sed rules:

find .  \( -name "*.cpp" -o -name "*.h" \) -not -name "SerializeAdapter.h" -exec sed -i -e "s/SerializeAdapter<.*>::/SerializeAdapter::/g" {} +
find .  \( -name "*.cpp" -o -name "*.h" \) -not -name "SerializeAdapter.h" -exec sed -i -e "s/AutoSerializeAdapter::/SerializeAdapter::/g" {} +

and a script to adapt more changes, to be run via find as well:

echo $1
sed -i "s/const uint32_t max_size/size_t maxSize/g" $1
sed -i "s/buffer, uint32_t\* size/buffer, size_t* size/g" $1
sed -i "s/bool bigEndian/Endianness streamEndianness/g" $1
sed -i "s/max_size/maxSize/g" $1
sed -i "s/bigEndian/streamEndianness/g" $1
sed -i "s/buffer, int32_t\* size/buffer, size_t* size/g" $1
#Replaces implementations
sed -i "s/uint32_t getSerializedSize() const {/size_t getSerializedSize() const {/g" $1
#Replaces declarations
#wont find header only implementations where there is no declaration but better than nothing...
sed -i "s/uint32_t getSerializedSize() const;/size_t getSerializedSize() const override;/g" $1
#Replaces declarations
#wont find header only implementations where there is no declaration but better than nothing...
sed -i "s/Endianness streamEndianness);/Endianness streamEndianness) override;/g" $1
#Replaces declarations
#wont find header only implementations where there is no declaration but better than nothing...
sed -i "s/streamEndianness) const;/streamEndianness) const override;/g" $1

Probably the above sed rules can be included in the script, I did not test this however.

fixes #38 ## `SerializeIF` The `bool bigEndian` parameter was changed to `enum Endianness streamEndianness` to be more clear about the intentian of the parameter. It is now also possible to write to or read from a little endian or machine endian stream. Machine endian means no endian conversion is performed (which is only useful if the serialized data is to be interpreted on the same machine). Lengths are now expressed as `size_t`, advancing #12. ## `EndianSwapper`/`EndianConverter` `EndianSwapper` was renamed to `EndianConverter`. It supports big and little endian now, following the change in `SerializeIF`. Names and documentation was updated to make its use more clear. ## `SerializeAdapter` The class is no longer a template, the individual functions are. This allows automatic deduction of template arguments, `uint32_t var; SerializeAdapter<uint32_t>::deSerialize(var, ...)` can now be written as `uint32_t var; ::deSerialize(var, ...)`. The Endianness parameter was changed following the update of `SerializeIF`. ## `SerializeAdapter_` This class is where the magic of compile time specialization of the serialization happens. It was moved into a private child class of `SerializeAdapter` to make more clear that it is not to be used on its own. ## `PoolRawAccess` `PoolRawAccess` was updated to use the `EndianConverter`. ## Other During the implementation of the above changes in the framework, a lot of variables were changed to `size_t`, your friendly compiler will probably remind you of most of them. Tried using `override` keyword where applicable. ## Helping hands API Changes can mostly be applied via the following sed rules: ```bash find . \( -name "*.cpp" -o -name "*.h" \) -not -name "SerializeAdapter.h" -exec sed -i -e "s/SerializeAdapter<.*>::/SerializeAdapter::/g" {} + find . \( -name "*.cpp" -o -name "*.h" \) -not -name "SerializeAdapter.h" -exec sed -i -e "s/AutoSerializeAdapter::/SerializeAdapter::/g" {} + ``` and a script to adapt more changes, to be run via find as well: ```bash echo $1 sed -i "s/const uint32_t max_size/size_t maxSize/g" $1 sed -i "s/buffer, uint32_t\* size/buffer, size_t* size/g" $1 sed -i "s/bool bigEndian/Endianness streamEndianness/g" $1 sed -i "s/max_size/maxSize/g" $1 sed -i "s/bigEndian/streamEndianness/g" $1 sed -i "s/buffer, int32_t\* size/buffer, size_t* size/g" $1 #Replaces implementations sed -i "s/uint32_t getSerializedSize() const {/size_t getSerializedSize() const {/g" $1 #Replaces declarations #wont find header only implementations where there is no declaration but better than nothing... sed -i "s/uint32_t getSerializedSize() const;/size_t getSerializedSize() const override;/g" $1 #Replaces declarations #wont find header only implementations where there is no declaration but better than nothing... sed -i "s/Endianness streamEndianness);/Endianness streamEndianness) override;/g" $1 #Replaces declarations #wont find header only implementations where there is no declaration but better than nothing... sed -i "s/streamEndianness) const;/streamEndianness) const override;/g" $1 ``` Probably the above sed rules can be included in the script, I did not test this however.
mohr added the
feature
API Change
labels 2020-06-30 14:44:32 +02:00
Owner

I integrated the changes into our branch and fork and it appears to work without issues.

It propably would be a good idea to merge the master branch again.
storagemanager components use size_t now so there was a little merge conflict.

I integrated the changes into our branch and fork and it appears to work without issues. It propably would be a good idea to merge the master branch again. storagemanager components use size_t now so there was a little merge conflict.
Author
Owner

Good to know that it works in your fork.
Will merge master and extend documentation as soon as I get to it.

Good to know that it works in your fork. Will merge master and extend documentation as soon as I get to it.
Owner

Okay, I also think there is still a compiler warning in PoolRawAccess (#warning use serialize...). Is this intended? (its still WIP after all).

And another small thing: Maybe the file for EndianConverter should be renamed to EndianConverter as well.

Okay, I also think there is still a compiler warning in PoolRawAccess (#warning use serialize...). Is this intended? (its still WIP after all). And another small thing: Maybe the file for EndianConverter should be renamed to EndianConverter as well.
mohr self-assigned this 2020-07-03 12:27:47 +02:00
mohr changed title from WIP: Update SerializeAdapter to Update SerializeAdapter 2020-07-07 12:28:16 +02:00
mohr closed this pull request 2020-07-10 12:21:15 +02:00
Owner

Also fixes #21

Also fixes #21
Sign in to join this conversation.
No description provided.