Rename fprintf_symbol_filtered
[binutils-gdb.git] / gdb / ui-out.h
index 5c96a7825be4aaeca10a9b7ae976742127010fa3..cd36211be1f97c20bc08267af51a30d12d1bf3b3 100644 (file)
@@ -1,6 +1,6 @@
 /* Output generating routines for GDB.
 
-   Copyright (C) 1999-2019 Free Software Foundation, Inc.
+   Copyright (C) 1999-2022 Free Software Foundation, Inc.
 
    Contributed by Cygnus Solutions.
    Written by Fernando Nasser for Cygnus.
@@ -77,8 +77,11 @@ enum ui_out_type
 /* The possible kinds of fields.  */
 enum class field_kind
   {
-    SIGNED,
-    STRING,
+    /* "FIELD_STRING" needs a funny name to avoid clashes with tokens
+       named "STRING".  See PR build/25250.  FIELD_SIGNED is given a
+       similar name for consistency.  */
+    FIELD_SIGNED,
+    FIELD_STRING,
   };
 
 /* The base type of all fields that can be emitted using %pF.  */
@@ -105,7 +108,7 @@ signed_field (const char *name, LONGEST val,
              signed_field_s &&tmp = {})
 {
   tmp.name = name;
-  tmp.kind = field_kind::SIGNED;
+  tmp.kind = field_kind::FIELD_SIGNED;
   tmp.val = val;
   return &tmp;
 }
@@ -126,7 +129,7 @@ string_field (const char *name, const char *str,
              string_field_s &&tmp = {})
 {
   tmp.name = name;
-  tmp.kind = field_kind::STRING;
+  tmp.kind = field_kind::FIELD_STRING;
   tmp.str = str;
   return &tmp;
 }
@@ -188,7 +191,11 @@ class ui_out
                        CORE_ADDR address);
   void field_string (const char *fldname, const char *string,
                     const ui_file_style &style = ui_file_style ());
-  void field_string (const char *fldname, const std::string &string);
+  void field_string (const char *fldname, const std::string &string,
+                    const ui_file_style &style = ui_file_style ())
+  {
+    field_string (fldname, string.c_str (), style);
+  }
   void field_stream (const char *fldname, string_file &stream,
                     const ui_file_style &style = ui_file_style ());
   void field_skip (const char *fldname);
@@ -200,6 +207,7 @@ class ui_out
 
   void spaces (int numspaces);
   void text (const char *string);
+  void text (const std::string &string) { text (string.c_str ()); }
 
   /* Output a printf-style formatted string.  In addition to the usual
      printf format specs, this supports a few GDB-specific
@@ -213,10 +221,10 @@ class ui_out
        uiout->field_signed(), uiout_>field_string() etc. calls when
        the formatted message is translatable.  E.g.:
 
-         uiout->message (_("\nWatchpoint %pF deleted because the program has "
-                         "left the block in\n"
-                         "which its expression is valid.\n"),
-                         signed_field ("wpnum", b->number));
+        uiout->message (_("\nWatchpoint %pF deleted because the program has "
+                        "left the block in\n"
+                        "which its expression is valid.\n"),
+                        signed_field ("wpnum", b->number));
 
      - '%p[' - output the following text in a specified style.
        '%p]' - output the following text in the default style.
@@ -249,7 +257,7 @@ class ui_out
   void vmessage (const ui_file_style &in_style,
                 const char *format, va_list args) ATTRIBUTE_PRINTF (3, 0);
 
-  void wrap_hint (const char *identstring);
+  void wrap_hint (int indent);
 
   void flush ();
 
@@ -272,6 +280,39 @@ class ui_out
      escapes.  */
   virtual bool can_emit_style_escape () const = 0;
 
+  /* An object that starts and finishes a progress meter.  */
+  class progress_meter
+  {
+  public:
+    /* SHOULD_PRINT indicates whether something should be printed for a tty.  */
+    progress_meter (struct ui_out *uiout, const std::string &name,
+                   bool should_print)
+      : m_uiout (uiout)
+    {
+      m_uiout->do_progress_start (name, should_print);
+    }
+
+    ~progress_meter ()
+    {
+      m_uiout->do_progress_notify (1.0);
+      m_uiout->do_progress_end ();
+    }
+
+    progress_meter (const progress_meter &) = delete;
+    progress_meter &operator= (const progress_meter &) = delete;
+
+    /* Emit some progress for this progress meter.  HOWMUCH may range
+       from 0.0 to 1.0.  */
+    void progress (double howmuch)
+    {
+      m_uiout->do_progress_notify (howmuch);
+    }
+
+  private:
+
+    struct ui_out *m_uiout;
+  };
+
  protected:
 
   virtual void do_table_begin (int nbrofcols, int nr_rows, const char *tblid)
@@ -302,10 +343,14 @@ class ui_out
   virtual void do_message (const ui_file_style &style,
                           const char *format, va_list args)
     ATTRIBUTE_PRINTF (3,0) = 0;
-  virtual void do_wrap_hint (const char *identstring) = 0;
+  virtual void do_wrap_hint (int indent) = 0;
   virtual void do_flush () = 0;
   virtual void do_redirect (struct ui_file *outstream) = 0;
 
+  virtual void do_progress_start (const std::string &, bool) = 0;
+  virtual void do_progress_notify (double) = 0;
+  virtual void do_progress_end () = 0;
+
   /* Set as not MI-like by default.  It is overridden in subclasses if
      necessary.  */