Raw.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9/* DEBUG: section 00 Debug Routines */
10
11#ifndef SQUID_SRC_BASE_RAW_H
12#define SQUID_SRC_BASE_RAW_H
13
14#include <iosfwd>
15
20class Raw
21{
22public:
23 Raw(const char *label, const char *data, const size_t size):
24 level(-1), label_(label), data_(data), size_(size), useHex_(false), useGap_(true) {}
25
27 Raw &minLevel(const int aLevel) { level = aLevel; return *this; }
28
30 Raw &hex() { useHex_ = true; return *this; }
31
32 Raw &gap(bool useGap = true) { useGap_ = useGap; return *this; }
33
40 std::ostream &print(std::ostream &os) const;
41
45 int level;
46
47private:
48 void printHex(std::ostream &os) const;
49
50 const char *label_;
51 const char *data_;
52 size_t size_;
53 bool useHex_;
54 bool useGap_;
55};
56
57inline std::ostream &
58operator <<(std::ostream &os, const Raw &raw)
59{
60 raw.print(os);
61 return os;
62}
63
64#endif /* SQUID_SRC_BASE_RAW_H */
65
int size
Definition: ModDevPoll.cc:75
std::ostream & operator<<(std::ostream &os, const Raw &raw)
Definition: Raw.h:58
Definition: Raw.h:21
Raw & gap(bool useGap=true)
Definition: Raw.h:32
bool useGap_
whether to print leading space if label is missing
Definition: Raw.h:54
bool useHex_
whether hex() has been called
Definition: Raw.h:53
std::ostream & print(std::ostream &os) const
Definition: Raw.cc:17
const char * label_
optional data name or ID; triggers size printing
Definition: Raw.h:50
void printHex(std::ostream &os) const
Raw(const char *label, const char *data, const size_t size)
Definition: Raw.h:23
Raw & minLevel(const int aLevel)
limit data printing to at least the given debugging level
Definition: Raw.h:27
const char * data_
raw data to be printed
Definition: Raw.h:51
Raw & hex()
print data using two hex digits per byte (decoder: xxd -r -p)
Definition: Raw.h:30
int level
Definition: Raw.h:45
size_t size_
data length
Definition: Raw.h:52

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors