resolve cyclic dependency with zstd
[platform/upstream/cmake.git] / Source / cmXMLSafe.h
1 /* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2    file Copyright.txt or https://cmake.org/licensing for details.  */
3 #pragma once
4
5 #include "cmConfigure.h" // IWYU pragma: keep
6
7 #include <iosfwd>
8 #include <string>
9
10 /** \class cmXMLSafe
11  * \brief Write strings to XML with proper escapes
12  */
13 class cmXMLSafe
14 {
15 public:
16   /** Construct with the data to be written.  This assumes the data
17       will exist for the duration of this object's life.  */
18   cmXMLSafe(const char* s);
19   cmXMLSafe(std::string const& s);
20
21   /** Specify whether to escape quotes too.  This is needed when
22       writing the content of an attribute value.  By default quotes
23       are escaped.  */
24   cmXMLSafe& Quotes(bool b = true);
25
26   /** Get the escaped data as a string.  */
27   std::string str() const;
28
29 private:
30   char const* Data;
31   unsigned long Size;
32   bool DoQuotes;
33   friend std::ostream& operator<<(std::ostream&, cmXMLSafe const&);
34 };