diff options
Diffstat (limited to 'contrib/epee/include/serialization/keyvalue_serialization.h')
-rw-r--r-- | contrib/epee/include/serialization/keyvalue_serialization.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/contrib/epee/include/serialization/keyvalue_serialization.h b/contrib/epee/include/serialization/keyvalue_serialization.h index bf2c8dacd..d4413a71b 100644 --- a/contrib/epee/include/serialization/keyvalue_serialization.h +++ b/contrib/epee/include/serialization/keyvalue_serialization.h @@ -70,6 +70,15 @@ public: \ #define KV_SERIALIZE_N(varialble, val_name) \ epee::serialization::selector<is_store>::serialize(this_ref.varialble, stg, hparent_section, val_name); + template<typename T> inline void serialize_default(const T &t, T v) { } + template<typename T> inline void serialize_default(T &t, T v) { t = v; } + +#define KV_SERIALIZE_OPT_N(variable, val_name, default_value) \ + do { \ + if (!epee::serialization::selector<is_store>::serialize(this_ref.variable, stg, hparent_section, val_name)) \ + epee::serialize_default(this_ref.variable, default_value); \ + } while (0); + #define KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE_N(varialble, val_name) \ epee::serialization::selector<is_store>::serialize_t_val_as_blob(this_ref.varialble, stg, hparent_section, val_name); @@ -86,6 +95,7 @@ public: \ #define KV_SERIALIZE_VAL_POD_AS_BLOB(varialble) KV_SERIALIZE_VAL_POD_AS_BLOB_N(varialble, #varialble) #define KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(varialble) KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE_N(varialble, #varialble) //skip is_pod compile time check #define KV_SERIALIZE_CONTAINER_POD_AS_BLOB(varialble) KV_SERIALIZE_CONTAINER_POD_AS_BLOB_N(varialble, #varialble) +#define KV_SERIALIZE_OPT(variable,default_value) KV_SERIALIZE_OPT_N(variable, #variable, default_value) } |