This PR refactors the DataHelpers. The main goal was to be able to extract and append arrays without needing to provide a lambda to do the (de-)serialization.
The general syntax will change from
DataHelpers::AppendDouble(OutMessage, "x", X);
to
DataHelpers::Append<double>(OutMessage, "x", X);
The template parameter should be always deductable from the parameter type and, thus, is completely optional. It can be used to explicitely force a specific version of the function as this was a requirement based on previous discussions.
Usage with an undefined type leads to the following error (MSVC):
1>...\Plugins\Rosbridge2Unreal\Source\Rosbridge2Unreal\Public\DataHelpers.h(208): error C2027: use of undefined type 'DataHelpers::Internal::DataConverter<T,void>'
1> with
1> [
1> T=SomeCustomType
1> ]
Discussion points
Should we do such a change? The data helpers now contain a little bit of template magic in the DataConverter struct to make it work. This, however, is also only necessary to be able to explicitely state the data type via a template parameter. We could get rid of the DataConverter completely by just using function overloading.
Should we leave in all old functions to ensure backwards compatibility?
If not: Should we leave functions in to explicitely Append/Extract array elements? First, I thought this would be a nice feature, but I failed to come up with a valid use case.
ToDo
[x] Fix formatting. Accidently ran clang-format which messed up the formatting in DataHelpers.h and makes the git diff unreadable.
This PR refactors the DataHelpers. The main goal was to be able to extract and append arrays without needing to provide a lambda to do the (de-)serialization.
The general syntax will change from
to
The template parameter should be always deductable from the parameter type and, thus, is completely optional. It can be used to explicitely force a specific version of the function as this was a requirement based on previous discussions.
Extracting arrays is now simplified as:
instead of
Again, template parameters are optional.
Usage with an undefined type leads to the following error (MSVC):
Discussion points
DataConverter
struct to make it work. This, however, is also only necessary to be able to explicitely state the data type via a template parameter. We could get rid of theDataConverter
completely by just using function overloading.ToDo