Skip to content

Commit 1e4f109

Browse files
committed
ByteArray inherits std::vector<char> instead of std::vector<uint8_t>
1 parent 6d0b10e commit 1e4f109

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

vpr/src/server/bytearray.h

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,39 @@
33

44
#ifndef NO_SERVER
55

6-
#include <cstdint>
76
#include <vector>
87
#include <string>
98
#include <cstring>
109

1110
namespace comm {
1211

1312
/**
14-
* @brief ByteArray as a simple wrapper over std::vector<uint8_t>
13+
* @brief ByteArray as a simple wrapper over std::vector<char>
1514
*/
16-
class ByteArray : public std::vector<uint8_t> {
15+
class ByteArray : public std::vector<char> {
1716
public:
1817
static const std::size_t DEFAULT_SIZE_HINT = 1024;
1918

2019
ByteArray(const char* data)
21-
: std::vector<uint8_t>(reinterpret_cast<const uint8_t*>(data),
22-
reinterpret_cast<const uint8_t*>(data + std::strlen(data)))
20+
: std::vector<char>(data, data + std::strlen(data))
2321
{}
2422

2523
ByteArray(const char* data, std::size_t size)
26-
: std::vector<uint8_t>(reinterpret_cast<const uint8_t*>(data),
27-
reinterpret_cast<const uint8_t*>(data + size))
24+
: std::vector<char>(data, data + size)
2825
{}
2926

3027
ByteArray(std::size_t size_hint = DEFAULT_SIZE_HINT) {
3128
reserve(size_hint);
3229
}
3330

3431
template<typename Iterator>
35-
ByteArray(Iterator first, Iterator last): std::vector<uint8_t>(first, last) {}
32+
ByteArray(Iterator first, Iterator last): std::vector<char>(first, last) {}
3633

3734
void append(const ByteArray& appendix) {
3835
insert(end(), appendix.begin(), appendix.end());
3936
}
4037

41-
void append(uint8_t b) {
38+
void append(char b) {
4239
push_back(b);
4340
}
4441

@@ -72,8 +69,8 @@ class ByteArray : public std::vector<uint8_t> {
7269
template<typename T>
7370
static uint32_t calc_check_sum(const T& iterable) {
7471
uint32_t sum = 0;
75-
for (uint8_t c : iterable) {
76-
sum += static_cast<unsigned int>(c);
72+
for (char c : iterable) {
73+
sum += static_cast<unsigned int>(static_cast<unsigned char>(c));
7774
}
7875
return sum;
7976
}

0 commit comments

Comments
 (0)