Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use SBE generated message types as plain C/C++ structure #553

Open
ayubsayyad opened this issue Mar 30, 2018 · 1 comment
Open

use SBE generated message types as plain C/C++ structure #553

ayubsayyad opened this issue Mar 30, 2018 · 1 comment

Comments

@ayubsayyad
Copy link

[C++]
I understood that SBE is for sending messages on wire, but often we use same types in our program to pass to functions and get values populated before doing so. Here we always need to provide buffer externally and maintain its lifetime

e.g.
Car carObj;
carObj.serialNumber(1234); //segmentation fault, as expected

can we generate something as below, this will enable developers not to maintain buffer explicitly. This will be backward compatible as we will not touch auto generated Car object.

struct CarWrapper{
CarWrapper(){
obj.wrap(buffer, 0, ..., ...)
}
Car obj;
char buffer[];
};

@tmontgomery
Copy link
Contributor

This could be auto-generated, yes. But I think it is also possible to use a template to do this. Create a template that can hold an SBE codec (the template param) and use operator() to return the codec for usage. The template would hold the buffer as a std::array with the length being the largest expected length.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants