File indexing completed on 2025-01-18 09:38:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
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
0042
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 } } }
0060
0061 #endif
0062
0063 #endif