From 2de3693dd24463c5a02b9308ddfd674f58bac7c1 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 10 Jul 2007 00:19:19 +0000 Subject: Fixed the atom, it wasn't copying from other atoms properly. --- src/atom.h | 19 +++++++++++++++++++ src/tests/fstratsptr.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 src/tests/fstratsptr.cpp (limited to 'src') diff --git a/src/atom.h b/src/atom.h index fad47eb..ecda2a0 100644 --- a/src/atom.h +++ b/src/atom.h @@ -22,6 +22,18 @@ namespace Bu { } + Atom( const MyType &oth ) : + pData( NULL ) + { + set( *oth.pData ); + } + + Atom( const t &oth ) : + pData( NULL ) + { + set( oth ); + } + virtual ~Atom() { clear(); @@ -83,6 +95,13 @@ namespace Bu return *this; } + + MyType &operator =( const MyType &oth ) + { + set( *oth.pData ); + + return *this; + } t *operator ->() { diff --git a/src/tests/fstratsptr.cpp b/src/tests/fstratsptr.cpp new file mode 100644 index 0000000..343f682 --- /dev/null +++ b/src/tests/fstratsptr.cpp @@ -0,0 +1,46 @@ +#include "bu/fstring.h" +#include "bu/atom.h" +#include "bu/sptr.h" + +class Person +{ +public: + Person(){}; + virtual ~Person(){}; + + Bu::Atom sFirstName; + Bu::Atom sLastName; +}; + +typedef Bu::SPtr PersonPtr; + +void Swap(PersonPtr one, PersonPtr two) +{ + PersonPtr three(new Person); + three->sFirstName = one->sFirstName; + three->sLastName = two->sLastName; + + printf( + "%s %s\n", + three->sFirstName->c_str(), + three->sLastName->c_str() ); +} + +int main() +{ +/* PersonPtr one(new Person); + PersonPtr two(new Person); + one->sFirstName = "Bob"; + one->sLastName = "Smith"; + two->sFirstName = "Fred"; + two->sLastName = "Carpenter"; + + Swap(one, two); +*/ + + Bu::Atom sOne, sTwo; + sOne = "Hello"; + sTwo = sOne; + + return 0; +} -- cgit v1.2.3