10Duke Enterprise C++ SDK
Toggle main menu visibility
Loading...
Searching...
No Matches
BinaryView.h
1
#ifndef TENDUKE_CORE_BINARYVIEW_H
2
#define TENDUKE_CORE_BINARYVIEW_H
3
4
#include "./DataSpan.h"
5
6
#include <cstring>
7
#include <string>
8
9
namespace
tenduke
{
namespace
utl
{
10
39
class
BinaryView
:
public
virtual
::tenduke::utl::DataSpan
40
{
41
public
:
47
BinaryView
(
48
const
unsigned
char
*
data
,
49
const
std::size_t size
50
) : data_(
data
)
51
, size_(size)
52
{
53
}
54
58
const
unsigned
char
*
data
()
const override
59
{
60
return
data_;
61
}
62
66
std::size_t
size_bytes
()
const override
67
{
68
return
size_;
69
}
70
71
private
:
72
const
unsigned
char
*data_;
73
std::size_t size_;
74
};
75
80
inline
BinaryView
empty_view
()
81
{
82
return
{
nullptr
, 0};
83
}
84
91
inline
BinaryView
make_view
(
92
const
unsigned
char
* data,
93
const
std::size_t size
94
) {
95
return
{data, size};
96
}
97
103
template
<std::
size_t
N>
104
inline
BinaryView
make_view
(
unsigned
char
(&arr)[N])
105
{
106
return
BinaryView
(arr, N);
107
}
108
114
inline
BinaryView
make_view
(
const
char
*value)
115
{
116
return
{
117
reinterpret_cast<
const
unsigned
char
*
>
(value),
118
std::strlen((
const
char
*)value)
119
};
120
}
121
127
inline
BinaryView
make_view
(
const
std::string &value)
128
{
129
return
{
130
reinterpret_cast<
const
unsigned
char
*
>
(value.data()),
131
value.size()
132
};
133
}
134
135
}}
136
137
#endif
//TENDUKE_CORE_BINARYVIEW_H
tenduke::utl::BinaryView
A read-only view of binary data.
Definition
BinaryView.h:40
tenduke::utl::BinaryView::BinaryView
BinaryView(const unsigned char *data, const std::size_t size)
Constructs a new instance.
Definition
BinaryView.h:47
tenduke::utl::BinaryView::data
const unsigned char * data() const override
Returns a pointer to the beginning of the underlying sequence.This provides a read-only view of the d...
Definition
BinaryView.h:58
tenduke::utl::BinaryView::size_bytes
std::size_t size_bytes() const override
Returns the size of the span in bytes.size of the span in bytes
Definition
BinaryView.h:66
tenduke::utl::DataSpan
A span of binary data.
Definition
DataSpan.h:16
tenduke::utl
Utilities.
Definition
Base64Decoder.h:10
tenduke::utl::empty_view
BinaryView empty_view()
Creates an empty tenduke::utl::BinaryView.
Definition
BinaryView.h:80
tenduke::utl::make_view
BinaryView make_view(const unsigned char *data, const std::size_t size)
A helper function to create a tenduke::utl::BinaryView from a const pointer.
Definition
BinaryView.h:91
tenduke
Root for classes, functions and globals of 10Duke C++ Client.
Definition
APIRequest.h:4
core
core
src
utl
BinaryView.h
Generated by
1.17.0