tlx
bitdump.hpp
Go to the documentation of this file.
1
/*******************************************************************************
2
* tlx/string/bitdump.hpp
3
*
4
* Part of tlx - http://panthema.net/tlx
5
*
6
* Copyright (C) 2019 Timo Bingmann <tb@panthema.net>
7
*
8
* All rights reserved. Published under the Boost Software License, Version 1.0
9
******************************************************************************/
10
11
#ifndef TLX_STRING_BITDUMP_HEADER
12
#define TLX_STRING_BITDUMP_HEADER
13
14
#include <cstdint>
15
#include <string>
16
17
namespace
tlx
{
18
19
//! \addtogroup tlx_string
20
//! \{
21
//! \name Bitdump Methods
22
//! \{
23
24
/******************************************************************************/
25
// Bitdump Methods
26
27
/*!
28
* Dump a (binary) string as a sequence of 8-bit little-endian bytes.
29
*
30
* \param data binary data to output as bits
31
* \param size length of binary data
32
* \return string of binary digits
33
*/
34
std::string
bitdump_le8
(
const
void
*
const
data,
size_t
size);
35
36
/*!
37
* Dump a (binary) string as a sequence of 8-bit little-endian bytes.
38
*
39
* \param str binary data to output as bits
40
* \return string of binary digits
41
*/
42
std::string
bitdump_le8
(
const
std::string& str);
43
44
/*!
45
* Dump a (binary) item as a sequence of 8-bit little-endian bytes.
46
*
47
* \param t binary data to output as bits
48
* \return string of binary digits
49
*/
50
template
<
typename
Type>
51
std::string
bitdump_le8_type
(
const
Type& t) {
52
return
bitdump_le8
(&t,
sizeof
(t));
53
}
54
55
/*----------------------------------------------------------------------------*/
56
57
/*!
58
* Dump a (binary) string as a sequence of 8-bit big-endian bytes.
59
*
60
* \param data binary data to output as bits
61
* \param size length of binary data
62
* \return string of binary digits
63
*/
64
std::string
bitdump_be8
(
const
void
*
const
data,
size_t
size);
65
66
/*!
67
* Dump a (binary) string as a sequence of 8-bit big-endian bytes.
68
*
69
* \param str binary data to output as bits
70
* \return string of binary digits
71
*/
72
std::string
bitdump_be8
(
const
std::string& str);
73
74
/*!
75
* Dump a (binary) item as a sequence of 8-bit big-endian bytes.
76
*
77
* \param t binary data to output as bits
78
* \return string of binary digits
79
*/
80
template
<
typename
Type>
81
std::string
bitdump_be8_type
(
const
Type& t) {
82
return
bitdump_be8
(&t,
sizeof
(t));
83
}
84
85
//! \}
86
//! \}
87
88
}
// namespace tlx
89
90
#endif // !TLX_STRING_BITDUMP_HEADER
91
92
/******************************************************************************/
tlx::bitdump_be8
std::string bitdump_be8(const void *const data, size_t size)
Dump a (binary) string as a sequence of 8-bit big-endian bytes.
Definition:
bitdump.cpp:59
tlx::bitdump_le8_type
std::string bitdump_le8_type(const Type &t)
Dump a (binary) item as a sequence of 8-bit little-endian bytes.
Definition:
bitdump.hpp:59
tlx::bitdump_le8
std::string bitdump_le8(const void *const data, size_t size)
Dump a (binary) string as a sequence of 8-bit little-endian bytes.
Definition:
bitdump.cpp:26
tlx
Definition:
exclusive_scan.hpp:17
tlx::bitdump_be8_type
std::string bitdump_be8_type(const Type &t)
Dump a (binary) item as a sequence of 8-bit big-endian bytes.
Definition:
bitdump.hpp:89
tlx
string
bitdump.hpp
Generated on Fri Jan 31 2020 00:00:00 for tlx by
1.8.17