proxygen
proxygen::BinPrinter Class Reference

#include <Logging.h>

Inheritance diagram for proxygen::BinPrinter:
proxygen::IOBufPrinter

Public Member Functions

std::string print (const folly::IOBuf *buf) override
 
- Public Member Functions inherited from proxygen::IOBufPrinter
 IOBufPrinter ()
 
virtual ~IOBufPrinter ()
 

Additional Inherited Members

- Public Types inherited from proxygen::IOBufPrinter
enum  Format : uint8_t { Format::HEX_FOLLY = 0, Format::HEX_16 = 1, Format::CHAIN_INFO = 2, Format::BIN = 3 }
 
- Static Public Member Functions inherited from proxygen::IOBufPrinter
static std::string printChain (const folly::IOBuf *buf, Format format, bool coalesce)
 
static std::string printHexFolly (const folly::IOBuf *buf, bool coalesce=false)
 
static std::string printHex16 (const folly::IOBuf *buf, bool coalesce=false)
 
static std::string printChainInfo (const folly::IOBuf *buf)
 
static std::string printBin (const folly::IOBuf *buf, bool coalesce=false)
 

Detailed Description

Definition at line 165 of file Logging.h.

Member Function Documentation

string proxygen::BinPrinter::print ( const folly::IOBuf buf)
overridevirtual

Implements proxygen::IOBufPrinter.

Definition at line 83 of file Logging.cpp.

References b, data, folly::IOBuf::data(), i, folly::IOBuf::length(), and uint8_t.

83  {
84  static uint8_t bytesPerLine = 8;
85  string out;
86  const uint8_t* data = buf->data();
87  for (size_t i = 0; i < buf->length(); i++) {
88  for (int b = 7; b >= 0; b--) {
89  out += data[i] & 1 << b ? '1' : '0';
90  }
91  out += ' ';
92  out += isprint(data[i]) ? data[i] : ' ';
93  if ((i + 1) % bytesPerLine == 0) {
94  out += '\n';
95  } else {
96  out += ' ';
97  }
98  }
99  out += '\n';
100  return out;
101 }
char b
const uint8_t * data() const
Definition: IOBuf.h:499
std::size_t length() const
Definition: IOBuf.h:533
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43

The documentation for this class was generated from the following files: