I live in a very safety/critical Ada-ic environment, and have taken the habit of having well defined and bounded type definition. I am also confronted to lots ASN1 usage/evangelists.
One of the key features that some people around me define as superior in ASN1 over protocol buffers is the ability to define, and therefore check, data range.
So,
Usual numerical types definition such as int32, int64 is out of scope here.
I read this Google overview and found no reference to any data range definition. Except for features concerning the enum management/representation, and some ordering features.
To give some other references, I heard of/read the links below and became aware of an Ada implementation project.
Does anyone know of an Ada plugin for protocol buffers?
which led to
http://www.diva-portal.org/smash/get/diva2:690878/FULLTEXT02.pdf
https://github.com/persan/protobuf-ada
It's true that protocol buffers do not have any built-in mechanism for numeric range.
The syntax however does support defining custom options:
extend google.protobuf.FieldOptions {
optional int32 maxval = 50001;
optional int32 minval = 50002;
}
message MyMessage {
required int32 month = 1 [(minval) = 1, (maxval) = 12];
}
Depending on library used, these can then either be accessed in runtime using reflection, or you can use a custom code generator to automatically generate verification code.
Is it true that protocol buffers do not have any range definition system ?
Yes
Are there any means on top of protocol buffer that could provide such a feature ?
You write code that checks the values are in the expected range.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With