summaryrefslogtreecommitdiff
path: root/MySpace/NetMessage.h
diff options
context:
space:
mode:
Diffstat (limited to 'MySpace/NetMessage.h')
-rw-r--r--MySpace/NetMessage.h45
1 files changed, 31 insertions, 14 deletions
diff --git a/MySpace/NetMessage.h b/MySpace/NetMessage.h
index bae4ad7..4989f55 100644
--- a/MySpace/NetMessage.h
+++ b/MySpace/NetMessage.h
@@ -17,6 +17,32 @@ public:
char *text;
};
+class KeyValue: public Pair<NMString, NMString> {
+public:
+ KeyValue(const NMString &k, const NMString &v): Pair<NMString, NMString>(k, v) {}
+ KeyValue &operator=(const KeyValue &other) {
+ first = other.first;
+ second = other.second;
+ return *this;
+ }
+};
+
+class Dictionary: public LinkedList< KeyValue > {
+public:
+ Dictionary();
+ virtual ~Dictionary();
+
+ virtual int parse(char *data, int size);
+
+ bool get_string(char *key, char *buff, int buffsize);
+ int get_int(char *key);
+
+ virtual void add_string(char *key, char *buff);
+ void add_int(char *key, int i);
+
+ int make_body(char *buff, int size);
+};
+
class NetMessage: public Map<NMString, NMString> {
public:
NetMessage();
@@ -25,32 +51,23 @@ public:
int parse(char *data, int size);
bool get_string(char *key, char *buff, int buffsize);
- bool get_data(char *key, char *buff, int *size);
int get_int(char *key);
+ bool get_data(char *key, char *buff, int *size);
+ Dictionary get_dict(char *key);
static char *unescape_inplace(char *val);
};
-class KeyValue: public Pair<NMString, NMString> {
-public:
- KeyValue(const NMString &k, const NMString &v): Pair<NMString, NMString>(k, v) {}
- KeyValue &operator=(const KeyValue &other) {
- first = other.first;
- second = other.second;
- return *this;
- }
-};
-
-class ClientNetMessage: public LinkedList< KeyValue > {
+class ClientNetMessage: public Dictionary {
public:
ClientNetMessage();
virtual ~ClientNetMessage();
- int ClientNetMessage::make_packet(char *buff, int size);
+ int make_packet(char *buff, int size);
void add_string(char *key, char *buff);
bool add_data(char *key, char *buff, int size);
- void add_int(char *key, int i);
+ void add_dict(char *key, Dictionary &d);
static char *escape(char *val);
};