From 74dd68ad611d15abf16a65c36a7cfd3f4492930a Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 9 Nov 2012 16:25:22 +0000 Subject: Made the repo less libbu++-centric. --- c++-libbu++/src/object.h | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 c++-libbu++/src/object.h (limited to 'c++-libbu++/src/object.h') 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 @@ +#ifndef GATS_OBJECT_H +#define GATS_OBJECT_H + +#include + +namespace Bu +{ + class Stream; + class Formatter; +}; + +namespace Gats +{ + enum Type + { + typeDictionary, + typeList, + typeString, + typeInteger, + typeFloat, + typeBoolean, + typeNull + }; + + /** + * The baseclass for every type that can be stored in a packet. + */ + class Object + { + public: + Object(); + virtual ~Object(); + + virtual Type getType() const =0; + + virtual void write( Bu::Stream &rOut ) const=0; + virtual void read( Bu::Stream &rIn, char cType )=0; + virtual Object *clone() const=0; + + static Object *read( Bu::Stream &rIn ); + static Object *strToGats( const Bu::String &sStr ); + + private: + static Object *strToGats( Bu::String::const_iterator &i ); + static Bu::String token( Bu::String::const_iterator &i ); + static void skipWs( Bu::String::const_iterator &i ); + }; + + const char *typeToStr( Type t ); +}; + +Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Object &obj ); +Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Type &t ); + +#endif -- cgit v1.2.3