Thrill  0.1
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 <[email protected]>
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  */
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>
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  */
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>
82  return bitdump_be8(&t, sizeof(t));
83 }
84 
85 //! \}
86 //! \}
87 
88 } // namespace tlx
89 
90 #endif // !TLX_STRING_BITDUMP_HEADER
91 
92 /******************************************************************************/
std::string bitdump_le8_type(const Type &t)
Dump a (binary) item as a sequence of 8-bit little-endian bytes.
Definition: bitdump.hpp:51
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:18
Type
VFS object type.
Definition: file_io.hpp:52
std::string bitdump_be8_type(const Type &t)
Dump a (binary) item as a sequence of 8-bit big-endian bytes.
Definition: bitdump.hpp:81
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
Definition: allocator.hpp:220
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:51