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

buf2str.h
Go to the documentation of this file.
1 // $Header$
2 //
3 // Copyright (C) 2000 - 2004, by
4 //
5 // Carlo Wood, Run on IRC <carlo@alinoe.com>
6 // RSA-1024 0x624ACAD5 1997-01-26 Sign & Encrypt
7 // Fingerprint16 = 32 EC A7 B6 AC DB 65 A6 F6 F6 55 DD 1C DC FF 61
8 //
9 // This file may be distributed under the terms of the Q Public License
10 // version 1.0 as appearing in the file LICENSE.QPL included in the
11 // packaging of this file.
12 //
13 
22 #ifndef LIBCWD_BUF2STR_H
23 #define LIBCWD_BUF2STR_H
24 
25 #ifndef LIBCWD_CHAR2STR_H
26 #include "char2str.h"
27 #endif
28 #ifndef LIBCW_CSTDDEF
29 #define LIBCW_CSTDDEF
30 #include <cstddef> // Needed for size_t
31 #endif
32 #ifndef LIBCW_IOSFWD
33 #define LIBCW_IOSFWD
34 #include <iosfwd>
35 #endif
36 
37 namespace libcwd {
38 
62 class buf2str {
63 private:
64  char const* M_buf;
65  size_t M_size;
66 
67 public:
69  buf2str(char const* buf, size_t size) : M_buf(buf), M_size(size) { }
70 
75  friend
76  inline
77  std::ostream&
78  operator<<(std::ostream& os, buf2str const& __buf2str)
79  {
80  size_t size = __buf2str.M_size;
81  for (char const* p1 = __buf2str.M_buf; size > 0; --size, ++p1)
82  os << char2str(*p1);
83  return os;
84  }
85 };
86 
87 } // namespace libcwd
88 
89 #endif // LIBCWD_BUF2STR_H
Definition of utility class char2str.
Print a (char) buffer with a given size to a debug ostream, escaping non-printable characters.
Definition: buf2str.h:62
friend std::ostream & operator<<(std::ostream &os, buf2str const &__buf2str)
Write the contents of the buffer represented by __buf2str to the ostream os, escaping non-printable c...
Definition: buf2str.h:78
buf2str(char const *buf, size_t size)
Construct buf2str object with attributes buf and size.
Definition: buf2str.h:69
Print a char to a debug ostream, escaping non-printable characters as needed.
Definition: char2str.h:53
namespace for libcwd.
Definition: debug.cc:87
Copyright © 2001 - 2004 Carlo Wood.  All rights reserved.