source: NonGTP/Boost/boost/iostreams/char_traits.hpp @ 857

Revision 857, 2.3 KB checked in by igarcia, 19 years ago (diff)
RevLine 
[857]1// (C) Copyright Jonathan Turkanis 2003.
2// Distributed under the Boost Software License, Version 1.0. (See accompanying
3// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
4
5// See http://www.boost.org/libs/iostreams for documentation.
6
7#ifndef BOOST_IOSTREAMS_CHAR_TRAITS_HPP_INCLUDED
8#define BOOST_IOSTREAMS_CHAR_TRAITS_HPP_INCLUDED
9
10#if defined(_MSC_VER) && (_MSC_VER >= 1020)
11# pragma once
12#endif
13
14#include <boost/config.hpp>
15#include <cstddef>
16#include <cstdio>  // EOF.
17#include <string>  // std::char_traits.
18#include <boost/iostreams/detail/char_traits.hpp>
19#include <boost/iostreams/detail/config/wide_streams.hpp>
20#ifndef BOOST_IOSTREAMS_NO_WIDE_STREAMS
21# include <cwchar>
22#endif
23
24#ifdef BOOST_NO_STDC_NAMESPACE
25namespace std { using ::wint_t; }
26#endif
27
28namespace boost { namespace iostreams {
29
30// Dinkumware that comes with QNX Momentics 6.3.0, 4.0.2, incorrectly defines the
31// EOF and WEOF macros to not std:: qualify the wint_t type.
32// Fix by placing the def in this scope.
33#if defined(__QNX__) && defined(BOOST_DINKUMWARE_STDLIB)
34using ::std::wint_t;
35#endif
36
37const int WOULD_BLOCK = (int) (EOF - 1);
38
39#ifndef BOOST_IOSTREAMS_NO_WIDE_STREAMS
40const std::wint_t WWOULD_BLOCK = (std::wint_t) (WEOF - 1);
41#endif
42
43template<typename Ch>
44struct char_traits;
45
46template<>
47struct char_traits<char> : BOOST_IOSTREAMS_CHAR_TRAITS(char) {
48    static char newline() { return '\n'; }
49    static int good() { return '\n'; }
50    static int would_block() { return WOULD_BLOCK; }
51    static bool is_good(int c) { return c != EOF && c != WOULD_BLOCK; }
52    static bool is_eof(int c) { return c == EOF; }
53    static bool would_block(int c) { return c == WOULD_BLOCK; }
54};
55
56#ifndef BOOST_IOSTREAMS_NO_WIDE_STREAMS
57template<>
58struct char_traits<wchar_t> : std::char_traits<wchar_t> {
59    static wchar_t newline() { return L'\n'; }
60    static std::wint_t good() { return L'\n'; }
61    static std::wint_t would_block() { return WWOULD_BLOCK; }
62    static bool is_good(std::wint_t c) { return c != WEOF && c != WWOULD_BLOCK; }
63    static bool is_eof(std::wint_t c) { return c == WEOF; }
64    static bool would_block(std::wint_t c) { return c == WWOULD_BLOCK; }
65};
66#endif
67
68} } // End namespaces iostreams, boost.
69
70#endif // #ifndef BOOST_IOSTREAMS_CHAR_TRAITS_HPP_INCLUDED
Note: See TracBrowser for help on using the repository browser.