Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Commit 2020-02-04 - Compatibility improvements for MSVC 2012, GCC 6.x [2]
  • Fixed missing hexdump.hpp.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | msvc_min_1500 | release | y2020 | gcc_min_408 | tagfiles | gcc_max_605 | msvc_max_1700
Files: files | file ages | folders
SHA3-256: 2e1ff3401151955f721a662ecb54fe96bf8d16e73d1953656d1e091ef5fe9cb1
User & Date: luismachuca 2020-02-07 16:45:46
Context
2020-02-28
03:36
Commit 2020-02-27 - The 27F Release [1]. check-in: 4dad71eb user: luismachuca tags: trunk, clang_min_302, msvc_min_1500, openwatcom_min_200, release, y2020, gcc_min_406
2020-02-07
16:45
Commit 2020-02-04 - Compatibility improvements for MSVC 2012, GCC 6.x [2] check-in: 2e1ff340 user: luismachuca tags: msvc_min_1500, release, y2020, gcc_min_408, tagfiles, gcc_max_605, msvc_max_1700
16:42
Commit 2020-02-04 - Compatibility improvements for MSVC 2012, GCC 6.x. check-in: f22f0a4b user: luismachuca tags: msvc_min_1500, release, y2020, gcc_min_408, tagfiles, gcc_max_605, msvc_max_1700
Changes

Added cxxomfort/cxxomfort/impl/hexdump.hpp.

















































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef CXXOMFORT_IMPL_HEXDUMP_HPP
#define CXXOMFORT_IMPL_HEXDUMP_HPP

namespace cxxomfort { namespace library {

namespace utility {

/**
 * @brief Dumps hex string representation of an area of memory.
 * @ingroup cxxo-sup-utility
 * @overload hexdump
 * @param dest An <tt>array_ref<char></tt> pointing to a writable area of memory of the specified size.
 * @param buffer The data buffer to read, as an <tt>array_ref<byte></tt>.
 * 
 * @returns An integer with the following possible values: <br/>
 * * <tt>==length</tt> if all characters were dumped without issues. <br/>
 * * <tt>0</tt> if there is no data to read, or if <tt>dest</tt> does not hold enough room to write the representation. <br/>
 * * <tt><0</tt> if there was an error when writing the data to @a dest .
 * 
 * @throws Only throws if <tt>sprintf()</tt> were somehow to throw.
 * 
 * */
inline 
int hexdump (cxxomfort::library::array_ref<char> dest, const_bytes_view buffer) {
	using namespace std;
	//error_code ec;
	if (buffer.size() < 1 || dest.size() * 2 < buffer.size()) {
		return 0;
	}
	char const * const buff = ( reinterpret_cast<char const * const>(buffer.data()) );
	size_t i= 0;
	for (i= 0; i < buffer.size(); ++i) {
		int sp = sprintf(dest.data()+2*i, "%hhx", buff[i]); 
		if (sp < 2) {
			return -static_cast<int>(i) -1;
		}
	}
	return i;
	//return ec;
}


inline 
int hexdump (cxxomfort::library::array_ref<char> dest, cxxomfort::library::array_ref<char const> buffer) {
	return hexdump(dest, cxxomfort::library::carrayref<std::byte>(buffer) ) ;
}
/**
 * @brief Dumps hex string representation of an area of memory.
 * @ingroup cxxo-sup-utility
 * @param dest An <tt>array_ref<unsigned char></tt> pointing to a writable area of memory of the specified size.
 * @param ptr A pointer to an area of memory to read.
 * @param length Length of the area of memory to read.
 * */
inline 
int hexdump (cxxomfort::library::array_ref<char> dest, void const * const ptr, size_t length) {
	std::byte const* b = (std::byte const*)(ptr);
	return hexdump(dest, cxxomfort::library::carrayref(b, length) );
}


inline
int hexload (bytes_view dest, std::string_view src) {
	int res= 0;
	(void)(src);
	(void)(dest);
	return res;
}


} 
} } // cxxomfort::library 
#endif  // guard