Custom storage
A repeated, string, bytes or message field is stored in a class of the library: an array with a fixed size. As of version 4.0.0 you can replace that class with one of your own, for instance one backed by external RAM, or one which keeps a ring of the last samples. With the customStorage option you take control of the storage type of a repeated, string, bytes or message field. The generated message exposes the storage type as a plain template parameter, without a size and without a default, so you supply the complete type yourself:
message Log
{
repeated uint32 values = 1 [(EmbeddedProto.options).customStorage = true];
}Log<MyStorage> log;The supplied type must derive from ::EmbeddedProto::RepeatedField<T> for a repeated field, from ::EmbeddedProto::internal::BaseStringBytes for a string or bytes field, or from ::EmbeddedProto::MessageInterface for a message field. This is enforced with a static assert. Your type implements the same virtual functions as the fixed size storage it replaces, plus a static max_serialized_size() function. The unit tests in the repository, test/test_custom_storage.cpp and the mock storage classes next to them, are the best place to start from.
The option takes precedence over maxLength. Fields without the option keep their existing behaviour, so existing proto files and generated code are unchanged.
Do you want to stream the data rather than store it? See callback storage.