Commit 43605853 authored by Brad King's avatar Brad King

ENH: Split kwsys_std into kwsys_ios and kwsys_stl in order to avoid std...

ENH: Split kwsys_std into kwsys_ios and kwsys_stl in order to avoid std namespace pollution and support more platforms.
parent ccf5114c
......@@ -109,49 +109,66 @@ ENDIF(CMAKE_ANSI_CFLAGS)
#-----------------------------------------------------------------------------
# Configure the standard library header wrappers based on compiler's
# capabilities and parent project's request.
# capabilities and parent project's request. Enforce 0/1 as only
# possible values for configuration into Configure.hxx.
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/kwsysPlatformCxxTests.cmake)
INCLUDE(${CMAKE_ROOT}/Modules/CheckIncludeFileCXX.cmake)
INCLUDE(${CMAKE_ROOT}/Modules/TestForSTDNamespace.cmake)
CHECK_INCLUDE_FILE_CXX("sstream" CMAKE_HAS_ANSI_STRING_STREAM)
CHECK_INCLUDE_FILE_CXX("iosfwd" CMAKE_ANSI_IOSFWD_HEADER)
# Enforce 0/1 as only possible values. Needed for the means by which
# Configure.hxx is implemented.
IF(CMAKE_NO_STD_NAMESPACE)
SET(CMAKE_NO_STD_NAMESPACE 1)
ELSE(CMAKE_NO_STD_NAMESPACE)
SET(CMAKE_NO_STD_NAMESPACE 0)
ENDIF(CMAKE_NO_STD_NAMESPACE)
IF(CMAKE_ANSI_IOSFWD_HEADER)
SET(CMAKE_NO_ANSI_STREAM_HEADERS 0)
ELSE(CMAKE_ANSI_IOSFWD_HEADER)
SET(CMAKE_NO_ANSI_STREAM_HEADERS 1)
ENDIF(CMAKE_ANSI_IOSFWD_HEADER)
IF(CMAKE_HAS_ANSI_STRING_STREAM)
SET(CMAKE_NO_ANSI_STRING_STREAM 0)
ELSE(CMAKE_HAS_ANSI_STRING_STREAM)
SET(CMAKE_NO_ANSI_STRING_STREAM 1)
ENDIF(CMAKE_HAS_ANSI_STRING_STREAM)
KWSYS_PLATFORM_CXX_TEST(KWSYS_HAVE_STL_STD
"Checking whether STL classes are in std" DIRECT)
# Select ANSI or old streams.
IF(KWSYS_FORCE_OLD_STREAMS)
SET(CMAKE_NO_ANSI_STREAM_HEADERS 1)
SET(CMAKE_NO_ANSI_STRING_STREAM 1)
SET(KWSYS_HAVE_ANSI_STREAMS 0)
ELSE(KWSYS_FORCE_OLD_STREAMS)
CHECK_INCLUDE_FILE_CXX("iosfwd" KWSYS_HAVE_ANSI_STREAMS)
IF(KWSYS_HAVE_ANSI_STREAMS)
SET(KWSYS_HAVE_ANSI_STREAMS 1)
ELSE(KWSYS_HAVE_ANSI_STREAMS)
SET(KWSYS_HAVE_ANSI_STREAMS 0)
ENDIF(KWSYS_HAVE_ANSI_STREAMS)
ENDIF(KWSYS_FORCE_OLD_STREAMS)
# Select string stream.
IF(KWSYS_HAVE_ANSI_STREAMS)
KWSYS_PLATFORM_CXX_TEST(KWSYS_HAVE_ANSI_STREAMS_STD
"Checking whether ANSI streams are in std" DIRECT)
CHECK_INCLUDE_FILE_CXX("sstream" KWSYS_HAVE_ANSI_SSTREAM)
IF(KWSYS_HAVE_ANSI_SSTREAM)
SET(KWSYS_HAVE_ANSI_SSTREAM 1)
ELSE(KWSYS_HAVE_ANSI_SSTREAM)
SET(KWSYS_HAVE_ANSI_SSTREAM 0)
ENDIF(KWSYS_HAVE_ANSI_SSTREAM)
ELSE(KWSYS_HAVE_ANSI_STREAMS)
SET(KWSYS_HAVE_ANSI_STREAMS_STD 0)
SET(KWSYS_HAVE_ANSI_SSTREAM 0)
ENDIF(KWSYS_HAVE_ANSI_STREAMS)
IF(KWSYS_HAVE_ANSI_SSTREAM)
SET(KWSYS_HAVE_OLD_STRSTREA_H 0)
SET(KWSYS_HAVE_OLD_STRSTREAM_H 0)
ELSE(KWSYS_HAVE_ANSI_SSTREAM)
CHECK_INCLUDE_FILE_CXX("strstream.h" KWSYS_HAVE_OLD_STRSTREAM_H)
IF(KWSYS_HAVE_OLD_STRSTREAM_H)
SET(KWSYS_HAVE_OLD_STRSTREAM_H 1)
SET(KWSYS_HAVE_OLD_STRSTREA_H 0)
ELSE(KWSYS_HAVE_OLD_STRSTREAM_H)
SET(KWSYS_HAVE_OLD_STRSTREAM_H 0)
CHECK_INCLUDE_FILE_CXX("strstrea.h" KWSYS_HAVE_OLD_STRSTREA_H)
IF(KWSYS_HAVE_OLD_STRSTREA_H)
SET(KWSYS_HAVE_OLD_STRSTREA_H 1)
ELSE(KWSYS_HAVE_OLD_STRSTREA_H)
SET(KWSYS_HAVE_OLD_STRSTREA_H 0)
ENDIF(KWSYS_HAVE_OLD_STRSTREA_H)
ENDIF(KWSYS_HAVE_OLD_STRSTREAM_H)
ENDIF(KWSYS_HAVE_ANSI_SSTREAM)
IF(KWSYS_NAMESPACE MATCHES "^kwsys$")
SET(KWSYS_NAME_IS_KWSYS 1)
ELSE(KWSYS_NAMESPACE MATCHES "^kwsys$")
SET(KWSYS_NAME_IS_KWSYS 0)
ENDIF(KWSYS_NAMESPACE MATCHES "^kwsys$")
# Set names that are used in creating Configure.hxx for these test
# results.
SET(KWSYS_NO_STD_NAMESPACE ${CMAKE_NO_STD_NAMESPACE})
SET(KWSYS_NO_ANSI_STREAM_HEADERS ${CMAKE_NO_ANSI_STREAM_HEADERS})
SET(KWSYS_NO_ANSI_STRING_STREAM ${CMAKE_NO_ANSI_STRING_STREAM})
# Choose default shared/static build if not specified.
IF(KWSYS_BUILD_SHARED MATCHES "^KWSYS_BUILD_SHARED$")
SET(KWSYS_BUILD_SHARED ${BUILD_SHARED_LIBS})
......@@ -179,14 +196,14 @@ FOREACH(header algorithm deque iterator list map numeric queue set stack string
utility vector)
# Configure the header wrapper.
SET(KWSYS_STL_HEADER "${header}")
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_std.h.in
${KWSYS_HEADER_DIR}/std/${header}
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_stl.h.in
${KWSYS_HEADER_DIR}/stl/${header}
@ONLY IMMEDIATE)
# Create an install target for the header wrapper.
IF(KWSYS_HEADER_INSTALL_DIR)
INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE}/std
FILES ${KWSYS_HEADER_DIR}/std/${header})
INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE}/stl
FILES ${KWSYS_HEADER_DIR}/stl/${header})
ENDIF(KWSYS_HEADER_INSTALL_DIR)
ENDFOREACH(header)
......@@ -195,14 +212,14 @@ ENDFOREACH(header)
# may be included.
FOREACH(header iostream fstream sstream iosfwd)
# Configure the header wrapper.
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_std_${header}.h.in
${KWSYS_HEADER_DIR}/std/${header}
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_ios_${header}.h.in
${KWSYS_HEADER_DIR}/ios/${header}
@ONLY IMMEDIATE)
# Create an install target for the header wrapper.
IF(KWSYS_HEADER_INSTALL_DIR)
INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE}/std
FILES ${KWSYS_HEADER_DIR}/std/${header})
INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE}/ios
FILES ${KWSYS_HEADER_DIR}/ios/${header})
ENDIF(KWSYS_HEADER_INSTALL_DIR)
ENDFOREACH(header)
......
......@@ -14,53 +14,64 @@
#ifndef @KWSYS_NAMESPACE@_Configure_hxx
#define @KWSYS_NAMESPACE@_Configure_hxx
/* Defined if kwsys namespace is "kwsys". */
#if @KWSYS_NAME_IS_KWSYS@
# define @KWSYS_NAMESPACE@_NAME_IS_KWSYS
#endif
/* Whether kwsys namespace is "kwsys". */
#define @KWSYS_NAMESPACE@_NAME_IS_KWSYS @KWSYS_NAME_IS_KWSYS@
/* Defined if no ANSI C++ stream headers are present. */
#if @KWSYS_NO_ANSI_STREAM_HEADERS@
# define @KWSYS_NAMESPACE@_NO_ANSI_STREAM_HEADERS
#endif
/* Whether ANSI C++ stream headers are present. */
#define @KWSYS_NAMESPACE@_HAVE_ANSI_STREAMS @KWSYS_HAVE_ANSI_STREAMS@
/* Defined if no ANSI C++ <sstream> header is present. */
#if @KWSYS_NO_ANSI_STRING_STREAM@
# define @KWSYS_NAMESPACE@_NO_ANSI_STRING_STREAM
#endif
/* Whether ANSI C++ streams are in std namespace. */
#define @KWSYS_NAMESPACE@_HAVE_ANSI_STREAMS_STD @KWSYS_HAVE_ANSI_STREAMS_STD@
/* Defined if no std namespace is present. */
#if @KWSYS_NO_STD_NAMESPACE@
# define @KWSYS_NAMESPACE@_NO_STD_NAMESPACE
#endif
/* Whether ANSI C++ <sstream> header is present and needed. */
#define @KWSYS_NAMESPACE@_HAVE_ANSI_SSTREAM @KWSYS_HAVE_ANSI_SSTREAM@
/* Defined if std namespace is the GCC hack. */
/* Whether old C++ <strstream.h> header is present and needed. */
#define @KWSYS_NAMESPACE@_HAVE_OLD_STRSTREAM_H @KWSYS_HAVE_OLD_STRSTREAM_H@
/* Whether old C++ <strstrea.h> header is present and needed. */
#define @KWSYS_NAMESPACE@_HAVE_OLD_STRSTREA_H @KWSYS_HAVE_OLD_STRSTREA_H@
/* Whether STL is in std namespace. */
#define @KWSYS_NAMESPACE@_HAVE_STL_STD @KWSYS_HAVE_STL_STD@
/* Whether the std namespace is the GCC 2.95 hack. */
#if defined(__GNUC__) && (__GNUC__ < 3)
# define @KWSYS_NAMESPACE@_FAKE_STD_NAMESPACE
# define @KWSYS_NAMESPACE@_FAKE_STD_NAMESPACE 1
#else
# define @KWSYS_NAMESPACE@_FAKE_STD_NAMESPACE 0
#endif
/* Define the std namespace macro. */
#if defined(@KWSYS_NAMESPACE@_NO_STD_NAMESPACE)
# define @KWSYS_NAMESPACE@_std
/* Define the stl namespace macro. */
#if @KWSYS_NAMESPACE@_HAVE_STL_STD
# define @KWSYS_NAMESPACE@_stl std
#else
# define @KWSYS_NAMESPACE@_std std
# define @KWSYS_NAMESPACE@_stl
#endif
/* Define the ios namespace macro. */
#if @KWSYS_NAMESPACE@_HAVE_ANSI_STREAMS_STD
# define @KWSYS_NAMESPACE@_ios_namespace std
#else
# define @KWSYS_NAMESPACE@_ios_namespace
#endif
#if @KWSYS_NAMESPACE@_HAVE_ANSI_SSTREAM
# define @KWSYS_NAMESPACE@_ios @KWSYS_NAMESPACE@_ios_namespace
#else
# define @KWSYS_NAMESPACE@_ios @KWSYS_NAMESPACE@_ios
#endif
/* If building a C++ file in kwsys itself, give the source file
access to the macros without a configured namespace. */
#if defined(KWSYS_NAMESPACE)
# if !defined(@KWSYS_NAMESPACE@_NAME_IS_KWSYS)
# define kwsys_std @KWSYS_NAMESPACE@_std
# endif
# if defined(@KWSYS_NAMESPACE@_NO_STD_NAMESPACE)
# define KWSYS_NO_STD_NAMESPACE
# endif
# if defined(@KWSYS_NAMESPACE@_NO_ANSI_STREAM_HEADERS)
# define KWSYS_NO_ANSI_STREAM_HEADERS
# endif
# if defined(@KWSYS_NAMESPACE@_NO_ANSI_STRING_STREAM)
# define KWSYS_NO_ANSI_STRING_STREAM
# if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
# define kwsys_stl @KWSYS_NAMESPACE@_stl
# define kwsys_ios @KWSYS_NAMESPACE@_ios
# endif
# define KWSYS_HAVE_STL_STD @KWSYS_NAMESPACE@_HAVE_STL_STD
# define KWSYS_HAVE_ANSI_STREAMS @KWSYS_NAMESPACE@_HAVE_ANSI_STREAMS
# define KWSYS_HAVE_ANSI_STREAMS_STD @KWSYS_NAMESPACE@_HAVE_ANSI_STREAMS_STD
# define KWSYS_HAVE_ANSI_SSTREAM @KWSYS_NAMESPACE@_HAVE_ANSI_SSTREAM
#endif
#endif
......@@ -16,8 +16,8 @@
#include KWSYS_HEADER(Configure.hxx)
#include KWSYS_HEADER(std/string)
#include KWSYS_HEADER(std/vector)
#include KWSYS_HEADER(stl/string)
#include KWSYS_HEADER(stl/vector)
namespace KWSYS_NAMESPACE
{
......@@ -27,10 +27,10 @@ class DirectoryInternals
{
public:
// Array of Files
kwsys_std::vector<kwsys_std::string> Files;
kwsys_stl::vector<kwsys_stl::string> Files;
// Path to Open'ed directory
kwsys_std::string Path;
kwsys_stl::string Path;
};
//----------------------------------------------------------------------------
......
......@@ -840,7 +840,7 @@ void regdump ();
static char* regprop ();
#endif
bool RegularExpression::find (kwsys_std::string const& s)
bool RegularExpression::find (kwsys_stl::string const& s)
{
return find(s.c_str());
}
......
......@@ -35,11 +35,11 @@
#include <@KWSYS_NAMESPACE@/Configure.h>
#include <@KWSYS_NAMESPACE@/Configure.hxx>
#include <@KWSYS_NAMESPACE@/std/string>
#include <@KWSYS_NAMESPACE@/stl/string>
/* Define this macro temporarily to keep the code readable. */
#if !defined (KWSYS_NAMESPACE) && !defined(@KWSYS_NAMESPACE@_NAME_IS_KWSYS)
# define kwsys_std @KWSYS_NAMESPACE@_std
#if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
# define kwsys_stl @KWSYS_NAMESPACE@_stl
#endif
namespace @KWSYS_NAMESPACE@
......@@ -221,17 +221,17 @@ public:
* Matches the regular expression to the given std string.
* Returns true if found, and sets start and end indexes accordingly.
*/
bool find (kwsys_std::string const&);
bool find (kwsys_stl::string const&);
/**
* Index to start of first find.
*/
inline kwsys_std::string::size_type start() const;
inline kwsys_stl::string::size_type start() const;
/**
* Index to end of first find.
*/
inline kwsys_std::string::size_type end() const;
inline kwsys_stl::string::size_type end() const;
/**
* Returns true if two regular expressions have the same
......@@ -265,9 +265,9 @@ public:
* Destructor.
*/
// awf added
kwsys_std::string::size_type start(int n) const;
kwsys_std::string::size_type end(int n) const;
kwsys_std::string match(int n) const;
kwsys_stl::string::size_type start(int n) const;
kwsys_stl::string::size_type end(int n) const;
kwsys_stl::string match(int n) const;
enum { NSUBEXP = 10 };
private:
......@@ -316,7 +316,7 @@ inline RegularExpression::~RegularExpression ()
/**
* Set the start position for the regular expression.
*/
inline kwsys_std::string::size_type RegularExpression::start () const
inline kwsys_stl::string::size_type RegularExpression::start () const
{
return(this->startp[0] - searchstring);
}
......@@ -325,7 +325,7 @@ inline kwsys_std::string::size_type RegularExpression::start () const
/**
* Returns the start/end index of the last item found.
*/
inline kwsys_std::string::size_type RegularExpression::end () const
inline kwsys_stl::string::size_type RegularExpression::end () const
{
return(this->endp[0] - searchstring);
}
......@@ -360,7 +360,7 @@ inline void RegularExpression::set_invalid ()
/**
* Return start index of nth submatch. start(0) is the start of the full match.
*/
inline kwsys_std::string::size_type RegularExpression::start(int n) const
inline kwsys_stl::string::size_type RegularExpression::start(int n) const
{
return this->startp[n] - searchstring;
}
......@@ -369,7 +369,7 @@ inline kwsys_std::string::size_type RegularExpression::start(int n) const
/**
* Return end index of nth submatch. end(0) is the end of the full match.
*/
inline kwsys_std::string::size_type RegularExpression::end(int n) const
inline kwsys_stl::string::size_type RegularExpression::end(int n) const
{
return this->endp[n] - searchstring;
}
......@@ -377,16 +377,16 @@ inline kwsys_std::string::size_type RegularExpression::end(int n) const
/**
* Return nth submatch as a string.
*/
inline kwsys_std::string RegularExpression::match(int n) const
inline kwsys_stl::string RegularExpression::match(int n) const
{
return kwsys_std::string(this->startp[n], this->endp[n] - this->startp[n]);
return kwsys_stl::string(this->startp[n], this->endp[n] - this->startp[n]);
}
} // namespace @KWSYS_NAMESPACE@
/* Undefine temporary macro. */
#if !defined (KWSYS_NAMESPACE) && !defined(@KWSYS_NAMESPACE@_NAME_IS_KWSYS)
# undef kwsys_std
#if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
# undef kwsys_stl
#endif
#endif
This diff is collapsed.
This diff is collapsed.
MACRO(KWSYS_PLATFORM_CXX_TEST var description invert)
IF("${var}_COMPILED" MATCHES "^${var}_COMPILED$")
MESSAGE(STATUS "${description}")
TRY_COMPILE(${var}_COMPILED
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/kwsysPlatformCxxTests.cxx
COMPILE_DEFINITIONS -DTEST_${var}
OUTPUT_VARIABLE OUTPUT)
IF(${var}_COMPILED)
FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/CMakeOutput.log
"${description} compiled with the following output:\n${OUTPUT}\n\n")
ELSE(${var}_COMPILED)
FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/CMakeError.log
"${description} failed to compile with the following output:\n${OUTPUT}\n\n")
ENDIF(${var}_COMPILED)
IF(${invert} MATCHES INVERT)
IF(${var}_COMPILED)
MESSAGE(STATUS "${description} - no")
ELSE(${var}_COMPILED)
MESSAGE(STATUS "${description} - yes")
ENDIF(${var}_COMPILED)
ELSE(${invert} MATCHES INVERT)
IF(${var}_COMPILED)
MESSAGE(STATUS "${description} - yes")
ELSE(${var}_COMPILED)
MESSAGE(STATUS "${description} - no")
ENDIF(${var}_COMPILED)
ENDIF(${invert} MATCHES INVERT)
ENDIF("${var}_COMPILED" MATCHES "^${var}_COMPILED$")
IF(${invert} MATCHES INVERT)
IF(${var}_COMPILED)
SET(${var} 0)
ELSE(${var}_COMPILED)
SET(${var} 1)
ENDIF(${var}_COMPILED)
ELSE(${invert} MATCHES INVERT)
IF(${var}_COMPILED)
SET(${var} 1)
ELSE(${var}_COMPILED)
SET(${var} 0)
ENDIF(${var}_COMPILED)
ENDIF(${invert} MATCHES INVERT)
ENDMACRO(KWSYS_PLATFORM_CXX_TEST)
#ifdef TEST_KWSYS_HAVE_STL_STD
#include <list>
void f(std::list<int>*) {}
int main() { return 0; }
#endif
#ifdef TEST_KWSYS_HAVE_ANSI_STREAMS_STD
#include <iosfwd>
void f(std::ostream*) {}
int main() { return 0; }
#endif
/*=========================================================================
Program: KWSys - Kitware System Library
Module: kwsys_std_fstream.h.in
Module: kwsys_ios_fstream.h.in
Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
......@@ -11,8 +11,8 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef @KWSYS_NAMESPACE@_std_fstream
#define @KWSYS_NAMESPACE@_std_fstream
#ifndef @KWSYS_NAMESPACE@_ios_fstream
#define @KWSYS_NAMESPACE@_ios_fstream
#include <@KWSYS_NAMESPACE@/Configure.hxx>
......@@ -21,22 +21,23 @@
#pragma warning (disable: 4702)
#endif
#if !defined(@KWSYS_NAMESPACE@_NO_ANSI_STREAM_HEADERS)
#if @KWSYS_NAMESPACE@_HAVE_ANSI_STREAMS
# include <fstream>
#else
# include <fstream.h>
# if !defined(@KWSYS_NAMESPACE@_NO_STD_NAMESPACE) && !defined(@KWSYS_NAMESPACE@_FAKE_STD_NAMESPACE)
namespace std
#endif
#if !@KWSYS_NAMESPACE@_HAVE_ANSI_SSTREAM
namespace @KWSYS_NAMESPACE@_ios
{
using ::ostream;
using ::istream;
using ::ofstream;
using ::ifstream;
using ::ios;
using ::endl;
using ::flush;
using @KWSYS_NAMESPACE@_ios_namespace::ostream;
using @KWSYS_NAMESPACE@_ios_namespace::istream;
using @KWSYS_NAMESPACE@_ios_namespace::ofstream;
using @KWSYS_NAMESPACE@_ios_namespace::ifstream;
using @KWSYS_NAMESPACE@_ios_namespace::ios;
using @KWSYS_NAMESPACE@_ios_namespace::endl;
using @KWSYS_NAMESPACE@_ios_namespace::flush;
}
# endif
#endif
#ifdef _MSC_VER
......
/*=========================================================================
Program: KWSys - Kitware System Library
Module: kwsys_std_iosfwd.h.in
Module: kwsys_ios_iosfwd.h.in
Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
......@@ -11,8 +11,8 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef @KWSYS_NAMESPACE@_std_iosfwd
#define @KWSYS_NAMESPACE@_std_iosfwd
#ifndef @KWSYS_NAMESPACE@_ios_iosfwd
#define @KWSYS_NAMESPACE@_ios_iosfwd
#include <@KWSYS_NAMESPACE@/Configure.hxx>
......@@ -21,7 +21,7 @@
#pragma warning (disable: 4702)
#endif
#if !defined(@KWSYS_NAMESPACE@_NO_ANSI_STREAM_HEADERS)
#if @KWSYS_NAMESPACE@_HAVE_ANSI_STREAMS
# include <iosfwd>
#else
class fstream;
......@@ -30,17 +30,18 @@ class ios;
class istream;
class ofstream;
class ostream;
# if !defined(@KWSYS_NAMESPACE@_NO_STD_NAMESPACE) && !defined(@KWSYS_NAMESPACE@_FAKE_STD_NAMESPACE)
namespace std
#endif
#if !@KWSYS_NAMESPACE@_HAVE_ANSI_SSTREAM
namespace @KWSYS_NAMESPACE@_ios
{
using ::fstream;
using ::ifstream;
using ::ios;
using ::istream;
using ::ofstream;
using ::ostream;
using @KWSYS_NAMESPACE@_ios_namespace::fstream;
using @KWSYS_NAMESPACE@_ios_namespace::ifstream;
using @KWSYS_NAMESPACE@_ios_namespace::ios;
using @KWSYS_NAMESPACE@_ios_namespace::istream;
using @KWSYS_NAMESPACE@_ios_namespace::ofstream;
using @KWSYS_NAMESPACE@_ios_namespace::ostream;
}
# endif
#endif
#ifdef _MSC_VER
......
/*=========================================================================
Program: KWSys - Kitware System Library
Module: kwsys_std_iostream.h.in
Module: kwsys_ios_iostream.h.in
Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
......@@ -11,8 +11,8 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef @KWSYS_NAMESPACE@_std_iostream
#define @KWSYS_NAMESPACE@_std_iostream
#ifndef @KWSYS_NAMESPACE@_ios_iostream
#define @KWSYS_NAMESPACE@_ios_iostream
#include <@KWSYS_NAMESPACE@/Configure.hxx>
......@@ -21,23 +21,24 @@
#pragma warning (disable: 4702)
#endif
#if !defined(@KWSYS_NAMESPACE@_NO_ANSI_STREAM_HEADERS)
#if @KWSYS_NAMESPACE@_HAVE_ANSI_STREAMS
# include <iostream>
#else
# include <iostream.h>
# if !defined(@KWSYS_NAMESPACE@_NO_STD_NAMESPACE) && !defined(@KWSYS_NAMESPACE@_FAKE_STD_NAMESPACE)
namespace std
#endif
#if !@KWSYS_NAMESPACE@_HAVE_ANSI_SSTREAM
namespace @KWSYS_NAMESPACE@_ios
{
using ::ostream;
using ::istream;
using ::ios;
using ::cout;
using ::cerr;
using ::cin;
using ::endl;
using ::flush;
using @KWSYS_NAMESPACE@_ios_namespace::ostream;
using @KWSYS_NAMESPACE@_ios_namespace::istream;
using @KWSYS_NAMESPACE@_ios_namespace::ios;
using @KWSYS_NAMESPACE@_ios_namespace::cout;
using @KWSYS_NAMESPACE@_ios_namespace::cerr;
using @KWSYS_NAMESPACE@_ios_namespace::cin;
using @KWSYS_NAMESPACE@_ios_namespace::endl;
using @KWSYS_NAMESPACE@_ios_namespace::flush;
}
# endif
#endif
#ifdef _MSC_VER
......
/*=========================================================================
Program: KWSys - Kitware System Library
Module: kwsys_std_sstream.h.in
Module: kwsys_ios_sstream.h.in
Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
......@@ -11,17 +11,17 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef @KWSYS_NAMESPACE@_std_sstream
#define @KWSYS_NAMESPACE@_std_sstream
#ifndef @KWSYS_NAMESPACE@_ios_sstream
#define @KWSYS_NAMESPACE@_ios_sstream
#include <@KWSYS_NAMESPACE@/Configure.hxx>
/* Define this macro temporarily to keep the code readable. */
#if !defined (KWSYS_NAMESPACE) && !defined(@KWSYS_NAMESPACE@_NAME_IS_KWSYS)
# define kwsys_std @KWSYS_NAMESPACE@_std
#if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
# define kwsys_stl @KWSYS_NAMESPACE@_stl
#endif
#if !defined(@KWSYS_NAMESPACE@_NO_ANSI_STRING_STREAM)
#if @KWSYS_NAMESPACE@_HAVE_ANSI_SSTREAM
# ifdef _MSC_VER
# pragma warning (push, 1)
# pragma warning (disable: 4702)
......@@ -35,23 +35,12 @@
# pragma warning (push, 1)
# pragma warning (disable: 4702)
# endif
# if !defined(@KWSYS_NAMESPACE@_NO_ANSI_STREAM_HEADERS)
# if @KWSYS_NAMESPACE@_HAVE_ANSI_STREAMS
# include <strstream>
# else
# elif @KWSYS_NAMESPACE@_HAVE_OLD_STRSTREAM_H
# include <strstream.h>
# if !defined(@KWSYS_NAMESPACE@_NO_STD_NAMESPACE) && !defined(@KWSYS_NAMESPACE@_FAKE_STD_NAMESPACE)
namespace std
{
using ::ostream;
using ::istream;
using ::istrstream;
using ::ostrstream;
using ::ios;
using ::endl;
using ::ends;
using ::flush;
}
# endif
# elif @KWSYS_NAMESPACE@_HAVE_OLD_STRSTREA_H
# include <strstrea.h>
# endif
# ifdef _MSC_VER
# pragma warning(pop)
......@@ -60,51 +49,57 @@ namespace std
// Only have old std::strstream classes. Wrap them to look like new
// ostringstream and istringstream classes.
# include <@KWSYS_NAMESPACE@/std/string>
# include <@KWSYS_NAMESPACE@/stl/string>
# if !defined(@KWSYS_NAMESPACE@_NO_STD_NAMESPACE)
namespace std
namespace @KWSYS_NAMESPACE@_ios
{
# endif
using @KWSYS_NAMESPACE@_ios_namespace::ostream;
using @KWSYS_NAMESPACE@_ios_namespace::istream;
using @KWSYS_NAMESPACE@_ios_namespace::istrstream;
using @KWSYS_NAMESPACE@_ios_namespace::ostrstream;
using @KWSYS_NAMESPACE@_ios_namespace::ios;
using @KWSYS_NAMESPACE@_ios_namespace::endl;
using @KWSYS_NAMESPACE@_ios_namespace::ends;
using @KWSYS_NAMESPACE@_ios_namespace::flush;
class ostringstream_cleanup
{
public:
ostringstream_cleanup(kwsys_std::ostrstream& ostr): m_OStrStream(ostr) {}
ostringstream_cleanup(ostrstream& ostr): m_OStrStream(ostr) {}
~ostringstream_cleanup() { m_OStrStream.rdbuf()->freeze(0); }
static void IgnoreUnusedVariable(const ostringstream_cleanup&) {}
protected:
kwsys_std::ostrstream& m_OStrStream;
ostrstream& m_OStrStream;
};
class ostringstream: public kwsys_std::ostrstream
class ostringstream: public ostrstream
{
public:
typedef kwsys_std::ostrstream Superclass;
typedef ostrstream Superclass;
ostringstream() {}
kwsys_std::string str()
kwsys_stl::string str()
{
ostringstream_cleanup cleanup(*this);
ostringstream_cleanup::IgnoreUnusedVariable(cleanup);
int pcount = this->pcount();
const char* ptr = this->Superclass::str();
return kwsys_std::string(ptr?ptr:"", pcount);
return kwsys_stl::string(ptr?ptr:"", pcount);
}
private:
ostringstream(const ostringstream&);
void operator=(const ostringstream&);
};
class istringstream: private kwsys_std::string, public kwsys_std::istrstream
class istringstream: private kwsys_stl::string, public istrstream
{
public:
typedef kwsys_std::string StdString;
typedef kwsys_std::istrstream IStrStream;
typedef kwsys_stl::string StdString;
typedef istrstream IStrStream;
istringstream(): StdString(), IStrStream(StdString::c_str()) {}
istringstream(const kwsys_std::string& s):
istringstream(const kwsys_stl::string& s):
StdString(s), IStrStream(StdString::c_str()) {}
kwsys_std::string str() const { return *this; }
void str(const kwsys_std::string& s)
kwsys_stl::string str() const { return *this; }
void str(const kwsys_stl::string& s)
{
// Very dangerous. If this throws, the object is hosed. When the
// destructor is later called, the program is hosed too.
......@@ -116,15 +111,13 @@ private:
void operator=(const istringstream&);
};
# if !defined(@KWSYS_NAMESPACE@_NO_STD_NAMESPACE)
}
# endif
} // namespace @KWSYS_NAMESPACE@_ios
#endif
/* Undefine temporary macro. */
#if !defined (KWSYS_NAMESPACE) && !defined(@KWSYS_NAMESPACE@_NAME_IS_KWSYS)
# undef kwsys_std
#if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
# undef kwsys_stl
#endif
#endif
/*=========================================================================
Program: KWSys - Kitware System Library
Module: kwsys_std.h.in
Module: kwsys_stl.h.in
Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
......@@ -11,8 +11,8 @@
PURPOSE. See the above copyright notices for more information.
=================================================================