/* Copyright (C) 2024 Free Software Foundation, Inc. Contributed by David Malcolm This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see . */ #ifndef GCC_PRETTY_PRINT_MARKUP_H #define GCC_PRETTY_PRINT_MARKUP_H #include "diagnostic-color.h" class pp_token_list; namespace pp_markup { class context { public: context (pretty_printer &pp, bool "ed, pp_token_list *formatted_token_list) : m_pp (pp), m_buf (*pp_buffer (&pp)), m_quoted (quoted), m_formatted_token_list (formatted_token_list) { } void begin_quote (); void end_quote (); void begin_highlight_color (const char *color_name); void end_highlight_color (); void push_back_any_text (); pretty_printer &m_pp; output_buffer &m_buf; bool &m_quoted; pp_token_list *m_formatted_token_list; }; /* Abstract base class for use in pp_format for handling "%e". This can add arbitrary content to the buffer being constructed, and isolates the non-typesafe part of the formatting call in one place. */ class element { public: virtual ~element () {} virtual void add_to_phase_2 (context &ctxt) = 0; protected: element () {} private: DISABLE_COPY_AND_ASSIGN (element); }; /* Concrete subclass: handle "%e" by printing a comma-separated list of quoted strings. */ class comma_separated_quoted_strings : public element { public: comma_separated_quoted_strings (const auto_vec &strings) : m_strings (strings) { } void add_to_phase_2 (context &ctxt) final override; private: const auto_vec &m_strings; }; } // namespace pp_markup #endif /* GCC_PRETTY_PRINT_MARKUP_H */