libcwd: The C++ Debugging Support Library - Reference Manual
Author: Carlo Wood
Description: C++ debugging support library with ostream debug output
Keywords: libcwd, debug output, debug facility, debug channel, object orientation, OO, C++, nested debug output, ostream, memory allocation, debugging, source file and line number

Main Page Reference Manual Namespace List Compound List Namespace Members Compound Members File Members

# libcwd/char2str.h

Go to the documentation of this file.

    00001 // $Header$
    00002 //
    00003 // Copyright (C) 2000 - 2004, by
    00004 //
    00005 // Carlo Wood, Run on IRC <carlo@alinoe.com>
    00006 // RSA-1024 0x624ACAD5 1997-01-26                    Sign & Encrypt
    00007 // Fingerprint16 = 32 EC A7 B6 AC DB 65 A6  F6 F6 55 DD 1C DC FF 61
    00008 //
    00009 // This file may be distributed under the terms of the Q Public License
    00010 // version 1.0 as appearing in the file LICENSE.QPL included in the
    00011 // packaging of this file.
    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 } // namespace libcwd
    00080
    00081 #endif // LIBCWD_CHAR2STR_H