aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/vespa/vespalib/objects/hexdump.h
blob: 402b33d822bfbb79b792e4fc4475c5991ff0386c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <vespa/vespalib/stllike/string.h>

namespace vespalib {

class asciistream;

/*
 * Helper class to provide hex dump of the contents in a buffer.
 */
class HexDump
{
public:
    HexDump(const void * buf, size_t sz) : _buf(buf), _sz(sz) { }
    vespalib::string toString() const;
    friend std::ostream & operator << (std::ostream & os, const HexDump & hd);
    friend asciistream & operator << (asciistream & os, const HexDump & hd);
private:
    const void * _buf;
    size_t       _sz;
};

}