diff options
author | Brad King <brad.king@kitware.com> | 2005-03-29 15:10:25 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2005-03-29 15:10:25 (GMT) |
commit | 65f1e3e1d8a69a9af7744034123fab36c356db1e (patch) | |
tree | 874504a014ab095148695ebafacc5462c2a697d6 /Source | |
parent | 22f6d68be3e6630b21bb17de63273965de44ee45 (diff) | |
download | CMake-65f1e3e1d8a69a9af7744034123fab36c356db1e.zip CMake-65f1e3e1d8a69a9af7744034123fab36c356db1e.tar.gz CMake-65f1e3e1d8a69a9af7744034123fab36c356db1e.tar.bz2 |
ENH: Added operator!= for stl string and char* when the system does not provide one.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/kwsys/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Source/kwsys/Configure.hxx.in | 24 | ||||
-rw-r--r-- | Source/kwsys/kwsysPlatformCxxTests.cxx | 11 | ||||
-rw-r--r-- | Source/kwsys/kwsys_stl_string.hxx.in | 19 |
4 files changed, 47 insertions, 10 deletions
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index c2f4b66..e355028 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -175,6 +175,9 @@ ELSE(KWSYS_IOS_USE_SSTREAM) ENDIF(KWSYS_IOS_USE_STRSTREAM_H) ENDIF(KWSYS_IOS_USE_SSTREAM) +KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_STRING_HAVE_NEQ_CHAR + "Checking whether stl string has operator!= for char*" DIRECT) + IF(KWSYS_IOS_USE_ANSI) # ANSI streams always have string operators. SET(KWSYS_STL_STRING_HAVE_OSTREAM 1) diff --git a/Source/kwsys/Configure.hxx.in b/Source/kwsys/Configure.hxx.in index a55f991..c28d8c9 100644 --- a/Source/kwsys/Configure.hxx.in +++ b/Source/kwsys/Configure.hxx.in @@ -41,6 +41,9 @@ /* Whether the STL string has operator>> for istream. */ #define @KWSYS_NAMESPACE@_STL_STRING_HAVE_ISTREAM @KWSYS_STL_STRING_HAVE_ISTREAM@ +/* Whether the STL string has operator!= for char*. */ +#define @KWSYS_NAMESPACE@_STL_STRING_HAVE_NEQ_CHAR @KWSYS_STL_STRING_HAVE_NEQ_CHAR@ + /* Define the stl namespace macro. */ #if @KWSYS_NAMESPACE@_STL_HAVE_STD # define @KWSYS_NAMESPACE@_stl std @@ -70,16 +73,17 @@ # define kwsys_stl @KWSYS_NAMESPACE@_stl # define kwsys_ios @KWSYS_NAMESPACE@_ios # endif -# define KWSYS_NAME_IS_KWSYS @KWSYS_NAMESPACE@_NAME_IS_KWSYS -# define KWSYS_STL_HAVE_STD @KWSYS_NAMESPACE@_STL_HAVE_STD -# define KWSYS_IOS_HAVE_STD @KWSYS_NAMESPACE@_IOS_HAVE_STD -# define KWSYS_IOS_USE_ANSI @KWSYS_NAMESPACE@_IOS_USE_ANSI -# define KWSYS_IOS_USE_SSTREAM @KWSYS_NAMESPACE@_IOS_USE_SSTREAM -# define KWSYS_IOS_USE_STRSTREAM_H @KWSYS_NAMESPACE@_IOS_USE_STRSTREAM_H -# define KWSYS_IOS_USE_STRSTREA_H @KWSYS_NAMESPACE@_IOS_USE_STRSTREA_H -# define KWSYS_STAT_HAS_ST_MTIM @KWSYS_NAMESPACE@_STAT_HAS_ST_MTIM -# define KWSYS_STL_STRING_HAVE_OSTREAM @KWSYS_NAMESPACE@_STL_STRING_HAVE_OSTREAM -# define KWSYS_STL_STRING_HAVE_ISTREAM @KWSYS_NAMESPACE@_STL_STRING_HAVE_ISTREAM +# define KWSYS_NAME_IS_KWSYS @KWSYS_NAMESPACE@_NAME_IS_KWSYS +# define KWSYS_STL_HAVE_STD @KWSYS_NAMESPACE@_STL_HAVE_STD +# define KWSYS_IOS_HAVE_STD @KWSYS_NAMESPACE@_IOS_HAVE_STD +# define KWSYS_IOS_USE_ANSI @KWSYS_NAMESPACE@_IOS_USE_ANSI +# define KWSYS_IOS_USE_SSTREAM @KWSYS_NAMESPACE@_IOS_USE_SSTREAM +# define KWSYS_IOS_USE_STRSTREAM_H @KWSYS_NAMESPACE@_IOS_USE_STRSTREAM_H +# define KWSYS_IOS_USE_STRSTREA_H @KWSYS_NAMESPACE@_IOS_USE_STRSTREA_H +# define KWSYS_STAT_HAS_ST_MTIM @KWSYS_NAMESPACE@_STAT_HAS_ST_MTIM +# define KWSYS_STL_STRING_HAVE_OSTREAM @KWSYS_NAMESPACE@_STL_STRING_HAVE_OSTREAM +# define KWSYS_STL_STRING_HAVE_ISTREAM @KWSYS_NAMESPACE@_STL_STRING_HAVE_ISTREAM +# define KWSYS_STL_STRING_HAVE_NEQ_CHAR @KWSYS_NAMESPACE@_STL_STRING_HAVE_NEQ_CHAR #endif #endif diff --git a/Source/kwsys/kwsysPlatformCxxTests.cxx b/Source/kwsys/kwsysPlatformCxxTests.cxx index d8454fd..5d24766 100644 --- a/Source/kwsys/kwsysPlatformCxxTests.cxx +++ b/Source/kwsys/kwsysPlatformCxxTests.cxx @@ -54,6 +54,17 @@ void f(istream& is, kwsys_stl::string& s) { is >> s; } int main() { return 0; } #endif +#ifdef TEST_KWSYS_STL_STRING_HAVE_NEQ_CHAR +# if KWSYS_STL_HAVE_STD +# define kwsys_stl std +# else +# define kwsys_stl +# endif +# include <string> +bool f(const kwsys_stl::string& s) { return s != ""; } +int main() { return 0; } +#endif + #ifdef TEST_KWSYS_STAT_HAS_ST_MTIM #include <sys/types.h> #include <sys/stat.h> diff --git a/Source/kwsys/kwsys_stl_string.hxx.in b/Source/kwsys/kwsys_stl_string.hxx.in index 7d45649..2061c18 100644 --- a/Source/kwsys/kwsys_stl_string.hxx.in +++ b/Source/kwsys/kwsys_stl_string.hxx.in @@ -90,3 +90,22 @@ operator<<(@KWSYS_NAMESPACE@_ios::ostream& os, return os << s.c_str(); } #endif + +// Provide the operator!= for the stl string and char* if it is not +// provided by the system or another copy of kwsys. Allow user code +// to block this definition by defining the macro +// @KWSYS_NAMESPACE@_STL_STRING_NO_NEQ_CHAR +// to avoid conflicts with other libraries. +#if !@KWSYS_NAMESPACE@_STL_STRING_HAVE_NEQ_CHAR && \ + !defined(@KWSYS_NAMESPACE@_STL_STRING_NO_NEQ_CHAR) && \ + !defined(KWSYS_STL_STRING_NEQ_CHAR_DEFINED) +# define KWSYS_STL_STRING_NEQ_CHAR_DEFINED +inline bool operator!=(@KWSYS_NAMESPACE@_stl::string const& s, const char* c) +{ + return !(s == c); +} +inline bool operator!=(const char* c, @KWSYS_NAMESPACE@_stl::string const& s) +{ + return !(s == c); +} +#endif |