-
Notifications
You must be signed in to change notification settings - Fork 1
/
data.h
86 lines (69 loc) · 1.69 KB
/
data.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef DATA_H_
#define DATA_H_
#include <string>
#include <vector>
#include <stdint.h>
class CWData
{
public:
char* getDataPtr(void);
unsigned long getDataSize(void);
void addInt(int ta);
void addUInt(unsigned int ta);
void addInt64(int64_t ta);
void addUInt64(uint64_t ta);
void addFloat(float ta);
void addDouble(double ta);
void addUShort(unsigned short ta);
void addString(const std::string& ta);
void addString2(const std::string& ta);
void addChar(char ta);
void addUChar(unsigned char ta);
void addVoidPtr(void *ptr);
void addBuffer(const char* buffer, size_t bsize);
void addVarInt(int64_t ta);
void clear();
void reserve(size_t count);
void resize(size_t count);
size_t capacity();
std::string releaseData()
{
return std::move(data);
}
protected:
std::string data;
};
class CRData
{
public:
CRData(const char* c,size_t datalength, bool pCopy=false);
CRData(const std::string *str);
CRData(void);
~CRData();
void set(const char* c,size_t datalength, bool pCopy=false);
bool getInt(int *ret);
bool getInt64(int64_t *ret);
bool getUInt(unsigned int *ret);
bool getFloat(float *ret);
bool getDouble(double *ret);
bool getUShort( unsigned short *ret);
bool getStr(std::string *ret);
bool getStr2(std::string *ret);
bool getChar(char *ret);
bool getUChar(unsigned char *ret);
bool getVoidPtr(void **ret);
bool getVarInt(int64_t* ret);
unsigned int getSize(void);
unsigned int getLeft(void);
unsigned int getStreampos(void);
void setStreampos(unsigned int spos);
const char *getDataPtr(void);
const char *getCurrDataPtr(void);
bool incrementPtr(unsigned int amount);
private:
const char* data;
size_t streampos;
size_t datalen;
bool copy;
};
#endif //DATA_H_