-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodec.h
More file actions
53 lines (37 loc) · 843 Bytes
/
codec.h
File metadata and controls
53 lines (37 loc) · 843 Bytes
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
46
47
48
49
50
51
52
53
//
// Created by bob on 11/5/19.
//
#ifndef _CODEC_H
#define _CODEC_H
#include <cstdint>
const unsigned int CODEC_BUF_SIZE = 16;
class Codec64 {
public:
Codec64();
~Codec64() = default;
bool getEncodedChar(uint8_t &ch);
bool putEncodedChar(uint8_t ch);
void put8(uint8_t n);
void put16(uint16_t n);
void put32(uint32_t n);
void put64(uint64_t n);
bool get8(uint8_t &n);
bool get16(uint16_t &n);
bool get32(uint32_t &n);
bool get64(uint64_t &n);
void beginEncode();
void beginDecode();
void endEncode();
void endDecode();
private:
uint8_t
inBuffer[CODEC_BUF_SIZE]{},
outBuffer[CODEC_BUF_SIZE]{};
uint32_t
inHead,inTail,inCount,
outHead,outTail,outCount;
bool
isEncoding,
isDecoding;
};
#endif //_CODEC_H