DCCL v3
Public Types | Public Member Functions | List of all members
dccl::TypedFieldCodec< WireType, FieldType > Class Template Referenceabstract

Base class for static-typed (no boost::any) field encoders/decoders. Most single-valued user defined variable length codecs will start with this class. Use TypedFixedFieldCodec if your codec is fixed length (always uses the same number of bits on the wire) or RepeatedTypedFieldCodec if your codec has special behavior for repeated (vector) fields. More...

#include <dccl/field_codec_typed.h>

Inheritance diagram for dccl::TypedFieldCodec< WireType, FieldType >:
Inheritance graph
[legend]

Public Types

typedef WireType wire_type
 
typedef FieldType field_type
 

Public Member Functions

virtual Bitset encode ()=0
 Encode an empty field. More...
 
virtual Bitset encode (const WireType &wire_value)=0
 Encode a non-empty field. More...
 
virtual WireType decode (Bitset *bits)=0
 Decode a field. If the field is empty (i.e. was encoded using the zero-argument encode()), throw NullValueException to indicate this. More...
 
virtual unsigned size ()=0
 Calculate the size (in bits) of an empty field. More...
 
virtual unsigned size (const WireType &wire_value)=0
 Calculate the size (in bits) of a non-empty field. More...
 
- Public Member Functions inherited from dccl::FieldCodecBase
 FieldCodecBase ()
 
virtual ~FieldCodecBase ()
 
void base_encode (Bitset *bits, const google::protobuf::Message &msg, MessagePart part)
 Encode this part (body or head) of the base message. More...
 
void base_size (unsigned *bit_size, const google::protobuf::Message &msg, MessagePart part)
 Calculate the size (in bits) of a part of the base message when it is encoded. More...
 
void base_decode (Bitset *bits, google::protobuf::Message *msg, MessagePart part)
 Decode part of a message. More...
 
void base_max_size (unsigned *bit_size, const google::protobuf::Descriptor *desc, MessagePart part)
 Calculate the maximum size of a message given its Descriptor alone (no data) More...
 
void base_min_size (unsigned *bit_size, const google::protobuf::Descriptor *desc, MessagePart part)
 Calculate the minimum size of a message given its Descriptor alone (no data) More...
 
void base_validate (const google::protobuf::Descriptor *desc, MessagePart part)
 Validate this part of the message to make sure all required extensions are set. More...
 
void base_info (std::ostream *os, const google::protobuf::Descriptor *desc, MessagePart part)
 Get human readable information (size of fields, etc.) about this part of the DCCL message. More...
 
void field_pre_encode (boost::any *wire_value, const boost::any &field_value)
 Pre-encodes a non-repeated (i.e. optional or required) field by converting the FieldType representation (the Google Protobuf representation) into the WireType representation (the type used in the encoded DCCL message). This allows for type-converting codecs. More...
 
void field_pre_encode_repeated (std::vector< boost::any > *wire_values, const std::vector< boost::any > &field_values)
 Pre-encodes a repeated field. More...
 
void field_encode (Bitset *bits, const boost::any &field_value, const google::protobuf::FieldDescriptor *field)
 Encode a non-repeated field. More...
 
void field_encode_repeated (Bitset *bits, const std::vector< boost::any > &field_values, const google::protobuf::FieldDescriptor *field)
 Encode a repeated field. More...
 
void field_size (unsigned *bit_size, const boost::any &field_value, const google::protobuf::FieldDescriptor *field)
 Calculate the size of a field. More...
 
void field_size_repeated (unsigned *bit_size, const std::vector< boost::any > &wire_values, const google::protobuf::FieldDescriptor *field)
 Calculate the size of a repeated field. More...
 
void field_decode (Bitset *bits, boost::any *field_value, const google::protobuf::FieldDescriptor *field)
 Decode a non-repeated field. More...
 
void field_decode_repeated (Bitset *bits, std::vector< boost::any > *field_values, const google::protobuf::FieldDescriptor *field)
 Decode a repeated field. More...
 
void field_post_decode (const boost::any &wire_value, boost::any *field_value)
 Post-decodes a non-repeated (i.e. optional or required) field by converting the WireType (the type used in the encoded DCCL message) representation into the FieldType representation (the Google Protobuf representation). This allows for type-converting codecs. More...
 
void field_post_decode_repeated (const std::vector< boost::any > &wire_values, std::vector< boost::any > *field_values)
 Post-decodes a repeated field. More...
 
void field_max_size (unsigned *bit_size, const google::protobuf::FieldDescriptor *field)
 Calculate the upper bound on this field's size (in bits) More...
 
void field_min_size (unsigned *bit_size, const google::protobuf::FieldDescriptor *field)
 Calculate the lower bound on this field's size (in bits) More...
 
void field_validate (bool *b, const google::protobuf::FieldDescriptor *field)
 Validate this field, checking that all required option extensions are set (e.g. (dccl.field).max and (dccl.field).min for arithmetic codecs) More...
 
void field_info (std::ostream *os, const google::protobuf::FieldDescriptor *field)
 Write human readable information about the field and its bounds to the provided stream. More...
 
std::string name () const
 the name of the codec used to identifier it in the .proto custom option extension
 
google::protobuf::FieldDescriptor::Type field_type () const
 the type exposed to the user in the original and decoded Protobuf messages More...
 
google::protobuf::FieldDescriptor::CppType wire_type () const
 the C++ type used "on the wire". This is the type visible after pre_encode and before post_decode functions are called. More...
 
const google::protobuf::FieldDescriptor * this_field () const
 Returns the FieldDescriptor (field schema meta-data) for this field. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from dccl::FieldCodecBase
static const google::protobuf::Descriptor * this_descriptor ()
 Returns the Descriptor (message schema meta-data) for the immediate parent Message. More...
 
static const google::protobuf::Messageroot_message ()
 
static bool has_codec_group ()
 
static std::string codec_group (const google::protobuf::Descriptor *desc)
 
static std::string codec_group ()
 
static int codec_version ()
 
static MessagePart part ()
 the part of the message currently being encoded (head or body).
 
- Protected Member Functions inherited from dccl::FieldCodecSelector< WireType, FieldType >
virtual WireType pre_encode (const FieldType &field_value)=0
 Convert from the FieldType representation (used in the Google Protobuf message) to the WireType representation (used with encode() and decode(), i.e. "on the wire"). More...
 
virtual FieldType post_decode (const WireType &wire_value)=0
 Convert from the WireType representation (used with encode() and decode(), i.e. "on the wire") to the FieldType representation (used in the Google Protobuf message). More...
 
- Protected Member Functions inherited from dccl::FieldCodecBase
dccl::DCCLFieldOptions dccl_field_options () const
 Get the DCCL field option extension value for the current field. More...
 
void require (bool b, const std::string &description)
 Essentially an assertion to be used in the validate() virtual method. More...
 
bool use_required ()
 Whether to use the required or optional encoding.
 
virtual void validate ()
 Validate a field. Use require() inside your overloaded validate() to assert requirements or throw Exceptions directly as needed.
 
virtual std::string info ()
 Write field specific information (in addition to general information such as sizes that are automatically written by this class for all fields. More...
 
virtual unsigned max_size ()=0
 Calculate maximum size of the field in bits. More...
 
virtual unsigned min_size ()=0
 Calculate minimum size of the field in bits. More...
 
virtual void any_encode_repeated (Bitset *bits, const std::vector< boost::any > &wire_values)
 
virtual void any_decode_repeated (Bitset *repeated_bits, std::vector< boost::any > *field_values)
 
virtual void any_pre_encode_repeated (std::vector< boost::any > *wire_values, const std::vector< boost::any > &field_values)
 
virtual void any_post_decode_repeated (const std::vector< boost::any > &wire_values, std::vector< boost::any > *field_values)
 
virtual unsigned any_size_repeated (const std::vector< boost::any > &wire_values)
 
virtual unsigned max_size_repeated ()
 
virtual unsigned min_size_repeated ()
 

Detailed Description

template<typename WireType, typename FieldType = WireType>
class dccl::TypedFieldCodec< WireType, FieldType >

Base class for static-typed (no boost::any) field encoders/decoders. Most single-valued user defined variable length codecs will start with this class. Use TypedFixedFieldCodec if your codec is fixed length (always uses the same number of bits on the wire) or RepeatedTypedFieldCodec if your codec has special behavior for repeated (vector) fields.

Template Parameters
WireTypethe type used for the encode and decode functions. This can be any C++ type, and is often the same as FieldType, unless a type conversion should be performed. The reason for using a different WireType and FieldType should be clear from the DefaultEnumCodec which uses DefaultNumericFieldCodec to do all the numerical encoding / decoding while DefaultEnumCodec does the type conversion (pre_encode() and post_decode()).
FieldTypethe type used in the Google Protobuf message that is exposed to the end-user Codec::decode(), Codec::encode(), etc. functions.

Definition at line 82 of file field_codec_typed.h.

Member Function Documentation

template<typename WireType, typename FieldType = WireType>
virtual WireType dccl::TypedFieldCodec< WireType, FieldType >::decode ( Bitset bits)
pure virtual
template<typename WireType, typename FieldType = WireType>
virtual Bitset dccl::TypedFieldCodec< WireType, FieldType >::encode ( )
pure virtual
template<typename WireType, typename FieldType = WireType>
virtual Bitset dccl::TypedFieldCodec< WireType, FieldType >::encode ( const WireType &  wire_value)
pure virtual
template<typename WireType, typename FieldType = WireType>
virtual unsigned dccl::TypedFieldCodec< WireType, FieldType >::size ( )
pure virtual

Calculate the size (in bits) of an empty field.

Returns
the size (in bits) of the empty field.

Implemented in dccl::RepeatedTypedFieldCodec< WireType, FieldType >, dccl::RepeatedTypedFieldCodec< Model::value_type, FieldType >, dccl::RepeatedTypedFieldCodec< dccl::int32 >, dccl::RepeatedTypedFieldCodec< Model::value_type, const google::protobuf::EnumValueDescriptor * >, dccl::v2::DefaultNumericFieldCodec< WireType, FieldType >, dccl::v2::DefaultNumericFieldCodec< dccl::uint32 >, dccl::v2::DefaultNumericFieldCodec< time_wire_type, uint64 >, dccl::v2::DefaultNumericFieldCodec< time_wire_type, double >, dccl::v2::DefaultNumericFieldCodec< double, double >, dccl::v2::DefaultNumericFieldCodec< time_wire_type, int64 >, dccl::v2::DefaultNumericFieldCodec< time_wire_type, TimeType >, dccl::v2::DefaultNumericFieldCodec< int32, const google::protobuf::EnumValueDescriptor * >, dccl::TypedFixedFieldCodec< WireType, FieldType >, dccl::TypedFixedFieldCodec< double >, dccl::TypedFixedFieldCodec< dccl::uint32 >, dccl::TypedFixedFieldCodec< protobuf::CCLMDATState::GFIPitchOil >, dccl::TypedFixedFieldCodec< float >, dccl::TypedFixedFieldCodec< dccl::uint64 >, dccl::TypedFixedFieldCodec< CustomMsg >, dccl::TypedFixedFieldCodec< T >, dccl::TypedFixedFieldCodec< time_wire_type, uint64 >, dccl::TypedFixedFieldCodec< time_wire_type, double >, dccl::TypedFixedFieldCodec< double, double >, dccl::TypedFixedFieldCodec< time_wire_type, int64 >, dccl::TypedFixedFieldCodec< time_wire_type, TimeType >, dccl::TypedFixedFieldCodec< dccl::uint32, dccl::uint32 >, dccl::TypedFixedFieldCodec< int32, const google::protobuf::EnumValueDescriptor * >, dccl::TypedFixedFieldCodec< bool >, and dccl::DefaultIdentifierCodec.

template<typename WireType, typename FieldType = WireType>
virtual unsigned dccl::TypedFieldCodec< WireType, FieldType >::size ( const WireType &  wire_value)
pure virtual

Calculate the size (in bits) of a non-empty field.

Parameters
wire_valueValue to use when calculating the size of the field. If calculating the size requires encoding the field completely, cache the encoded value for a likely future call to encode() for the same wire_value.
Returns
the size (in bits) of the field.

Implemented in dccl::RepeatedTypedFieldCodec< WireType, FieldType >, dccl::RepeatedTypedFieldCodec< Model::value_type, FieldType >, dccl::RepeatedTypedFieldCodec< dccl::int32 >, dccl::RepeatedTypedFieldCodec< Model::value_type, const google::protobuf::EnumValueDescriptor * >, and dccl::DefaultIdentifierCodec.


The documentation for this class was generated from the following file: