blob: 7a2d43454dd6c4a1bea5f1e6ac06146ea8c16d7f (
plain)
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
|
/*
* BinTreeNodeReader.h
*
* Created on: 26/06/2012
* Author: Antonio
*/
#ifndef BINTREENODEREADER_H_
#define BINTREENODEREADER_H_
#include "ProtocolTreeNode.h"
#include "ISocketConnection.h"
#include "ByteArray.h"
#include "WAConnection.h"
#include <string>
#include <vector>
#include <map>
#define BUFFER_SIZE 512
class WAConnection;
enum ReadType {STRING, ARRAY};
class ReadData {
public:
ReadData() {};
virtual ~ReadData() {};
ReadType type;
void * data;
};
class BinTreeNodeReader {
private:
ISocketConnection *rawIn;
ByteArrayInputStream* in;
std::vector<unsigned char> buf;
int readSize;
WAConnection *conn;
ProtocolTreeNode* nextTreeInternal();
bool isListTag(int b);
void decodeStream(int flags, int offset, int length);
std::map<string,string>* readAttributes(int attribCount);
std::vector<ProtocolTreeNode*>* readList(int token);
int readListSize(int token);
std::vector<ProtocolTreeNode*>* readList();
ReadData* readString();
ReadData* readString(int token);
static void fillArray(std::vector<unsigned char>& buff, int len, ByteArrayInputStream* in);
static void fillArray(std::vector<unsigned char>& buff, int len, ISocketConnection *in);
std::string* objectAsString(ReadData* o);
std::string* readStringAsString();
std::string* readStringAsString(int token);
void getTopLevelStream();
static int readInt8(ByteArrayInputStream* in);
static int readInt8(ISocketConnection *in);
static int readInt16(ByteArrayInputStream* in);
static int readInt16(ISocketConnection *in);
static int readInt24(ByteArrayInputStream* in);
static int readInt24(ISocketConnection *in);
public:
BinTreeNodeReader(WAConnection* conn, ISocketConnection* connection);
~BinTreeNodeReader();
ProtocolTreeNode* nextTree();
void streamStart();
};
#endif /* BINTREENODEREADER_H_ */
|