2 #ifndef SSP21_SEQSTRUCTFIELD_H 3 #define SSP21_SEQSTRUCTFIELD_H 5 #include "log4cpp/Logger.h" 6 #include "log4cpp/LogMacros.h" 8 #include "ssp21/crypto/IMessagePrinter.h" 9 #include "ssp21/crypto/VLength.h" 11 #include "ssp21/util/ICollection.h" 15 template <
class StructType, u
int32_t MAX_COUNT>
21 uint32_t capacity()
const 30 for (uint32_t i = 0; i < this->count(); ++i)
32 sum += this->get(i)->size();
35 return VLength::size_in_bytes(this->count()) + sum;
43 auto cerr = VLength::read(count, input);
44 if (any(cerr))
return cerr;
49 auto serr = item.read(input);
50 if (any(serr))
return serr;
52 if (!this->push(item))
65 const auto err = VLength::write(this->count(), output);
66 if (any(err))
return err;
68 for (uint32_t i = 0; i < this->count_; ++i)
70 auto serr = this->items_[i].write(output);
71 if (any(serr))
return serr;
79 char message[log4cpp::max_log_entry_size];
80 SAFE_STRING_FORMAT(message, log4cpp::max_log_entry_size,
"%s (count = %u)", name, this->count());
81 printer.print(message);
83 for (uint32_t i = 0; i < this->count_; ++i)
85 SAFE_STRING_FORMAT(message, log4cpp::max_log_entry_size,
"field #%u", i + 1);
86 printer.print(message);
88 this->items_[i].print(
"test", printer);
97 bool push(
const StructType& item)
99 if (this->count_ == MAX_COUNT)
104 this->items_[this->count_++] = item;
109 StructType
const* get(uint32_t i)
const 111 if (i >= this->count_)
116 return &this->items_[i];
119 uint32_t count()
const 127 StructType items_[MAX_COUNT];
SSP21-cpp main namespace.
reached an implementation specific capacity limit