-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
buffer_in.h
45 lines (32 loc) · 1000 Bytes
/
buffer_in.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once
#include <stdint.h>
#include <string>
#include <vector>
class buffer_in
{
private:
const uint8_t *p { nullptr };
int size { 0 };
mutable int o { 0 };
const uint8_t * get_pointer() const { return p; };
public:
buffer_in();
buffer_in(const uint8_t *p, const int size);
buffer_in(const buffer_in & b);
virtual ~buffer_in();
uint8_t get_net_byte();
uint16_t get_net_short(); // 2 bytes
uint32_t get_net_long(); // 4 bytes
uint64_t get_net_long_long(); // 8 bytes
float get_net_float();
double get_net_double();
const uint8_t * get_bytes(const int len) const;
int get_size() const { return size; };
buffer_in get_segment(const int len);
std::string get_string(const int len);
void seek(const int len);
bool end_reached() const;
int get_n_bytes_left() const;
const std::vector<uint8_t> peek() const;
};
uint64_t get_variable_size_integer(buffer_in & data_source, const int len);