2016-10-30 18:24:19 +01:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2009-10-04 10:30:41 +03:00
|
|
|
#ifndef cmXMLSafe_h
|
|
|
|
#define cmXMLSafe_h
|
|
|
|
|
2017-07-20 19:35:53 +02:00
|
|
|
#include "cmConfigure.h" // IWYU pragma: keep
|
2016-07-09 11:21:54 +02:00
|
|
|
|
2015-11-17 17:22:37 +01:00
|
|
|
#include <iosfwd>
|
2016-07-09 11:21:54 +02:00
|
|
|
#include <string>
|
2009-10-04 10:30:41 +03:00
|
|
|
|
|
|
|
/** \class cmXMLSafe
|
|
|
|
* \brief Write strings to XML with proper escapes
|
|
|
|
*/
|
|
|
|
class cmXMLSafe
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** Construct with the data to be written. This assumes the data
|
|
|
|
will exist for the duration of this object's life. */
|
|
|
|
cmXMLSafe(const char* s);
|
2015-08-17 11:37:30 +02:00
|
|
|
cmXMLSafe(std::string const& s);
|
2009-10-04 10:30:41 +03:00
|
|
|
|
|
|
|
/** Specify whether to escape quotes too. This is needed when
|
|
|
|
writing the content of an attribute value. By default quotes
|
|
|
|
are escaped. */
|
|
|
|
cmXMLSafe& Quotes(bool b = true);
|
|
|
|
|
|
|
|
/** Get the escaped data as a string. */
|
2015-08-17 11:37:30 +02:00
|
|
|
std::string str();
|
2016-07-09 11:21:54 +02:00
|
|
|
|
2009-10-04 10:30:41 +03:00
|
|
|
private:
|
|
|
|
char const* Data;
|
|
|
|
unsigned long Size;
|
|
|
|
bool DoQuotes;
|
2015-11-17 17:22:37 +01:00
|
|
|
friend std::ostream& operator<<(std::ostream&, cmXMLSafe const&);
|
2009-10-04 10:30:41 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|