summaryrefslogtreecommitdiff
path: root/gdb/ui-out.h
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/ui-out.h')
-rw-r--r--gdb/ui-out.h37
1 files changed, 36 insertions, 1 deletions
diff --git a/gdb/ui-out.h b/gdb/ui-out.h
index fbf9c9bd326..e682d44383e 100644
--- a/gdb/ui-out.h
+++ b/gdb/ui-out.h
@@ -68,11 +68,24 @@ enum ui_out_type
ui_out_type_list
};
+enum class field_kind
+ {
+ INT,
+ STRING,
+ };
+
/* An int field, to be passed to %pF in format strings. */
-struct int_field_s
+struct base_field_s
{
const char *name;
+ field_kind kind;
+};
+
+/* An int field, to be passed to %pF in format strings. */
+
+struct int_field_s : base_field_s
+{
int val;
};
@@ -85,10 +98,32 @@ int_field (const char *name, int val,
int_field_s &&tmp = {})
{
tmp.name = name;
+ tmp.kind = field_kind::INT;
tmp.val = val;
return &tmp;
}
+/* A string field, to be passed to %pF in format strings. */
+
+struct string_field_s : base_field_s
+{
+ const char *str;
+};
+
+/* Construct a temporary string_field_s on the caller's stack and
+ return a pointer to the constructed object. We use this because
+ it's not possible to pass a reference via va_args. */
+
+static inline string_field_s *
+string_field (const char *name, const char *str,
+ string_field_s &&tmp = {})
+{
+ tmp.name = name;
+ tmp.kind = field_kind::STRING;
+ tmp.str = str;
+ return &tmp;
+}
+
/* A styled string. */
struct styled_string_s