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(+) 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