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

Public Member Functions | Friends | List of all members
libcwd::buf2str Class Reference

Print a (char) buffer with a given size to a debug ostream, escaping non-printable characters. More...

#include <libcwd/buf2str.h>

Public Member Functions

 buf2str (char const *buf, size_t size)
 Construct buf2str object with attributes buf and size.
 

Friends

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 characters.
 

Detailed Description

Print a (char) buffer with a given size to a debug ostream, escaping non-printable characters.

Converts size characters from character buffer pointed to by buf into all printable characters by either printing the character itself, the octal representation or one of \a, \b, \t, \n, \f, \r, \e or \\.

See also
libcwd::char2str

Example:

char const* buf = "\e[31m;Hello\e[0m;\n";
size_t size = strlen(buf);
Dout(dc::notice, "The buffer contains: \"" << buf2str(buf, size) << '"');
buf2str(char const *buf, size_t size)
Construct buf2str object with attributes buf and size.
Definition: buf2str.h:69
#define Dout(cntrl, data)
Macro for writing debug output.
Definition: debug.h:154
channel_ct notice
Definition: debug.cc:460
Copyright © 2001 - 2004 Carlo Wood.  All rights reserved.