23 #ifndef DCCLV4FIELDCODECHASHH
24 #define DCCLV4FIELDCODECHASHH
26 #include "field_codec_default.h"
44 uint32 pre_encode(
const uint32& field_value)
override {
return masked_hash(); }
47 uint32 expected = masked_hash();
48 uint32 received = wire_value;
50 if (expected != received)
53 ss <<
"Hash value mismatch. Expected: " << expected <<
", received: " << received
54 <<
". Ensure both sender and receiver are using identical DCCL definitions";
56 throw(
Exception(ss.str(), this->root_descriptor()));
61 void validate()
override
68 "(dccl.field).max must equal be a power of 2 minus 1 "
69 "(e.g. 255, 4294967295, etc.)");
71 static_cast<double>(std::numeric_limits<uint32>::max()),
72 "(dccl.field).max must fit in unsigned 32 bits.");
77 std::size_t
hash = this->manager().hash(this->root_descriptor());
Bitset encode() override
Encode an empty field.
Dynamic Compact Control Language namespace.
Exception class for DCCL.
google::protobuf::uint32 uint32
an unsigned 32 bit integer
void require(bool b, const std::string &description)
Essentially an assertion to be used in the validate() virtual method.
void set_force_use_required(bool force_required=true)
Force the codec to always use the "required" field encoding, regardless of the FieldDescriptor settin...
unsigned ceil_log2(dccl::uint64 v)
A variable size container of bits (subclassed from std::deque<bool>) with an optional hierarchy....
Provides a basic bounded arbitrary length numeric (double, float, uint32, uint64, int32,...
virtual std::size_t hash()
Generate a field specific hash to be combined with the descriptor hash.