proxygen
proxygen::Hex16Printer Class Reference

#include <Logging.h>

Inheritance diagram for proxygen::Hex16Printer:
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 150 of file Logging.h.

Member Function Documentation

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

Implements proxygen::IOBufPrinter.

Definition at line 59 of file Logging.cpp.

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

59  {
60  stringstream out;
61  const uint8_t* data = buf->data();
62  char tmp[24];
63  for (size_t i = 0; i < buf->length(); i++) {
64  snprintf(tmp, 3, "%02x", data[i]);
65  out << tmp;
66  if ((i + 1) % 2 == 0) {
67  out << ' ';
68  }
69  if ((i + 1) % 16 == 0) {
70  out << std::endl;
71  }
72  }
73  return out.str();
74 }
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: