Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:49

0001 // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
0002 // (C) Copyright 2003-2007 Jonathan Turkanis
0003 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0004 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
0005 
0006 // Provides std::char_traits for libraries without templated streams. Should not
0007 // be confused with <boost/iostreams/char_traits.hpp>, which defines the
0008 // template boost::iostreams::char_traits.
0009 
0010 // See http://www.boost.org/libs/iostreams for documentation.
0011 
0012 #ifndef BOOST_IOSTREAMS_DETAIL_CHAR_TRAITS_HPP_INCLUDED
0013 #define BOOST_IOSTREAMS_DETAIL_CHAR_TRAITS_HPP_INCLUDED
0014 
0015 #if defined(_MSC_VER)
0016 # pragma once
0017 #endif
0018 
0019 #include <iosfwd>
0020 #include <boost/iostreams/detail/config/wide_streams.hpp>
0021 #ifdef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES
0022 # include <boost/config.hpp> // Make sure size_t is in std.
0023 # include <cstddef>
0024 # include <cstring>
0025 # include <cstdio>
0026 #endif
0027 
0028 #ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES //--------------------------------//
0029 # define BOOST_IOSTREAMS_CHAR_TRAITS(ch) std::char_traits< ch >
0030 #else
0031 # define BOOST_IOSTREAMS_CHAR_TRAITS(ch) boost::iostreams::detail::char_traits
0032 
0033 namespace boost { namespace iostreams { namespace detail {
0034 
0035 struct char_traits  {
0036     typedef char            char_type;
0037     typedef int             int_type;
0038     typedef std::streampos  pos_type;
0039     typedef std::streamoff  off_type;
0040 
0041     // Note: this may not be not conforming, since it treats chars as unsigned,
0042     // but is only used to test for equality.
0043     static int compare(const char* lhs, const char* rhs, std::size_t n)
0044     { return std::strncmp(lhs, rhs, n); }
0045     static char* copy(char *dest, const char *src, std::size_t n)
0046     { return static_cast<char*>(std::memcpy(dest, src, n)); }
0047     static char* move(char *dest, const char *src, std::size_t n)
0048     { return static_cast<char*>(std::memmove(dest, src, n)); }
0049     static const char* find(const char* s, std::size_t n, const char& c)
0050     { return (const char*) (const void*) std::memchr(s, c, n); }
0051     static char to_char_type(const int& c) { return c; }
0052     static int to_int_type(const char& c) { return c; }
0053     static bool eq_int_type(const int& lhs, const int& rhs)
0054     { return lhs == rhs; }
0055     static int eof() { return EOF; }
0056     static int not_eof(const int& c) { return c != EOF ? c : '\n'; }
0057 };
0058 
0059 } } } // End namespaces detail, iostreams, boost.
0060 
0061 #endif // #ifdef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES //-----------------------//
0062 
0063 #endif // #ifndef BOOST_IOSTREAMS_DETAIL_CHAR_TRAITS_HPP_INCLUDED