You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.3KB

  1. /* Shared escaped string class.
  2. Copyright (C) 1999-2020 Free Software Foundation, Inc.
  3. This file is part of GCC.
  4. GCC is free software; you can redistribute it and/or modify it under
  5. the terms of the GNU General Public License as published by the Free
  6. Software Foundation; either version 3, or (at your option) any later
  7. version.
  8. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  9. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  11. for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GCC; see the file COPYING3. If not see
  14. <http://www.gnu.org/licenses/>. */
  15. #ifndef GCC_ESCAPED_STRING_H
  16. #define GCC_ESCAPED_STRING_H
  17. #include <cstdlib>
  18. /* A class to handle converting a string that might contain
  19. control characters, (eg newline, form-feed, etc), into one
  20. in which contains escape sequences instead. */
  21. class escaped_string
  22. {
  23. public:
  24. escaped_string () { m_owned = false; m_str = NULL; };
  25. ~escaped_string () { if (m_owned) free (m_str); }
  26. operator const char *() const { return m_str; }
  27. void escape (const char *);
  28. private:
  29. escaped_string(const escaped_string&) {}
  30. escaped_string& operator=(const escaped_string&) { return *this; }
  31. char *m_str;
  32. bool m_owned;
  33. };
  34. #endif /* ! GCC_ESCAPED_STRING_H */