diff options
author | sje <sje@4f64403b-2f21-0410-a795-97e2b3489a10> | 2007-06-27 17:05:05 +0000 |
---|---|---|
committer | sje <sje@4f64403b-2f21-0410-a795-97e2b3489a10> | 2007-06-27 17:05:05 +0000 |
commit | cbd22101bcff041e598aba668412d0a4232b58e3 (patch) | |
tree | 984f7afe9ec9246719e185288f8a2e96f4bc0665 /MySpace/NetMessage.h | |
parent | 353f66dee3f468aaf7cc0d0ab314df89ae56c428 (diff) |
git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@217 4f64403b-2f21-0410-a795-97e2b3489a10
Diffstat (limited to 'MySpace/NetMessage.h')
-rw-r--r-- | MySpace/NetMessage.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/MySpace/NetMessage.h b/MySpace/NetMessage.h new file mode 100644 index 0000000..8261302 --- /dev/null +++ b/MySpace/NetMessage.h @@ -0,0 +1,58 @@ +#ifndef _NET_MESSAGE_INC
+#define _NET_MESSAGE_INC
+
+#include "collection.h"
+
+class NMString {
+public:
+ NMString();
+ NMString(const NMString &other);
+ NMString(char *t);
+ virtual ~NMString();
+
+ const bool operator<(const NMString &other) const;
+ const bool operator==(const NMString &other) const;
+ NMString &operator=(const NMString &other);
+
+ char *text;
+};
+
+class NetMessage: public Map<NMString, NMString> {
+public:
+ NetMessage();
+ virtual ~NetMessage();
+
+ 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);
+
+ 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 > {
+public:
+ ClientNetMessage();
+ virtual ~ClientNetMessage();
+
+ int ClientNetMessage::make_packet(char *buff, int size);
+
+ void add_string(char *key, char *buff);
+ void add_data(char *key, char *buff, int size);
+ void add_int(char *key, int i);
+
+ static char *escape(char *val);
+};
+
+#endif
|