24 #ifndef DCCLV4FIELDCODECHASHH
25 #define DCCLV4FIELDCODECHASHH
27 #include "field_codec_default.h"
45 uint32 pre_encode(
const uint32& field_value)
override {
return masked_hash(); }
48 uint32 expected = masked_hash();
49 uint32 received = wire_value;
51 if (expected != received)
54 ss <<
"Hash value mismatch. Expected: " << expected <<
", received: " << received
55 <<
". Ensure both sender and receiver are using identical DCCL definitions";
57 throw(
Exception(ss.str(), this->root_descriptor()));
62 void validate()
override
69 "(dccl.field).max must equal be a power of 2 minus 1 "
70 "(e.g. 255, 4294967295, etc.)");
72 static_cast<double>(std::numeric_limits<uint32>::max()),
73 "(dccl.field).max must fit in unsigned 32 bits.");
78 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.