.gitignore: add some more IDE / tools related file
[babeltrace.git] / src / plugins / common / param-validation / param-validation.h
index 0daee1ff9040e0c3498126e153a59d47b7d77df4..8361b593473601386ffd37ed3e643124a5cbbbea 100644 (file)
@@ -3,6 +3,7 @@
  *
  * Copyright 2019 EfficiOS Inc.
  */
  *
  * Copyright 2019 EfficiOS Inc.
  */
+
 #ifndef BABELTRACE_PLUGINS_COMMON_PARAM_VALIDATION_PARAM_VALIDATION_H
 #define BABELTRACE_PLUGINS_COMMON_PARAM_VALIDATION_PARAM_VALIDATION_H
 
 #ifndef BABELTRACE_PLUGINS_COMMON_PARAM_VALIDATION_PARAM_VALIDATION_H
 #define BABELTRACE_PLUGINS_COMMON_PARAM_VALIDATION_PARAM_VALIDATION_H
 
@@ -19,7 +20,7 @@ struct bt_param_validation_value_descr;
 
 #if defined(__cplusplus)
 #define BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_END \
 
 #if defined(__cplusplus)
 #define BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_END \
-       { bt_param_validation_map_value_entry_descr::end }
+       { bt_param_validation_map_value_entry_descr {} }
 #else
 #define BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_END { NULL, 0, {} }
 #endif
 #else
 #define BT_PARAM_VALIDATION_MAP_VALUE_ENTRY_END { NULL, 0, {} }
 #endif
@@ -53,29 +54,45 @@ typedef enum bt_param_validation_status
 
 struct bt_param_validation_value_descr {
 #if defined(__cplusplus)
 
 struct bt_param_validation_value_descr {
 #if defined(__cplusplus)
-       static struct {} array_t;
-       static struct {} string_t;
-       static struct {} signed_integer_t;
-       static struct {} bool_t;
-
-       bt_param_validation_value_descr(decltype(array_t),
+       static bt_param_validation_value_descr makeArray(
                        uint64_t min_length, uint64_t max_length,
                        const bt_param_validation_value_descr &element_type)
                        uint64_t min_length, uint64_t max_length,
                        const bt_param_validation_value_descr &element_type)
-               : type{BT_VALUE_TYPE_ARRAY}, array{min_length, max_length, &element_type}
-       {}
+       {
+               bt_param_validation_value_descr descr {BT_VALUE_TYPE_ARRAY};
+
+               descr.array.min_length = min_length;
+               descr.array.max_length = max_length;
+               descr.array.element_type = &element_type;
 
 
-       bt_param_validation_value_descr(decltype(string_t),
+               return descr;
+       }
+
+       static bt_param_validation_value_descr makeString(
                        const char **choices = nullptr)
                        const char **choices = nullptr)
-               : type{BT_VALUE_TYPE_STRING}, string{choices}
-        {}
+       {
+               bt_param_validation_value_descr descr {BT_VALUE_TYPE_STRING};
 
 
-       bt_param_validation_value_descr(decltype(signed_integer_t))
-               : type{BT_VALUE_TYPE_SIGNED_INTEGER}
-       {}
+               descr.string.choices = choices;
+
+               return descr;
+       }
 
 
-       bt_param_validation_value_descr(decltype(bool_t))
-               : type{BT_VALUE_TYPE_BOOL}
+       static bt_param_validation_value_descr makeSignedInteger()
+       {
+               return bt_param_validation_value_descr {BT_VALUE_TYPE_SIGNED_INTEGER};
+       }
+
+       static bt_param_validation_value_descr makeBool()
+       {
+               return bt_param_validation_value_descr {BT_VALUE_TYPE_BOOL};
+       }
+
+private:
+       bt_param_validation_value_descr(bt_value_type type_)
+               : type {type_}
        {}
        {}
+
+public:
 #endif
 
        bt_value_type type;
 #endif
 
        bt_value_type type;
@@ -107,12 +124,14 @@ struct bt_param_validation_value_descr {
 
 struct bt_param_validation_map_value_entry_descr {
 #if defined(__cplusplus)
 
 struct bt_param_validation_map_value_entry_descr {
 #if defined(__cplusplus)
-       static struct {} end;
-
-       bt_param_validation_map_value_entry_descr(decltype(end))
+       /*
+        * Construct an "end" descriptor, used to denote the end of a descriptor
+        * list.
+        */
+       bt_param_validation_map_value_entry_descr()
                : key{nullptr},
                /* These values are not important. */
                : key{nullptr},
                /* These values are not important. */
-               is_optional{false}, value_descr(bt_param_validation_value_descr::bool_t)
+               is_optional{false}, value_descr(bt_param_validation_value_descr::makeBool())
        {}
 
        bt_param_validation_map_value_entry_descr(const char *key_, bool is_optional_,
        {}
 
        bt_param_validation_map_value_entry_descr(const char *key_, bool is_optional_,
@@ -127,13 +146,13 @@ struct bt_param_validation_map_value_entry_descr {
        const struct bt_param_validation_value_descr value_descr;
 };
 
        const struct bt_param_validation_value_descr value_descr;
 };
 
-BT_EXTERN_C BT_HIDDEN
+BT_EXTERN_C
 enum bt_param_validation_status bt_param_validation_validate(
                const bt_value *params,
                const struct bt_param_validation_map_value_entry_descr *entries,
                gchar **error);
 
 enum bt_param_validation_status bt_param_validation_validate(
                const bt_value *params,
                const struct bt_param_validation_map_value_entry_descr *entries,
                gchar **error);
 
-BT_EXTERN_C BT_HIDDEN __BT_ATTR_FORMAT_PRINTF(2, 3)
+BT_EXTERN_C __BT_ATTR_FORMAT_PRINTF(2, 3)
 enum bt_param_validation_status bt_param_validation_error(
                struct bt_param_validation_context *ctx,
                const char *format, ...);
 enum bt_param_validation_status bt_param_validation_error(
                struct bt_param_validation_context *ctx,
                const char *format, ...);
This page took 0.026471 seconds and 4 git commands to generate.