aboutsummaryrefslogtreecommitdiff
path: root/c++-libbu++/src/object.h
diff options
context:
space:
mode:
Diffstat (limited to 'c++-libbu++/src/object.h')
-rw-r--r--c++-libbu++/src/object.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/c++-libbu++/src/object.h b/c++-libbu++/src/object.h
new file mode 100644
index 0000000..2724189
--- /dev/null
+++ b/c++-libbu++/src/object.h
@@ -0,0 +1,55 @@
1#ifndef GATS_OBJECT_H
2#define GATS_OBJECT_H
3
4#include <bu/string.h>
5
6namespace Bu
7{
8 class Stream;
9 class Formatter;
10};
11
12namespace Gats
13{
14 enum Type
15 {
16 typeDictionary,
17 typeList,
18 typeString,
19 typeInteger,
20 typeFloat,
21 typeBoolean,
22 typeNull
23 };
24
25 /**
26 * The baseclass for every type that can be stored in a packet.
27 */
28 class Object
29 {
30 public:
31 Object();
32 virtual ~Object();
33
34 virtual Type getType() const =0;
35
36 virtual void write( Bu::Stream &rOut ) const=0;
37 virtual void read( Bu::Stream &rIn, char cType )=0;
38 virtual Object *clone() const=0;
39
40 static Object *read( Bu::Stream &rIn );
41 static Object *strToGats( const Bu::String &sStr );
42
43 private:
44 static Object *strToGats( Bu::String::const_iterator &i );
45 static Bu::String token( Bu::String::const_iterator &i );
46 static void skipWs( Bu::String::const_iterator &i );
47 };
48
49 const char *typeToStr( Type t );
50};
51
52Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Object &obj );
53Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Type &t );
54
55#endif