diff options
author | Mike Buland <mbuland@penny-arcade.com> | 2021-09-27 08:04:28 -0700 |
---|---|---|
committer | Mike Buland <mbuland@penny-arcade.com> | 2021-09-27 08:04:28 -0700 |
commit | 7ebfdb3e7b71fdd315032adb0854e28f0073e1f7 (patch) | |
tree | a69ac57986342792cc76e2759091e855b3255ca8 /c++-libbu++ | |
parent | 701b05de4d2e79afd88ef8ddf93ba0fcc0eb5b14 (diff) | |
download | libgats-7ebfdb3e7b71fdd315032adb0854e28f0073e1f7.tar.gz libgats-7ebfdb3e7b71fdd315032adb0854e28f0073e1f7.tar.bz2 libgats-7ebfdb3e7b71fdd315032adb0854e28f0073e1f7.tar.xz libgats-7ebfdb3e7b71fdd315032adb0854e28f0073e1f7.zip |
Added explicit assignment/comparison operators.
Added = and == to all primitive types, not to the container types
(yet?).
Diffstat (limited to 'c++-libbu++')
-rw-r--r-- | c++-libbu++/src/boolean.cpp | 24 | ||||
-rw-r--r-- | c++-libbu++/src/boolean.h | 5 | ||||
-rw-r--r-- | c++-libbu++/src/float.cpp | 22 | ||||
-rw-r--r-- | c++-libbu++/src/float.h | 5 | ||||
-rw-r--r-- | c++-libbu++/src/integer.cpp | 22 | ||||
-rw-r--r-- | c++-libbu++/src/integer.h | 5 | ||||
-rw-r--r-- | c++-libbu++/src/string.cpp | 33 | ||||
-rw-r--r-- | c++-libbu++/src/string.h | 7 |
8 files changed, 123 insertions, 0 deletions
diff --git a/c++-libbu++/src/boolean.cpp b/c++-libbu++/src/boolean.cpp index e442c2c..d4702a5 100644 --- a/c++-libbu++/src/boolean.cpp +++ b/c++-libbu++/src/boolean.cpp | |||
@@ -54,6 +54,30 @@ void Gats::Boolean::read( Bu::Stream &rIn, char cType ) | |||
54 | } | 54 | } |
55 | } | 55 | } |
56 | 56 | ||
57 | Gats::Boolean &Gats::Boolean::operator=( const Gats::Boolean &rhs ) | ||
58 | { | ||
59 | bVal = rhs.bVal; | ||
60 | |||
61 | return *this; | ||
62 | } | ||
63 | |||
64 | Gats::Boolean &Gats::Boolean::operator=( bool rhs ) | ||
65 | { | ||
66 | bVal = rhs; | ||
67 | |||
68 | return *this; | ||
69 | } | ||
70 | |||
71 | bool Gats::Boolean::operator==( const Gats::Boolean &rhs ) const | ||
72 | { | ||
73 | return bVal == rhs.bVal; | ||
74 | } | ||
75 | |||
76 | bool Gats::Boolean::operator==( bool rhs ) const | ||
77 | { | ||
78 | return bVal == rhs; | ||
79 | } | ||
80 | |||
57 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Boolean &b ) | 81 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Boolean &b ) |
58 | { | 82 | { |
59 | return f << "(bool) " << b.getValue(); | 83 | return f << "(bool) " << b.getValue(); |
diff --git a/c++-libbu++/src/boolean.h b/c++-libbu++/src/boolean.h index 2fed713..ac01762 100644 --- a/c++-libbu++/src/boolean.h +++ b/c++-libbu++/src/boolean.h | |||
@@ -27,6 +27,11 @@ namespace Gats | |||
27 | virtual void write( Bu::Stream &rOut ) const; | 27 | virtual void write( Bu::Stream &rOut ) const; |
28 | virtual void read( Bu::Stream &rIn, char cType ); | 28 | virtual void read( Bu::Stream &rIn, char cType ); |
29 | 29 | ||
30 | Gats::Boolean &operator=( const Gats::Boolean &rhs ); | ||
31 | Gats::Boolean &operator=( bool rhs ); | ||
32 | bool operator==( const Gats::Boolean &rhs ) const; | ||
33 | bool operator==( bool rhs ) const; | ||
34 | |||
30 | private: | 35 | private: |
31 | bool bVal; | 36 | bool bVal; |
32 | }; | 37 | }; |
diff --git a/c++-libbu++/src/float.cpp b/c++-libbu++/src/float.cpp index c011794..409efd7 100644 --- a/c++-libbu++/src/float.cpp +++ b/c++-libbu++/src/float.cpp | |||
@@ -130,6 +130,28 @@ void Gats::Float::read( Bu::Stream &rIn, char cType ) | |||
130 | } | 130 | } |
131 | } | 131 | } |
132 | 132 | ||
133 | Gats::Float &Gats::Float::operator=( const Gats::Float &rhs ) | ||
134 | { | ||
135 | fVal = rhs.fVal; | ||
136 | return *this; | ||
137 | } | ||
138 | |||
139 | Gats::Float &Gats::Float::operator=( float &rhs ) | ||
140 | { | ||
141 | fVal = rhs; | ||
142 | return *this; | ||
143 | } | ||
144 | |||
145 | bool Gats::Float::operator==( const Gats::Float &rhs ) const | ||
146 | { | ||
147 | return fVal == rhs.fVal; | ||
148 | } | ||
149 | |||
150 | bool Gats::Float::operator==( float rhs ) const | ||
151 | { | ||
152 | return fVal == rhs; | ||
153 | } | ||
154 | |||
133 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Float &flt ) | 155 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Float &flt ) |
134 | { | 156 | { |
135 | return f << "(float) " << flt.getValue(); | 157 | return f << "(float) " << flt.getValue(); |
diff --git a/c++-libbu++/src/float.h b/c++-libbu++/src/float.h index 9aab0a5..0e42f76 100644 --- a/c++-libbu++/src/float.h +++ b/c++-libbu++/src/float.h | |||
@@ -29,6 +29,11 @@ namespace Gats | |||
29 | virtual void write( Bu::Stream &rOut ) const; | 29 | virtual void write( Bu::Stream &rOut ) const; |
30 | virtual void read( Bu::Stream &rIn, char cType ); | 30 | virtual void read( Bu::Stream &rIn, char cType ); |
31 | 31 | ||
32 | Gats::Float &operator=( const Gats::Float &rhs ); | ||
33 | Gats::Float &operator=( float &rhs ); | ||
34 | bool operator==( const Gats::Float &rhs ) const; | ||
35 | bool operator==( float rhs ) const; | ||
36 | |||
32 | private: | 37 | private: |
33 | double fVal; | 38 | double fVal; |
34 | mutable Bu::String sWriteCache; | 39 | mutable Bu::String sWriteCache; |
diff --git a/c++-libbu++/src/integer.cpp b/c++-libbu++/src/integer.cpp index f63dd37..1f10279 100644 --- a/c++-libbu++/src/integer.cpp +++ b/c++-libbu++/src/integer.cpp | |||
@@ -39,6 +39,28 @@ void Gats::Integer::read( Bu::Stream &rIn, char cType ) | |||
39 | readPackedInt( rIn, iVal ); | 39 | readPackedInt( rIn, iVal ); |
40 | } | 40 | } |
41 | 41 | ||
42 | Gats::Integer &Gats::Integer::operator=( const Gats::Integer &rhs ) | ||
43 | { | ||
44 | iVal = rhs.iVal; | ||
45 | return *this; | ||
46 | } | ||
47 | |||
48 | Gats::Integer &Gats::Integer::operator=( int64_t rhs ) | ||
49 | { | ||
50 | iVal = rhs; | ||
51 | return *this; | ||
52 | } | ||
53 | |||
54 | bool Gats::Integer::operator==( const Gats::Integer &rhs ) | ||
55 | { | ||
56 | return iVal == rhs.iVal; | ||
57 | } | ||
58 | |||
59 | bool Gats::Integer::operator==( int64_t rhs ) | ||
60 | { | ||
61 | return iVal == rhs; | ||
62 | } | ||
63 | |||
42 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Integer &i ) | 64 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Integer &i ) |
43 | { | 65 | { |
44 | return f << "(int) " << i.getValue(); | 66 | return f << "(int) " << i.getValue(); |
diff --git a/c++-libbu++/src/integer.h b/c++-libbu++/src/integer.h index d1ef3aa..e0a8d26 100644 --- a/c++-libbu++/src/integer.h +++ b/c++-libbu++/src/integer.h | |||
@@ -31,6 +31,11 @@ namespace Gats | |||
31 | virtual void write( Bu::Stream &rOut ) const; | 31 | virtual void write( Bu::Stream &rOut ) const; |
32 | virtual void read( Bu::Stream &rIn, char cType ); | 32 | virtual void read( Bu::Stream &rIn, char cType ); |
33 | 33 | ||
34 | Gats::Integer &operator=( const Gats::Integer &rhs ); | ||
35 | Gats::Integer &operator=( int64_t rhs ); | ||
36 | bool operator==( const Gats::Integer &rhs ); | ||
37 | bool operator==( int64_t rhs ); | ||
38 | |||
34 | template<typename itype> | 39 | template<typename itype> |
35 | static void readPackedInt( Bu::Stream &rStream, itype &rOut ) | 40 | static void readPackedInt( Bu::Stream &rStream, itype &rOut ) |
36 | { | 41 | { |
diff --git a/c++-libbu++/src/string.cpp b/c++-libbu++/src/string.cpp index f329f41..32018b8 100644 --- a/c++-libbu++/src/string.cpp +++ b/c++-libbu++/src/string.cpp | |||
@@ -65,6 +65,39 @@ void Gats::String::read( Bu::Stream &rIn, char cType ) | |||
65 | rIn.read( getStr(), iSize ); | 65 | rIn.read( getStr(), iSize ); |
66 | } | 66 | } |
67 | 67 | ||
68 | Gats::String &Gats::String::operator=( const char *s ) | ||
69 | { | ||
70 | Bu::String::operator=( s ); | ||
71 | return *this; | ||
72 | } | ||
73 | |||
74 | Gats::String &Gats::String::operator=( const Gats::String &s ) | ||
75 | { | ||
76 | Bu::String::operator=( s ); | ||
77 | return *this; | ||
78 | } | ||
79 | |||
80 | Gats::String &Gats::String::operator=( const Bu::String &s ) | ||
81 | { | ||
82 | Bu::String::operator=( s ); | ||
83 | return *this; | ||
84 | } | ||
85 | |||
86 | bool Gats::String::operator==( const char *s ) const | ||
87 | { | ||
88 | return Bu::String::operator==( s ); | ||
89 | } | ||
90 | |||
91 | bool Gats::String::operator==( const Gats::String &s ) const | ||
92 | { | ||
93 | return Bu::String::operator==( s ); | ||
94 | } | ||
95 | |||
96 | bool Gats::String::operator==( const Bu::String &s ) const | ||
97 | { | ||
98 | return Bu::String::operator==( s ); | ||
99 | } | ||
100 | |||
68 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::String &s ) | 101 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::String &s ) |
69 | { | 102 | { |
70 | for( Gats::String::const_iterator i = s.begin(); i; i++ ) | 103 | for( Gats::String::const_iterator i = s.begin(); i; i++ ) |
diff --git a/c++-libbu++/src/string.h b/c++-libbu++/src/string.h index b37137e..eae60e3 100644 --- a/c++-libbu++/src/string.h +++ b/c++-libbu++/src/string.h | |||
@@ -30,6 +30,13 @@ namespace Gats | |||
30 | virtual void write( Bu::Stream &rOut ) const; | 30 | virtual void write( Bu::Stream &rOut ) const; |
31 | virtual void read( Bu::Stream &rIn, char cType ); | 31 | virtual void read( Bu::Stream &rIn, char cType ); |
32 | 32 | ||
33 | Gats::String &operator=( const char *s ); | ||
34 | Gats::String &operator=( const Gats::String &s ); | ||
35 | Gats::String &operator=( const Bu::String &s ); | ||
36 | bool operator==( const char *s ) const; | ||
37 | bool operator==( const Gats::String &s ) const; | ||
38 | bool operator==( const Bu::String &s ) const; | ||
39 | |||
33 | private: | 40 | private: |
34 | }; | 41 | }; |
35 | }; | 42 | }; |