00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #if HAVE_CONFIG_H
00021 #include <config.h>
00022 #else
00023 #error "Please run ./configure in the top arts directory before compiling."
00024 #endif
00025
00026 #ifndef HAVE_SSTREAM
00027 #if !defined(IOTRAITS_H)
00028 #define IOTRAITS_H
00029
00030 #include <cstring>
00031 #include <cctype>
00032 #include <streambuf.h>
00033
00034 #if defined(__GNUC__) && __GNUC_MINOR__ <= 7
00035 # define PORT_TEMPLATE_SPECIALIZATION
00036 #else
00037 # define PORT_TEMPLATE_SPECIALIZATION template <>
00038 #endif
00039
00040
00041
00042 template <class charT> struct ctype {};
00043
00044 PORT_TEMPLATE_SPECIALIZATION
00045 struct ctype<char>
00046 {
00047 typedef char char_type;
00048 typedef int int_type;
00049
00050
00051 char_type newline() const { return '\n'; }
00052 };
00053
00054
00055
00056 template <class charT> struct ios_traits {};
00057
00058
00059
00060 PORT_TEMPLATE_SPECIALIZATION
00061 struct ios_traits<char>
00062 {
00063 typedef char char_type;
00064 typedef int int_type;
00065 typedef streampos pos_type;
00066 typedef streamoff off_type;
00067 typedef int state_type;
00068
00069 static inline char_type eos() { return char_type(); }
00070 static inline int_type eof() { return -1; }
00071 static inline int_type not_eof(int_type c) { return c == eof()? eof() + 1: c; }
00072 static inline char_type newline() { return '\n'; }
00073
00074 static inline bool eq(char_type c1, char_type c2) { return c1 == c2; }
00075 static inline bool eq_int_type(int_type i1, int_type i2) { return i1 == i2; }
00076 static inline void assign(char& to, char from) { to = from; }
00077
00078 static inline char_type to_char_type(int_type c) { return char_type(c); }
00079 static inline int_type to_int_type(char_type c) { return int_type(c); }
00080
00081 static inline char_type *copy(char_type *dst, char_type const *src, pos_type n)
00082 {
00083 memcpy(dst, src, n);
00084 return dst;
00085 }
00086 static inline size_t length(char_type const *s) { return strlen(s); }
00087 };
00088
00089
00090
00091 #endif
00092 #endif
00093