simple-binary-encoding icon indicating copy to clipboard operation
simple-binary-encoding copied to clipboard

Parametrization for decoder/encoder generation

Open RainM opened this issue 7 years ago • 3 comments

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.

RainM avatar Nov 17 '18 18:11 RainM

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

mjpt777 avatar Nov 18 '18 08:11 mjpt777

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 

ksergey avatar Jan 30 '19 14:01 ksergey

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

tmontgomery avatar Jan 30 '19 16:01 tmontgomery