1/*
2 * Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef _KERNEL_DEBUG_HEX_DUMP_H
6#define _KERNEL_DEBUG_HEX_DUMP_H
7
8
9#include <debug.h>
10
11
12namespace BKernel {
13
14
15enum {
16	HEX_DUMP_FLAG_OMIT_ADDRESS	= 0x01
17};
18
19
20class HexDumpDataProvider {
21public:
22	virtual						~HexDumpDataProvider();
23
24	virtual	bool				HasMoreData() const = 0;
25	virtual	uint8				NextByte() = 0;
26	virtual	bool				GetAddressString(char* buffer,
27									size_t bufferSize) const;
28};
29
30
31class HexDumpBufferDataProvider : public HexDumpDataProvider {
32public:
33								HexDumpBufferDataProvider(const void* data,
34									size_t dataSize);
35
36	virtual	bool				HasMoreData() const;
37	virtual	uint8				NextByte();
38	virtual	bool				GetAddressString(char* buffer,
39									size_t bufferSize) const;
40
41private:
42			const uint8*		fData;
43			size_t				fDataSize;
44};
45
46
47void	print_hex_dump(HexDumpDataProvider& data, size_t maxBytes,
48			uint32 flags = 0);
49void	print_hex_dump(const void* data, size_t maxBytes, uint32 flags = 0);
50
51
52}	// namespace BKernel
53
54
55#endif	/* _KERNEL_DEBUG_HEX_DUMP_H */
56