1 |
afaq |
1.1 |
#ifndef _Message_hpp_included_
|
2 |
|
|
#define _Message_hpp_included_
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
#include <string>
|
6 |
|
|
#include <vector>
|
7 |
|
|
#include <map>
|
8 |
|
|
|
9 |
|
|
#include "Util.hpp"
|
10 |
|
|
class Element {
|
11 |
|
|
private:
|
12 |
|
|
std::string key;
|
13 |
|
|
std::string value;
|
14 |
|
|
std::string type;
|
15 |
|
|
public:
|
16 |
|
|
Element(std::string key, std::string value, std::string type) {
|
17 |
|
|
this->key = key;
|
18 |
|
|
this->value = value;
|
19 |
|
|
this->type = type;
|
20 |
|
|
}
|
21 |
|
|
std::string getKey() {
|
22 |
|
|
return key;
|
23 |
|
|
}
|
24 |
|
|
std::string getValue() {
|
25 |
|
|
return value;
|
26 |
|
|
}
|
27 |
|
|
std::string getType() {
|
28 |
|
|
return type;
|
29 |
|
|
}
|
30 |
|
|
};
|
31 |
|
|
|
32 |
|
|
typedef std::vector<Element*> Data;
|
33 |
|
|
typedef Data::iterator DataIter;
|
34 |
|
|
typedef std::vector<Data*> VecData;
|
35 |
|
|
typedef VecData::iterator VecDataIter;
|
36 |
|
|
typedef std::map<std::string, VecData*> Map;
|
37 |
|
|
typedef Map::iterator MapIter;
|
38 |
|
|
typedef Map::value_type MsgEntry;
|
39 |
|
|
typedef std::vector<std::string>::iterator StrIter;
|
40 |
|
|
//typedef std::vector<Map*> VecMap;
|
41 |
|
|
//typedef VecMap::iterator VecMapIter;
|
42 |
|
|
|
43 |
|
|
class Message {
|
44 |
|
|
private:
|
45 |
|
|
//public:
|
46 |
|
|
std::string name;
|
47 |
|
|
std::string exception;
|
48 |
|
|
|
49 |
|
|
Util util;
|
50 |
|
|
|
51 |
|
|
Data data;
|
52 |
|
|
Map myMap;
|
53 |
|
|
typedef std::vector<Message*> VecMsg;
|
54 |
|
|
VecMsg vecMsg;
|
55 |
|
|
//VecMap vecMap;
|
56 |
|
|
|
57 |
|
|
int serializeData(std::string & message, DataIter b, DataIter e);
|
58 |
|
|
bool getKVT(std::string& key, std::string& value, std::string& type, std::vector<std::string>& tempTokens, StrIter i);
|
59 |
|
|
bool validateKVT(std::string& key, std::string& value, std::string& type);
|
60 |
|
|
public:
|
61 |
|
|
Message();
|
62 |
|
|
~Message();
|
63 |
|
|
void dispose();
|
64 |
|
|
void setName(std::string name);
|
65 |
|
|
void setException(std::string exception);
|
66 |
|
|
std::string getName();
|
67 |
|
|
std::string getException();
|
68 |
|
|
void addVecOfElement(Data* d);
|
69 |
|
|
void addElement(Element* e);
|
70 |
|
|
void addMsg(Message* m);
|
71 |
|
|
//void addNewElement(Element* e);
|
72 |
|
|
void appendToVec(Message& inMsg,std:: string listName);
|
73 |
|
|
void addVecOfVecOfElement(VecData* vd, std::string name);
|
74 |
|
|
Element* getElement(int index);
|
75 |
|
|
std::string getElementValue(std::string);
|
76 |
|
|
std::string getElementValue(std::string paramName, std::string listName, int index);
|
77 |
|
|
MapIter getMapIterBegin();
|
78 |
|
|
MapIter getMapIterEnd();
|
79 |
|
|
int getNoOfElements();
|
80 |
|
|
//std::string serialize();
|
81 |
|
|
int serialize(std::string & message);
|
82 |
|
|
int serializeOne(std::string & message);
|
83 |
|
|
//int deserialize(std::string message);
|
84 |
|
|
int deserialize(std::string & message);
|
85 |
|
|
int deserializeOne(std::string & message);
|
86 |
|
|
void tokenize(const std::string& str,
|
87 |
|
|
std::vector<std::string>& tokens,
|
88 |
|
|
const std::string& delimiters);
|
89 |
|
|
};
|
90 |
|
|
|
91 |
|
|
typedef std::vector<Message*> VecMsg;
|
92 |
|
|
typedef VecMsg::iterator VecMsgIter;
|
93 |
|
|
|
94 |
|
|
#endif
|
95 |
|
|
|