mi-console.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* MI Command Set - MI Console.
  2. Copyright (C) 2000-2022 Free Software Foundation, Inc.
  3. Contributed by Cygnus Solutions (a Red Hat company).
  4. This file is part of GDB.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  15. #ifndef MI_MI_CONSOLE_H
  16. #define MI_MI_CONSOLE_H
  17. /* An output stream for MI. Wraps a given output stream with a prefix
  18. and handles quoting. This stream is locally buffered. */
  19. class mi_console_file : public ui_file
  20. {
  21. public:
  22. /* Create a console that wraps the given output stream RAW with the
  23. string PREFIX and quoting it with QUOTE. */
  24. mi_console_file (ui_file *raw, const char *prefix, char quote);
  25. /* MI-specific API. */
  26. void set_raw (ui_file *raw);
  27. /* ui_file-specific methods. */
  28. void flush () override;
  29. void write (const char *buf, long length_buf) override;
  30. void write_async_safe (const char *buf, long length_buf) override;
  31. private:
  32. /* The wrapped raw output stream. */
  33. ui_file *m_raw;
  34. /* The local buffer. */
  35. string_file m_buffer;
  36. /* The prefix. */
  37. const char *m_prefix;
  38. /* The quote char. */
  39. char m_quote;
  40. };
  41. #endif /* MI_MI_CONSOLE_H */