24 #ifndef FIELD_CODEC_PRESENCE_20190722H
25 #define FIELD_CODEC_PRESENCE_20190722H
27 #include "dccl/field_codec_typed.h"
44 template<
typename WrappedType>
101 encoded.push_front(
true);
112 bool present = bits->front();
144 return _inner_codec.max_size();
157 return _inner_codec.min_size();
virtual unsigned max_size()
Calculate maximum size of the field in bits.
virtual Bitset encode(const wire_type &value)
Encodes a non-empty field, adding a 1 bit to the front for optional fields.
void get_more_bits(size_type num_bits)
Retrieve more bits from the parent Bitset.
Dynamic Compact Control Language namespace.
virtual unsigned size(const wire_type &wire_value)
Size of a non-empty field; gets size from "wrapped" codec, adds 1 for optional fields.
virtual Bitset encode()
Encodes an empty field as a single 0 bit.
virtual wire_type decode(Bitset *bits)
Decodes a field, first evaluating the presence bit if necessary.
Base::field_type field_type
The field_type of the "wrapped" codec.
WrappedType wrapped_type
The codec type of the "wrapped" codec.
Exception used to signal null (non-existent) value within field codecs during decode.
A variable size container of bits (subclassed from std::deque<bool>) with an optional hierarchy....
virtual void validate()
Calls _inner_codec.validate()
WrappedType _inner_codec
Instance of the "wrapped" codec.
Base class for static-typed (no boost::any) field encoders/decoders. Most single-valued user defined ...
Encodes empty optional fields with a single "presence" bit.
bool use_required()
Whether to use the required or optional encoding.
virtual unsigned size()
Size of an empty field (1 bit)
virtual unsigned min_size()
Calculate minimum size of the field in bits.
Base::wire_type wire_type
The wire_type of the "wrapped" codec.