Teach gdb::option about string options
[deliverable/binutils-gdb.git] / gdb / cli / cli-option.h
index 1bfbfce1ce512991f85f6afaa13274a99fa57df5..a26b52f7f29c92fb21bd7deab49442d99a2a5034 100644 (file)
@@ -86,6 +86,7 @@ public:
       unsigned int *(*uinteger) (const option_def &, void *ctx);
       int *(*integer) (const option_def &, void *ctx);
       const char **(*enumeration) (const option_def &, void *ctx);
+      char **(*string) (const option_def &, void *ctx);
     }
   var_address;
 
@@ -261,6 +262,26 @@ struct enum_option_def : option_def
   }
 };
 
+/* A var_string command line option.  */
+
+template<typename Context>
+struct string_option_def : option_def
+{
+  string_option_def (const char *long_option_,
+                    char **(*get_var_address_cb_) (Context *),
+                    show_value_ftype *show_cmd_cb_,
+                    const char *set_doc_,
+                    const char *show_doc_ = nullptr,
+                    const char *help_doc_ = nullptr)
+    : option_def (long_option_, var_string,
+                 (erased_get_var_address_ftype *) get_var_address_cb_,
+                 show_cmd_cb_,
+                 set_doc_, show_doc_, help_doc_)
+  {
+    var_address.enumeration = detail::get_var_address<const char *, Context>;
+  }
+};
+
 /* A group of options that all share the same context pointer to pass
    to the options' get-current-value callbacks.  */
 struct option_def_group
This page took 0.025399 seconds and 4 git commands to generate.