Raw.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2022 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#include "squid.h"
10#include "base/IoManip.h"
11#include "base/Raw.h"
12#include "debug/Stream.h"
13
14#include <iostream>
15
16std::ostream &
17Raw::print(std::ostream &os) const
18{
19 if (label_)
20 os << ' ' << label_ << '[' << size_ << ']';
21
22 if (!size_)
23 return os;
24
25 // finalize debugging level if no level was set explicitly via minLevel()
26 const int finalLevel = (level >= 0) ? level :
28 if (finalLevel <= Debug::SectionLevel()) {
29 if (label_)
30 os << '=';
31 else if (useGap_)
32 os << ' ';
33 if (data_) {
34 if (useHex_)
35 PrintHex(os, data_, size_);
36 else
37 os.write(data_, size_);
38 } else {
39 os << "[null]";
40 }
41 }
42
43 return os;
44}
45
void PrintHex(std::ostream &os, const char *const data, const size_t n)
Prints the first n data bytes using hex notation. Does nothing if n is 0.
Definition: IoManip.cc:16
static int SectionLevel()
maximum level currently allowed
Definition: Stream.h:106
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
const char * data_
raw data to be printed
Definition: Raw.h:51
int level
Definition: Raw.h:45
size_t size_
data length
Definition: Raw.h:52
#define DBG_DATA
Definition: Stream.h:43

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors