ARTS  2.3.1285(git:92a29ea9-dirty)
iotraits.h
Go to the documentation of this file.
1 // <!!-*-C++-*- file: iotraits.h --->
2 // <!!-------------------------------------------------------------------------->
3 // <!! Copyright (C) 1996 Dietmar Kuehl >
4 // <!! Universitaet Konstanz, Lehrstuhl fuer praktische Informatik I >
5 // <!!>
6 // <!! Permission to use, copy, modify, distribute and sell this >
7 // <!! software for any purpose is hereby granted without fee, provided >
8 // <!! that the above copyright notice appears in all copies and that >
9 // <!! both that copyright notice and this permission notice appear in >
10 // <!! supporting documentation. Dietmar Kuehl makes no representations >
11 // <!! about the suitability of this software for any purpose. It is >
12 // <!! provided "as is" without express or implied warranty. >
13 // <!!-------------------------------------------------------------------------->
14 
15 // Author: Dietmar Kühl dietmar.kuehl@uni-konstanz.de www.informatik.uni-konstanz.de/~kuehl
16 // Title: The definition of the iotraits classes
17 
18 //------------------------------------------------------------------------------
19 
20 #include "config_global.h"
21 
22 #ifndef HAVE_SSTREAM
23 #if !defined(IOTRAITS_H)
24 #define IOTRAITS_H
25 
26 #include <cstring>
27 #include <cctype>
28 #include <streambuf.h>
29 
30 #if defined(__GNUC__) && __GNUC_MINOR__ <= 7
31 # define PORT_TEMPLATE_SPECIALIZATION
32 #else
33 # define PORT_TEMPLATE_SPECIALIZATION template <>
34 #endif
35 
36 //------------------------------------------------------------------------------
37 
38 template <class charT> struct ctype {};
39 
41 struct ctype<char>
42 {
43  typedef char char_type;
44  typedef int int_type;
45 
46  //--- fix needed: bool isspace(int_type c) const { return isspace(c); }
47  char_type newline() const { return '\n'; }
48 };
49 
50 //------------------------------------------------------------------------------
51 
52 template <class charT> struct ios_traits {};
53 
54 //------------------------------------------------------------------------------
55 
57 struct ios_traits<char>
58 {
59  typedef char char_type;
60  typedef int int_type;
61  typedef streampos pos_type;
62  typedef streamoff off_type;
63  typedef int state_type;
64 
65  static inline char_type eos() { return char_type(); }
66  static inline int_type eof() { return -1; }
67  static inline int_type not_eof(int_type c) { return c == eof()? eof() + 1: c; }
68  static inline char_type newline() { return '\n'; }
69 
70  static inline bool eq(char_type c1, char_type c2) { return c1 == c2; }
71  static inline bool eq_int_type(int_type i1, int_type i2) { return i1 == i2; }
72  static inline void assign(char& to, char from) { to = from; }
73 
74  static inline char_type to_char_type(int_type c) { return char_type(c); }
75  static inline int_type to_int_type(char_type c) { return int_type(c); }
76 
77  static inline char_type *copy(char_type *dst, char_type const *src, pos_type n)
78  {
79  memcpy(dst, src, n);
80  return dst;
81  }
82  static inline size_t length(char_type const *s) { return strlen(s); }
83 };
84 
85 //------------------------------------------------------------------------------
86 
87 #endif /* IOTRAITS_H */
88 #endif /* HAVE_SSTREAM */
89 
static size_t length(char_type const *s)
Definition: iotraits.h:82
streamoff off_type
Definition: iotraits.h:62
static int_type to_int_type(char_type c)
Definition: iotraits.h:75
static char_type eos()
Definition: iotraits.h:65
static int_type not_eof(int_type c)
Definition: iotraits.h:67
char_type newline() const
Definition: iotraits.h:47
streampos pos_type
Definition: iotraits.h:61
static bool eq(char_type c1, char_type c2)
Definition: iotraits.h:70
static char_type newline()
Definition: iotraits.h:68
#define PORT_TEMPLATE_SPECIALIZATION
Definition: iotraits.h:33
static char_type to_char_type(int_type c)
Definition: iotraits.h:74
static char_type * copy(char_type *dst, char_type const *src, pos_type n)
Definition: iotraits.h:77
int int_type
Definition: iotraits.h:44
static int_type eof()
Definition: iotraits.h:66
char char_type
Definition: iotraits.h:43
static bool eq_int_type(int_type i1, int_type i2)
Definition: iotraits.h:71
Definition: iotraits.h:38
static void assign(char &to, char from)
Definition: iotraits.h:72