summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid <david@xagasoft.com>2007-07-10 00:19:19 +0000
committerDavid <david@xagasoft.com>2007-07-10 00:19:19 +0000
commit2de3693dd24463c5a02b9308ddfd674f58bac7c1 (patch)
treeaf9bd21a242d6372f85b602cae425659dc8e20d7
parente3287beb03915aea7f2133147cb7b1d766daf079 (diff)
downloadlibbu++-2de3693dd24463c5a02b9308ddfd674f58bac7c1.tar.gz
libbu++-2de3693dd24463c5a02b9308ddfd674f58bac7c1.tar.bz2
libbu++-2de3693dd24463c5a02b9308ddfd674f58bac7c1.tar.xz
libbu++-2de3693dd24463c5a02b9308ddfd674f58bac7c1.zip
Fixed the atom, it wasn't copying from other atoms properly.
-rw-r--r--src/atom.h19
-rw-r--r--src/tests/fstratsptr.cpp46
2 files changed, 65 insertions, 0 deletions
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
22 { 22 {
23 } 23 }
24 24
25 Atom( const MyType &oth ) :
26 pData( NULL )
27 {
28 set( *oth.pData );
29 }
30
31 Atom( const t &oth ) :
32 pData( NULL )
33 {
34 set( oth );
35 }
36
25 virtual ~Atom() 37 virtual ~Atom()
26 { 38 {
27 clear(); 39 clear();
@@ -83,6 +95,13 @@ namespace Bu
83 95
84 return *this; 96 return *this;
85 } 97 }
98
99 MyType &operator =( const MyType &oth )
100 {
101 set( *oth.pData );
102
103 return *this;
104 }
86 105
87 t *operator ->() 106 t *operator ->()
88 { 107 {
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 @@
1#include "bu/fstring.h"
2#include "bu/atom.h"
3#include "bu/sptr.h"
4
5class Person
6{
7public:
8 Person(){};
9 virtual ~Person(){};
10
11 Bu::Atom<Bu::FString> sFirstName;
12 Bu::Atom<Bu::FString> sLastName;
13};
14
15typedef Bu::SPtr<Person> PersonPtr;
16
17void Swap(PersonPtr one, PersonPtr two)
18{
19 PersonPtr three(new Person);
20 three->sFirstName = one->sFirstName;
21 three->sLastName = two->sLastName;
22
23 printf(
24 "%s %s\n",
25 three->sFirstName->c_str(),
26 three->sLastName->c_str() );
27}
28
29int main()
30{
31/* PersonPtr one(new Person);
32 PersonPtr two(new Person);
33 one->sFirstName = "Bob";
34 one->sLastName = "Smith";
35 two->sFirstName = "Fred";
36 two->sLastName = "Carpenter";
37
38 Swap(one, two);
39*/
40
41 Bu::Atom<Bu::FString> sOne, sTwo;
42 sOne = "Hello";
43 sTwo = sOne;
44
45 return 0;
46}