00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00022 #ifndef LIBCWD_CHAR2STR_H
00023 #define LIBCWD_CHAR2STR_H
00024
00025 #ifndef LIBCW_IOSFWD
00026 #define LIBCW_IOSFWD
00027 #include <iosfwd>
00028 #endif
00029
00030 namespace libcwd {
00031
00053 class char2str {
00054 private:
00055 char c;
00056
00057 private:
00058 void print_char_to(std::ostream&) const;
00059 void print_escaped_char_to(std::ostream&) const;
00060
00061 public:
00063 char2str(char ci) : c(ci) { }
00064
00069 friend __inline__ std::ostream& operator<<(std::ostream& os, char2str const c2s)
00070 {
00071 if ((c2s.c > 31 && c2s.c != 92 && c2s.c != 127) || (unsigned char)c2s.c > 159)
00072 c2s.print_char_to(os);
00073 else
00074 c2s.print_escaped_char_to(os);
00075 return os;
00076 }
00077 };
00078
00079 }
00080
00081 #endif // LIBCWD_CHAR2STR_H