Zserio C++17 runtime library 1.3.0
Built for Zserio 2.20.0
Loading...
Searching...
No Matches
Bytes.h
Go to the documentation of this file.
1#ifndef ZSERIO_BYTES_H_INC
2#define ZSERIO_BYTES_H_INC
3
4#include <algorithm>
5#include <cstdint>
6#include <string_view>
7#include <vector>
8
9#include "zserio/BitSize.h"
10#include "zserio/Span.h"
11#include "zserio/Traits.h"
12
13namespace zserio
14{
15
19template <typename ALLOC = std::allocator<uint8_t>>
20using BasicBytes = std::vector<uint8_t, ALLOC>;
21
26
31
32template <typename ALLOC>
34{
35 using type = BytesView;
36};
37
38inline bool operator==(const BytesView& lhs, const BytesView& rhs)
39{
40 return std::equal(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
41}
42
43inline bool operator!=(const BytesView& lhs, const BytesView& rhs)
44{
45 return !(lhs == rhs);
46}
47
48inline bool operator<(const BytesView& lhs, const BytesView& rhs)
49{
50 return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
51}
52
53inline bool operator>(const BytesView& lhs, const BytesView& rhs)
54{
55 return rhs < lhs;
56}
57
58inline bool operator<=(const BytesView& lhs, const BytesView& rhs)
59{
60 return !(rhs < lhs);
61}
62
63inline bool operator>=(const BytesView& lhs, const BytesView& rhs)
64{
65 return !(lhs < rhs);
66}
67
68namespace detail
69{
70
71void validate(BytesView stringValue, std::string_view fieldName);
72BitSize bitSizeOf(BytesView bytesValue, BitSize bitPosition = 0);
73BitSize initializeOffsets(BytesView bytesValue, BitSize bitPosition);
74
75} // namespace detail
76
77} // namespace zserio
78
79#endif // ZSERIO_BYTES_H_INC
Span< const uint8_t > BytesView
Definition Bytes.h:30
bool operator>(const BasicBitBufferView< ALLOC > &lhs, const BasicBitBufferView< ALLOC > &rhs)
Definition BitBuffer.h:526
bool operator==(const BasicBitBufferView< ALLOC > &lhs, const BasicBitBufferView< ALLOC > &rhs)
Definition BitBuffer.h:508
unsigned int BitSize
Definition BitSize.h:8
std::vector< uint8_t, ALLOC > BasicBytes
Definition Bytes.h:20
bool operator<(const BasicBitBufferView< ALLOC > &lhs, const BasicBitBufferView< ALLOC > &rhs)
Definition BitBuffer.h:520
bool operator<=(const BasicBitBufferView< ALLOC > &lhs, const BasicBitBufferView< ALLOC > &rhs)
Definition BitBuffer.h:532
bool operator>=(const BasicBitBufferView< ALLOC > &lhs, const BasicBitBufferView< ALLOC > &rhs)
Definition BitBuffer.h:538
bool operator!=(const BasicBitBufferView< ALLOC > &lhs, const BasicBitBufferView< ALLOC > &rhs)
Definition BitBuffer.h:514