xref: /netbsd-src/external/gpl3/gdb/dist/gdbsupport/xml-utils.h (revision 5ba1f45f2a09259cc846f20c7c5501604d633c90)
18dffb485Schristos /* Shared helper routines for manipulating XML.
28dffb485Schristos 
3*5ba1f45fSchristos    Copyright (C) 2006-2024 Free Software Foundation, Inc.
48dffb485Schristos 
58dffb485Schristos    This file is part of GDB.
68dffb485Schristos 
78dffb485Schristos    This program is free software; you can redistribute it and/or modify
88dffb485Schristos    it under the terms of the GNU General Public License as published by
98dffb485Schristos    the Free Software Foundation; either version 3 of the License, or
108dffb485Schristos    (at your option) any later version.
118dffb485Schristos 
128dffb485Schristos    This program is distributed in the hope that it will be useful,
138dffb485Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
148dffb485Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
158dffb485Schristos    GNU General Public License for more details.
168dffb485Schristos 
178dffb485Schristos    You should have received a copy of the GNU General Public License
188dffb485Schristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
198dffb485Schristos 
208dffb485Schristos #ifndef COMMON_XML_UTILS_H
218dffb485Schristos #define COMMON_XML_UTILS_H
228dffb485Schristos 
238dffb485Schristos /* Return a string with special characters from TEXT replaced by entity
248dffb485Schristos    references.  */
258dffb485Schristos 
268dffb485Schristos extern std::string xml_escape_text (const char *text);
278dffb485Schristos 
288dffb485Schristos /* Append TEXT to RESULT, with special characters replaced by entity
298dffb485Schristos    references.  */
308dffb485Schristos 
314b169a6bSchristos extern void xml_escape_text_append (std::string &result, const char *text);
324b169a6bSchristos 
334b169a6bSchristos /* Simple printf to string function.  Current implemented formatters:
344b169a6bSchristos    %s - append an xml escaped text to BUFFER.
354b169a6bSchristos    %d - append an signed integer to BUFFER.
364b169a6bSchristos    %u - append an unsigned integer to BUFFER.
374b169a6bSchristos    %x - append an unsigned integer formatted in hexadecimal to BUFFER.
384b169a6bSchristos    %o - append an unsigned integer formatted in octal to BUFFER.  */
394b169a6bSchristos 
404b169a6bSchristos void string_xml_appendf (std::string &buffer, const char *format, ...)
414b169a6bSchristos   ATTRIBUTE_PRINTF (2, 3);
428dffb485Schristos 
438dffb485Schristos #endif /* COMMON_XML_UTILS_H */
44