2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2009-02-06 00:31:37 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2009-02-06 00:31:37 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2009-02-06 00:31:37 +03:00
|
|
|
#ifndef cmXMLSafe_h
|
|
|
|
#define cmXMLSafe_h
|
|
|
|
|
2015-08-20 23:06:40 +03:00
|
|
|
#include <cmsys/Configure.hxx>
|
2016-04-29 16:40:20 +03:00
|
|
|
|
2015-08-20 23:02:20 +03:00
|
|
|
#include <iosfwd>
|
2016-04-29 17:53:13 +03:00
|
|
|
#include <string>
|
2009-02-06 00:31:37 +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-01-30 01:19:40 +03:00
|
|
|
cmXMLSafe(std::string const& s);
|
2009-02-06 00:31:37 +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-01-30 01:19:40 +03:00
|
|
|
std::string str();
|
2009-02-06 00:31:37 +03:00
|
|
|
private:
|
|
|
|
char const* Data;
|
|
|
|
unsigned long Size;
|
|
|
|
bool DoQuotes;
|
2015-08-20 23:02:20 +03:00
|
|
|
friend std::ostream& operator<<(std::ostream&, cmXMLSafe const&);
|
2009-02-06 00:31:37 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|