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

Parametrization for decoder/encoder generation #619

Open
RainM opened this issue Nov 17, 2018 · 3 comments
Open

Parametrization for decoder/encoder generation #619

RainM opened this issue Nov 17, 2018 · 3 comments

Comments

@RainM
Copy link

RainM commented Nov 17, 2018

Hi, is it possible to parametrize generated encoder/decoder?
In particular, I'm asking for some way to replace current exception throwing in C++ generator for something. Right now, the only way for a decoder/encoder to generate an error is throwing std::runtime_error.
So, the idea is to let a developer decide what to do, raise std::runtime_error exception or raise some platform-specific exception or legacy way with setjump/longjump.
As an addition, this idea may require some additional headers to be included (for custom exceptions, for example).
How it may be solved. Pass both additional classpath at sbe-tool start (for loading developer's code) and some '-D' argument which make an sbe-tool to instance custom developer's code and to execute some callbacks from developer's code which generates whatever developer wants.

@mjpt777
Copy link
Contributor

mjpt777 commented Nov 18, 2018

Would you like to submit a PR with your ideas for how this can be implemented?

@ksergey
Copy link
Contributor

ksergey commented Jan 30, 2019

Something like:

        if (SBE_BOUNDS_CHECK_EXPECT((position > m_bufferLength), false))
        {
            SBE_BOUNDS_CHECK_ERROR("buffer too short [E100]");
        }

sbe.h

#ifndef SBE_BOUNDS_CHECK_ERROR
#    define SBE_BOUNDS_CHECK_ERROR(msg) { throw std::runtime_error(msg); }
#endif 

@tmontgomery
Copy link
Contributor

This has been requested before. Probably a clean way to handle it.

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

4 participants