@@ -281,6 +281,18 @@ class MutableOption {
281281 value_type value_;
282282};
283283
284+ template <typename Constrain, typename Marshaller, typename Annotation,
285+ typename T>
286+ struct OptionParameters {
287+ Configuration *parent;
288+ std::string path;
289+ std::string description;
290+ T defaultValue;
291+ Constrain constrain{};
292+ Marshaller marshaller{};
293+ Annotation annotation{};
294+ };
295+
284296/* *
285297 * Represent a Configuration option.
286298 *
@@ -292,6 +304,8 @@ class Option : public OptionBaseV3 {
292304public:
293305 using value_type = T;
294306 using constrain_type = Constrain;
307+ using OptionParametersType =
308+ OptionParameters<Constrain, Marshaller, Annotation, T>;
295309
296310 Option (Configuration *parent, std::string path, std::string description,
297311 const T &defaultValue = T(), Constrain constrain = Constrain(),
@@ -307,6 +321,12 @@ class Option : public OptionBaseV3 {
307321 }
308322 }
309323
324+ Option (OptionParametersType params)
325+ : Option(params.parent, std::move(params.path),
326+ std::move(params.description), std::move(params.defaultValue),
327+ std::move(params.constrain), std::move(params.marshaller),
328+ std::move(params.annotation)) {}
329+
310330 std::string typeString () const override { return OptionTypeName<T>::get (); }
311331
312332 void dumpDescription (RawConfig &config) const override {
@@ -421,9 +441,14 @@ template <typename T, typename Annotation>
421441using OptionWithAnnotation =
422442 Option<T, NoConstrain<T>, DefaultMarshaller<T>, Annotation>;
423443
444+ // / Shorthand if you want a option type with only custom annotation.
445+ template <typename Annotation>
446+ using KeyListOptionWithAnnotation =
447+ Option<KeyList, ListConstrain<KeyConstrain>, DefaultMarshaller<KeyList>,
448+ Annotation>;
449+
424450// / Shorthand for KeyList option with constrain.
425- using KeyListOption = Option<KeyList, ListConstrain<KeyConstrain>,
426- DefaultMarshaller<KeyList>, NoAnnotation>;
451+ using KeyListOption = KeyListOptionWithAnnotation<NoAnnotation>;
427452
428453// / Shorthand for create a key list constrain.
429454static inline ListConstrain<KeyConstrain>
@@ -465,7 +490,7 @@ struct ConditionalHiddenHelper<true, SubConfigOption> {
465490 class HiddenSubConfigOption : public SubConfigOption {
466491 public:
467492 using SubConfigOption::SubConfigOption;
468- bool skipDescription () const { return true ; }
493+ bool skipDescription () const override { return true ; }
469494 };
470495 using OptionType = HiddenSubConfigOption;
471496};
0 commit comments