diff options
Diffstat (limited to '')
| -rw-r--r-- | c++-libbu++/src/object.cpp | 19 | ||||
| -rw-r--r-- | c++-libbu++/src/object.h | 3 |
2 files changed, 22 insertions, 0 deletions
diff --git a/c++-libbu++/src/object.cpp b/c++-libbu++/src/object.cpp index 61471b9..7cd50e6 100644 --- a/c++-libbu++/src/object.cpp +++ b/c++-libbu++/src/object.cpp | |||
| @@ -15,10 +15,14 @@ | |||
| 15 | #include "gats/dictionary.h" | 15 | #include "gats/dictionary.h" |
| 16 | #include "gats/null.h" | 16 | #include "gats/null.h" |
| 17 | 17 | ||
| 18 | #include "gats/gatsstream.h" | ||
| 19 | |||
| 18 | #include <stdlib.h> | 20 | #include <stdlib.h> |
| 19 | 21 | ||
| 20 | #include <bu/formatter.h> | 22 | #include <bu/formatter.h> |
| 21 | #include <bu/stream.h> | 23 | #include <bu/stream.h> |
| 24 | #include <bu/membuf.h> | ||
| 25 | #include <bu/staticmembuf.h> | ||
| 22 | 26 | ||
| 23 | #include <bu/sio.h> | 27 | #include <bu/sio.h> |
| 24 | using namespace Bu; | 28 | using namespace Bu; |
| @@ -31,6 +35,21 @@ Gats::Object::~Object() | |||
| 31 | { | 35 | { |
| 32 | } | 36 | } |
| 33 | 37 | ||
| 38 | Bu::String Gats::Object::toPacket() | ||
| 39 | { | ||
| 40 | Bu::MemBuf mbOut; | ||
| 41 | Gats::GatsStream gsOut( mbOut ); | ||
| 42 | gsOut.writeObject( this ); | ||
| 43 | return mbOut.getString(); | ||
| 44 | } | ||
| 45 | |||
| 46 | Gats::Object *Gats::Object::fromPacket( const Bu::String &sData ) | ||
| 47 | { | ||
| 48 | Bu::StaticMemBuf mbIn( sData.getStr(), sData.getSize() ); | ||
| 49 | Gats::GatsStream gsIn( mbIn ); | ||
| 50 | return gsIn.readObject(); | ||
| 51 | } | ||
| 52 | |||
| 34 | Gats::Object *Gats::Object::read( Bu::Stream &rIn ) | 53 | Gats::Object *Gats::Object::read( Bu::Stream &rIn ) |
| 35 | { | 54 | { |
| 36 | char buf; | 55 | char buf; |
diff --git a/c++-libbu++/src/object.h b/c++-libbu++/src/object.h index 62da7c1..859e126 100644 --- a/c++-libbu++/src/object.h +++ b/c++-libbu++/src/object.h | |||
| @@ -44,6 +44,9 @@ namespace Gats | |||
| 44 | virtual void read( Bu::Stream &rIn, char cType )=0; | 44 | virtual void read( Bu::Stream &rIn, char cType )=0; |
| 45 | virtual Object *clone() const=0; | 45 | virtual Object *clone() const=0; |
| 46 | 46 | ||
| 47 | Bu::String toPacket(); | ||
| 48 | static Object *fromPacket( const Bu::String &sData ); | ||
| 49 | |||
| 47 | static Object *read( Bu::Stream &rIn ); | 50 | static Object *read( Bu::Stream &rIn ); |
| 48 | static Object *strToGats( const Bu::String &sStr ); | 51 | static Object *strToGats( const Bu::String &sStr ); |
| 49 | 52 | ||
