From f58a0b3a1f657124076b96ba092e1f69e88af263 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 18 Jun 2007 20:25:50 +0000 Subject: Added the atom class and did some more client work, it will close the socket now when the end has been reached. --- src/tests/atom.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/tests/atom.cpp (limited to 'src/tests/atom.cpp') diff --git a/src/tests/atom.cpp b/src/tests/atom.cpp new file mode 100644 index 0000000..cf076b1 --- /dev/null +++ b/src/tests/atom.cpp @@ -0,0 +1,17 @@ +#include "bu/atom.h" +#include +#include + +int main() +{ + Bu::Atom aInt; + Bu::Atom aStr; + + aStr.set("Hey there, dude"); + aInt.set( 55 ); + int me = aInt; + aInt = 12; + printf("%d, %d\n", aInt.get(), me ); + printf("%s\n", aStr.get() ); +} + -- cgit v1.2.3 From 8a7fed8386c152023ddae611fe274b966287370a Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 18 Jun 2007 22:49:39 +0000 Subject: Added more helper guys to atom, it seems weird, but I think it's ok... --- src/atom.h | 14 ++++++++++++++ src/tests/atom.cpp | 8 ++++++++ 2 files changed, 22 insertions(+) (limited to 'src/tests/atom.cpp') diff --git a/src/atom.h b/src/atom.h index f876274..a0469b6 100644 --- a/src/atom.h +++ b/src/atom.h @@ -84,6 +84,20 @@ namespace Bu return *this; } + t *operator ->() + { + if( !pData ) + throw Bu::ExceptionBase("Not set"); + return pData; + } + + t &operator *() + { + if( !pData ) + throw Bu::ExceptionBase("Not set"); + return *pData; + } + private: t *pData; talloc ta; diff --git a/src/tests/atom.cpp b/src/tests/atom.cpp index cf076b1..2077bfd 100644 --- a/src/tests/atom.cpp +++ b/src/tests/atom.cpp @@ -2,10 +2,18 @@ #include #include +typedef struct bob +{ + int a, b; +} bob; int main() { Bu::Atom aInt; Bu::Atom aStr; + Bu::Atom aBob; + + aBob = bob(); + aBob->a = 5; aStr.set("Hey there, dude"); aInt.set( 55 ); -- cgit v1.2.3