Eliminate make_cleanup_ui_file_delete / make ui_file a class hierarchy
[deliverable/binutils-gdb.git] / gdb / mi / mi-console.h
index 64355a710d7f86b1b8673c388e9d4093ff3c6912..289013f9554f6c9d3c2171303ef9ef1df3bc3bb5 100644 (file)
 #ifndef MI_CONSOLE_H
 #define MI_CONSOLE_H
 
-extern struct ui_file *mi_console_file_new (struct ui_file *raw,
-                                           const char *prefix,
-                                           char quote);
+/* An output stream for MI.  Wraps a given output stream with a prefix
+   and handles quoting.  This stream is locally buffered.  */
 
-extern void mi_console_set_raw (struct ui_file *console,
-                               struct ui_file *raw);
+class mi_console_file : public ui_file
+{
+public:
+  /* Create a console that wraps the given output stream RAW with the
+     string PREFIX and quoting it with QUOTE.  */
+  mi_console_file (ui_file *raw, const char *prefix, char quote);
+
+  /* MI-specific API.  */
+  void set_raw (ui_file *raw);
+
+  /* ui_file-specific methods.  */
+
+  void flush () override;
+
+  void write (const char *buf, long length_buf) override;
+
+private:
+  /* The wrapped raw output stream.  */
+  ui_file *m_raw;
+
+  /* The local buffer.  */
+  string_file m_buffer;
+
+  /* The prefix.  */
+  const char *m_prefix;
+
+  /* The quote char.  */
+  char m_quote;
+};
 
 #endif
This page took 0.031369 seconds and 4 git commands to generate.