-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsegmenter.hpp
More file actions
53 lines (37 loc) · 1.19 KB
/
segmenter.hpp
File metadata and controls
53 lines (37 loc) · 1.19 KB
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
// Copyright 2020 DriveX.Tech. All rights reserved.
//
// Licensed under the License.
#pragma once
#ifndef _SEGMENTER_HPP_
#define _SEGMENTER_HPP_
#include <vector>
#include "types/types.h"
class Segmenter {
public:
typedef enum {
CONTINUE,
FAILED,
SUCCESSFUL,
} Status;
public:
Segmenter(dxt_common::WORD data_chunk_length = 180);
~Segmenter();
void reset();
bool set_data_chunk_length(dxt_common::WORD data_chunk_length);
static bool test_is_started(const std::vector<dxt_common::BYTE>& seger);
static bool test_is_finished(const std::vector<dxt_common::BYTE>& seger);
bool skip(dxt_common::WORD len);
Status try_pack(std::vector<dxt_common::BYTE>& seger);
Status pack(std::vector<dxt_common::BYTE>& seger);
Status try_unpack(const std::vector<dxt_common::BYTE>& seger);
Status unpack(const std::vector<dxt_common::BYTE>& seger);
public:
std::vector<dxt_common::BYTE> seger_data;
public:
static const dxt_common::WORD SEGMENTER_HDER_LEN = 5; // segment header length 5B
private:
dxt_common::WORD max_seger_length, max_seger_payload_length;
dxt_common::BYTE seger_ind;
dxt_common::WORD seger_off;
};
#endif