1b3642de4b
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 {}; } |
||
---|---|---|
.. | ||
inc/bond | ||
test | ||
.gitignore | ||
CMakeLists.txt |