There are two key expresssion support classes in zenoh-cpp: KeyExpr and KeyExprView, which corresponds to zenoh-c z_keyexpr_t and z_owned_keyexpr_t structures.
Both these classes supports operatons like equals, join, etc. Currently these operations are implemented as methods. This leads to code duplication: all real functionality is implemented in KeyExprView, but to provide convenient API the KeyExpr repeats all these methods by just proxying them to it's KeyExprView representation.
Taking into account that each of these methods exists in two variants (with and without error code support), the amount of boilerplate code becomes too big. This also unnecessarily increases size of documentation.
I propose to remove these methods and replace them with standalone functions named keyexpr_equals, keyexpr_join, etc. These functions should accept const KeyExprView& type, so they will automatically accept KeyExpr, const char*, std::string_view.
Describe the feature
There are two key expresssion support classes in zenoh-cpp:
KeyExpr
andKeyExprView
, which corresponds to zenoh-cz_keyexpr_t
andz_owned_keyexpr_t
structures.Both these classes supports operatons like
equals
,join
, etc. Currently these operations are implemented as methods. This leads to code duplication: all real functionality is implemented inKeyExprView
, but to provide convenient API theKeyExpr
repeats all these methods by just proxying them to it'sKeyExprView
representation.Taking into account that each of these methods exists in two variants (with and without error code support), the amount of boilerplate code becomes too big. This also unnecessarily increases size of documentation.
Fix for issue https://github.com/eclipse-zenoh/zenoh-cpp/issues/20 adds even more duplicated code (variants of these functions with
Session
parameter).I propose to remove these methods and replace them with standalone functions named
keyexpr_equals
,keyexpr_join
, etc. These functions should acceptconst KeyExprView&
type, so they will automatically acceptKeyExpr
,const char*
,std::string_view
.It will be possible to write code like this:
instead of
But more important that the code duplication between
KeyExprView
andKeyExpr
will be removed