diff options
author | Brad King <brad.king@kitware.com> | 2015-09-02 14:23:17 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-09-02 14:23:17 (GMT) |
commit | c5cc3441b379e2bc6e70efd6dbd530edebbf0024 (patch) | |
tree | de0c2a39648c936039b7c86886cbe49c04b92923 /Source/kwsys/IOStream.cxx | |
parent | 72c11e590273d100c49f472afc3a7569b233ff00 (diff) | |
parent | 1b79433a6d7cdd1da1a0af74240f2299c78e4112 (diff) | |
download | CMake-c5cc3441b379e2bc6e70efd6dbd530edebbf0024.zip CMake-c5cc3441b379e2bc6e70efd6dbd530edebbf0024.tar.gz CMake-c5cc3441b379e2bc6e70efd6dbd530edebbf0024.tar.bz2 |
Merge branch 'upstream-kwsys' into update-kwsys
Diffstat (limited to 'Source/kwsys/IOStream.cxx')
-rw-r--r-- | Source/kwsys/IOStream.cxx | 88 |
1 files changed, 28 insertions, 60 deletions
diff --git a/Source/kwsys/IOStream.cxx b/Source/kwsys/IOStream.cxx index a31f8c8..81c6a73 100644 --- a/Source/kwsys/IOStream.cxx +++ b/Source/kwsys/IOStream.cxx @@ -12,25 +12,14 @@ #include "kwsysPrivate.h" #include KWSYS_HEADER(Configure.hxx) -// Configure the implementation for the current streams library. -#if !KWSYS_IOS_USE_ANSI -# define ios_base ios -# if defined(__HP_aCC) -# define protected public -# include <iostream.h> // Hack access to some private stream methods. -# undef protected -# endif -#endif - // Include the streams library. -#include KWSYS_HEADER(ios/iostream) +#include <iostream> #include KWSYS_HEADER(IOStream.hxx) // Work-around CMake dependency scanning limitation. This must // duplicate the above list of headers. #if 0 # include "Configure.hxx.in" -# include "kwsys_ios_iostream.hxx.in" # include "IOStream.hxx.in" #endif @@ -50,7 +39,7 @@ namespace KWSYS_NAMESPACE { // Scan an input stream for an integer value. -static int IOStreamScanStream(kwsys_ios::istream& is, char* buffer) +static int IOStreamScanStream(std::istream& is, char* buffer) { // Prepare to write to buffer. char* out = buffer; @@ -64,10 +53,10 @@ static int IOStreamScanStream(kwsys_ios::istream& is, char* buffer) // detect it from the input. A leading 0x means hex, and a leading // 0 alone means octal. int base = 0; - int flags = is.flags() & kwsys_ios::ios_base::basefield; - if(flags == kwsys_ios::ios_base::oct) { base = 8; } - else if(flags == kwsys_ios::ios_base::dec) { base = 10; } - else if(flags == kwsys_ios::ios_base::hex) { base = 16; } + int flags = is.flags() & std::ios_base::basefield; + if(flags == std::ios_base::oct) { base = 8; } + else if(flags == std::ios_base::dec) { base = 10; } + else if(flags == std::ios_base::hex) { base = 16; } bool foundDigit = false; bool foundNonZero = false; if(is.peek() == '0') @@ -134,24 +123,17 @@ static int IOStreamScanStream(kwsys_ios::istream& is, char* buffer) // Read an integer value from an input stream. template <class T> -kwsys_ios::istream& -IOStreamScanTemplate(kwsys_ios::istream& is, T& value, char type) +std::istream& +IOStreamScanTemplate(std::istream& is, T& value, char type) { - int state = kwsys_ios::ios_base::goodbit; + int state = std::ios_base::goodbit; // Skip leading whitespace. -# if KWSYS_IOS_USE_ANSI - kwsys_ios::istream::sentry okay(is); -# else - is.eatwhite(); - kwsys_ios::istream& okay = is; -# endif + std::istream::sentry okay(is); if(okay) { -# if KWSYS_IOS_USE_ANSI try { -# endif // Copy the string to a buffer and construct the format string. char buffer[KWSYS_IOS_INT64_MAX_DIG]; # if defined(_MSC_VER) @@ -174,52 +156,40 @@ IOStreamScanTemplate(kwsys_ios::istream& is, T& value, char type) int success = (sscanf(buffer, format, &result) == 1)?1:0; // Set flags for resulting state. - if(is.peek() == EOF) { state |= kwsys_ios::ios_base::eofbit; } - if(!success) { state |= kwsys_ios::ios_base::failbit; } + if(is.peek() == EOF) { state |= std::ios_base::eofbit; } + if(!success) { state |= std::ios_base::failbit; } else { value = result; } -# if KWSYS_IOS_USE_ANSI - } catch(...) { state |= kwsys_ios::ios_base::badbit; } -# endif + } catch(...) { state |= std::ios_base::badbit; } } -# if KWSYS_IOS_USE_ANSI - is.setstate(kwsys_ios::ios_base::iostate(state)); -# else - is.clear(state); -# endif + is.setstate(std::ios_base::iostate(state)); return is; } // Print an integer value to an output stream. template <class T> -kwsys_ios::ostream& -IOStreamPrintTemplate(kwsys_ios::ostream& os, T value, char type) +std::ostream& +IOStreamPrintTemplate(std::ostream& os, T value, char type) { -# if KWSYS_IOS_USE_ANSI - kwsys_ios::ostream::sentry okay(os); -# else - kwsys_ios::ostream& okay = os; -# endif + std::ostream::sentry okay(os); if(okay) { -# if KWSYS_IOS_USE_ANSI try { -# endif // Construct the format string. char format[8]; char* f = format; *f++ = '%'; - if(os.flags() & kwsys_ios::ios_base::showpos) { *f++ = '+'; } - if(os.flags() & kwsys_ios::ios_base::showbase) { *f++ = '#'; } + if(os.flags() & std::ios_base::showpos) { *f++ = '+'; } + if(os.flags() & std::ios_base::showbase) { *f++ = '#'; } # if defined(_MSC_VER) *f++ = 'I'; *f++ = '6'; *f++ = '4'; # else *f++ = 'l'; *f++ = 'l'; # endif - long bflags = os.flags() & kwsys_ios::ios_base::basefield; - if(bflags == kwsys_ios::ios_base::oct) { *f++ = 'o'; } - else if(bflags != kwsys_ios::ios_base::hex) { *f++ = type; } - else if(os.flags() & kwsys_ios::ios_base::uppercase) { *f++ = 'X'; } + long bflags = os.flags() & std::ios_base::basefield; + if(bflags == std::ios_base::oct) { *f++ = 'o'; } + else if(bflags != std::ios_base::hex) { *f++ = type; } + else if(os.flags() & std::ios_base::uppercase) { *f++ = 'X'; } else { *f++ = 'x'; } *f = '\0'; @@ -228,22 +198,20 @@ IOStreamPrintTemplate(kwsys_ios::ostream& os, T value, char type) char buffer[2*KWSYS_IOS_INT64_MAX_DIG]; sprintf(buffer, format, value); os << buffer; -# if KWSYS_IOS_USE_ANSI - } catch(...) { os.clear(os.rdstate() | kwsys_ios::ios_base::badbit); } -# endif + } catch(...) { os.clear(os.rdstate() | std::ios_base::badbit); } } return os; } # if !KWSYS_IOS_HAS_ISTREAM_LONG_LONG // Implement input stream operator for IOStreamSLL. -kwsys_ios::istream& IOStreamScan(kwsys_ios::istream& is, IOStreamSLL& value) +std::istream& IOStreamScan(std::istream& is, IOStreamSLL& value) { return IOStreamScanTemplate(is, value, 'd'); } // Implement input stream operator for IOStreamULL. -kwsys_ios::istream& IOStreamScan(kwsys_ios::istream& is, IOStreamULL& value) +std::istream& IOStreamScan(std::istream& is, IOStreamULL& value) { return IOStreamScanTemplate(is, value, 'u'); } @@ -251,13 +219,13 @@ kwsys_ios::istream& IOStreamScan(kwsys_ios::istream& is, IOStreamULL& value) # if !KWSYS_IOS_HAS_OSTREAM_LONG_LONG // Implement output stream operator for IOStreamSLL. -kwsys_ios::ostream& IOStreamPrint(kwsys_ios::ostream& os, IOStreamSLL value) +std::ostream& IOStreamPrint(std::ostream& os, IOStreamSLL value) { return IOStreamPrintTemplate(os, value, 'd'); } // Implement output stream operator for IOStreamULL. -kwsys_ios::ostream& IOStreamPrint(kwsys_ios::ostream& os, IOStreamULL value) +std::ostream& IOStreamPrint(std::ostream& os, IOStreamULL value) { return IOStreamPrintTemplate(os, value, 'u'); } |