cmXMLSafe.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef cmXMLSafe_h
  14. #define cmXMLSafe_h
  15. #include <cmsys/stl/string>
  16. #include <cmsys/ios/iosfwd>
  17. /** \class cmXMLSafe
  18. * \brief Write strings to XML with proper escapes
  19. */
  20. class cmXMLSafe
  21. {
  22. public:
  23. /** Construct with the data to be written. This assumes the data
  24. will exist for the duration of this object's life. */
  25. cmXMLSafe(const char* s);
  26. cmXMLSafe(cmsys_stl::string const& str);
  27. /** Specify whether to escape quotes too. This is needed when
  28. writing the content of an attribute value. By default quotes
  29. are escaped. */
  30. cmXMLSafe& Quotes(bool b = true);
  31. /** Get the escaped data as a string. */
  32. cmsys_stl::string str();
  33. private:
  34. char const* Data;
  35. unsigned long Size;
  36. bool DoQuotes;
  37. friend cmsys_ios::ostream& operator<<(cmsys_ios::ostream&,
  38. cmXMLSafe const&);
  39. };
  40. #endif