MCPcopy Create free account
hub / github.com/apache/qpid-proton / byte_array

Class byte_array

cpp/include/proton/byte_array.hpp:45–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43/// Used to represent fixed-sized data types that don't have a natural
44/// C++ representation as an array of bytes.
45template <size_t N> class byte_array : private internal::comparable<byte_array<N> > {
46 public:
47 /// @name Sequence container typedefs
48 /// @{
49 typedef uint8_t value_type;
50 typedef value_type* pointer;
51 typedef const value_type* const_pointer;
52 typedef value_type& reference;
53 typedef const value_type& const_reference;
54 typedef value_type* iterator;
55 typedef const value_type* const_iterator;
56 typedef std::size_t size_type;
57 typedef std::ptrdiff_t difference_type;
58 typedef std::reverse_iterator<iterator> reverse_iterator;
59 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
60 /// @}
61
62 /// Zero-initialized byte array
63 byte_array() { std::fill(bytes_, bytes_+N, '\0'); }
64
65 /// Size of the array
66 static size_t size() { return N; }
67
68 /// @name Array operators
69 /// @{
70 value_type* begin() { return bytes_; }
71 value_type* end() { return bytes_+N; }
72 value_type& operator[](size_t i) { return bytes_[i]; }
73
74 const value_type* begin() const { return bytes_; }
75 const value_type* end() const { return bytes_+N; }
76 const value_type& operator[](size_t i) const { return bytes_[i]; }
77 /// @}
78
79 /// @name Comparison operators
80 /// @{
81 friend bool operator==(const byte_array& x, const byte_array& y) {
82 return std::equal(x.begin(), x.end(), y.begin());
83 }
84
85 friend bool operator<(const byte_array& x, const byte_array& y) {
86 return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
87 }
88 /// @}
89
90 /// Print byte array in hex
91 friend std::ostream& operator<<(std::ostream& o, const byte_array& b) {
92 internal::print_hex(o, b.begin(), b.size());
93 return o;
94 }
95
96 private:
97 value_type bytes_[N];
98};
99
100} // proton
101

Callers

nothing calls this directly

Calls 3

print_hexFunction · 0.85
beginMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected