bond/cpp
Adam Sapek 1b3642de4b Allow fixing version of multi-version protocols
When a protocol supports multiple version some compile-time
optimizations become impossible. For example protocol transcoding always
has to check version at runtime and perform fast pass-through only when
version of source and target are the same. Consequently both code paths,
fast pass-through and field-by-field transcoding, must be instantiated,
increasing build time and size of the executable code.

This change defines a global protocol trait that can be specialized by an
application to fix the version of a protocol. Effectively application can
promise to use only one version of the protocol (defined by
bond::default_version<Reader>). For example in order to use only the
version 2 of Compact Binary protocol application could include a header
file in the generated code using --header option:

        gbc c++ --header="<compact_binary_v2.h>" foo.bond

where compact_binary_v2.h contains:

        #include <bond/core/traits.h>
        #include <bond/core/bond_version.h>

        namespace bond
        {
            template <typename Input>
            class CompactBinaryReader;

            template <typename Input> struct
            default_version<CompactBinaryReader<Input> >
            {
                static const uint16_t value = v2;
            };

            template <typename Input> struct
            enable_protocol_versions<CompactBinaryReader<Input> >
                : false_type {};
        }
2015-06-22 12:32:30 -07:00
..
inc/bond Allow fixing version of multi-version protocols 2015-06-22 12:32:30 -07:00
test Fix name conflict in C++ unit test 2015-06-04 20:02:41 -07:00
.gitignore Initial commit 2015-01-09 11:21:05 -08:00
CMakeLists.txt Initial commit 2015-01-09 11:21:05 -08:00