Chris@16: // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) Chris@16: // (C) Copyright 2003-2007 Jonathan Turkanis Chris@16: // Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) Chris@16: Chris@16: // See http://www.boost.org/libs/iostreams for documentation. Chris@16: Chris@16: #ifndef BOOST_IOSTREAMS_CHAR_TRAITS_HPP_INCLUDED Chris@16: #define BOOST_IOSTREAMS_CHAR_TRAITS_HPP_INCLUDED Chris@16: Chris@16: #if defined(_MSC_VER) && (_MSC_VER >= 1020) Chris@16: # pragma once Chris@16: #endif Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include // EOF. Chris@16: #include // std::char_traits. Chris@16: #include Chris@16: #include Chris@16: #ifndef BOOST_IOSTREAMS_NO_WIDE_STREAMS Chris@16: # include Chris@16: #endif Chris@16: Chris@16: #ifdef BOOST_NO_STDC_NAMESPACE Chris@16: namespace std { using ::wint_t; } Chris@16: #endif Chris@16: Chris@16: namespace boost { namespace iostreams { Chris@16: Chris@16: // Dinkumware that comes with QNX Momentics 6.3.0, 4.0.2, incorrectly defines Chris@16: // the EOF and WEOF macros to not std:: qualify the wint_t type (and so does Chris@16: // Sun C++ 5.8 + STLport 4). Fix by placing the def in this scope. Chris@16: // NOTE: Use BOOST_WORKAROUND? Chris@16: #if (defined(__QNX__) && defined(BOOST_DINKUMWARE_STDLIB)) \ Chris@16: || defined(__SUNPRO_CC) Chris@16: using ::std::wint_t; Chris@16: #endif Chris@16: Chris@16: const int WOULD_BLOCK = (int) (EOF - 1); Chris@16: Chris@16: #ifndef BOOST_IOSTREAMS_NO_WIDE_STREAMS Chris@16: const std::wint_t WWOULD_BLOCK = (std::wint_t) (WEOF - 1); Chris@16: #endif Chris@16: Chris@16: template Chris@16: struct char_traits; Chris@16: Chris@16: template<> Chris@16: struct char_traits : BOOST_IOSTREAMS_CHAR_TRAITS(char) { Chris@16: static char newline() { return '\n'; } Chris@16: static int good() { return '\n'; } Chris@16: static int would_block() { return WOULD_BLOCK; } Chris@16: static bool is_good(int c) { return c != EOF && c != WOULD_BLOCK; } Chris@16: static bool is_eof(int c) { return c == EOF; } Chris@16: static bool would_block(int c) { return c == WOULD_BLOCK; } Chris@16: }; Chris@16: Chris@16: #ifndef BOOST_IOSTREAMS_NO_WIDE_STREAMS Chris@16: template<> Chris@16: struct char_traits : std::char_traits { Chris@16: static wchar_t newline() { return L'\n'; } Chris@16: static std::wint_t good() { return L'\n'; } Chris@16: static std::wint_t would_block() { return WWOULD_BLOCK; } Chris@16: static bool is_good(std::wint_t c) { return c != WEOF && c != WWOULD_BLOCK; } Chris@16: static bool is_eof(std::wint_t c) { return c == WEOF; } Chris@16: static bool would_block(std::wint_t c) { return c == WWOULD_BLOCK; } Chris@16: }; Chris@16: #endif Chris@16: Chris@16: } } // End namespaces iostreams, boost. Chris@16: Chris@16: #endif // #ifndef BOOST_IOSTREAMS_CHAR_TRAITS_HPP_INCLUDED