https://github.com/Kitware/CMake
Revision e0fbd95f06ca4d1b0274da5b9a1e3c58c4f93ca2 authored by Kitware Robot on 29 May 2016, 04:01:05 UTC, committed by Kitware Robot on 29 May 2016, 04:01:05 UTC
1 parent 797a332
Raw File
Tip revision: e0fbd95f06ca4d1b0274da5b9a1e3c58c4f93ca2 authored by Kitware Robot on 29 May 2016, 04:01:05 UTC
CMake Nightly Date Stamp
Tip revision: e0fbd95
cmXMLSafe.h
/*============================================================================
  CMake - Cross Platform Makefile Generator
  Copyright 2000-2009 Kitware, Inc., Insight Software Consortium

  Distributed under the OSI-approved BSD License (the "License");
  see accompanying file Copyright.txt for details.

  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.
============================================================================*/
#ifndef cmXMLSafe_h
#define cmXMLSafe_h

#include <cmsys/Configure.hxx>

#include <iosfwd>
#include <string>

/** \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);
  cmXMLSafe(std::string const& s);

  /** 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.  */
  std::string str();

private:
  char const* Data;
  unsigned long Size;
  bool DoQuotes;
  friend std::ostream& operator<<(std::ostream&, cmXMLSafe const&);
};

#endif
back to top