diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2008-09-11 21:09:31 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2008-09-11 21:09:31 +0000 |
| commit | 7ddeaa42e452a85e275649efa519fe0959210d12 (patch) | |
| tree | ee83a1a5b8855d11855698ccd68b19241b3ec40d | |
| parent | 5dbc8f155b16759b4ebb82aceb3759c686489e3b (diff) | |
| download | libbu++-7ddeaa42e452a85e275649efa519fe0959210d12.tar.gz libbu++-7ddeaa42e452a85e275649efa519fe0959210d12.tar.bz2 libbu++-7ddeaa42e452a85e275649efa519fe0959210d12.tar.xz libbu++-7ddeaa42e452a85e275649efa519fe0959210d12.zip | |
Fixed some whacky old FBasicString hikinx. Basically it supports all the basic,
expected operators now, like plus. It was annoying without them.
Diffstat (limited to '')
| -rw-r--r-- | src/fstring.h | 20 | ||||
| -rw-r--r-- | src/unit/fstring.cpp | 38 |
2 files changed, 58 insertions, 0 deletions
diff --git a/src/fstring.h b/src/fstring.h index fb4bf55..93216a1 100644 --- a/src/fstring.h +++ b/src/fstring.h | |||
| @@ -492,6 +492,20 @@ namespace Bu | |||
| 492 | return (*this); | 492 | return (*this); |
| 493 | } | 493 | } |
| 494 | 494 | ||
| 495 | MyType operator +( const MyType &rRight ) | ||
| 496 | { | ||
| 497 | MyType ret( *this ); | ||
| 498 | ret.append( rRight ); | ||
| 499 | return ret; | ||
| 500 | } | ||
| 501 | |||
| 502 | MyType operator +( const chr *pRight ) | ||
| 503 | { | ||
| 504 | MyType ret( *this ); | ||
| 505 | ret.append( pRight ); | ||
| 506 | return ret; | ||
| 507 | } | ||
| 508 | |||
| 495 | /** | 509 | /** |
| 496 | * Reset your FString to this character array. | 510 | * Reset your FString to this character array. |
| 497 | *@param pData (const chr *) The character array to set your FString to. | 511 | *@param pData (const chr *) The character array to set your FString to. |
| @@ -1032,6 +1046,12 @@ namespace Bu | |||
| 1032 | 1046 | ||
| 1033 | template<> uint32_t __calcHashCode<FString>( const FString &k ); | 1047 | template<> uint32_t __calcHashCode<FString>( const FString &k ); |
| 1034 | template<> bool __cmpHashKeys<FString>( const FString &a, const FString &b ); | 1048 | template<> bool __cmpHashKeys<FString>( const FString &a, const FString &b ); |
| 1049 | template<class T> FBasicString<T> operator +( const T *pLeft, const FBasicString<T> &rRight ) | ||
| 1050 | { | ||
| 1051 | Bu::FBasicString<T> ret( pLeft ); | ||
| 1052 | ret.append( rRight ); | ||
| 1053 | return ret; | ||
| 1054 | } | ||
| 1035 | 1055 | ||
| 1036 | #ifdef BU_TRACE | 1056 | #ifdef BU_TRACE |
| 1037 | template<> void __tracer_format<FString>( const FString &v ); | 1057 | template<> void __tracer_format<FString>( const FString &v ); |
diff --git a/src/unit/fstring.cpp b/src/unit/fstring.cpp index c856b05..ea3342a 100644 --- a/src/unit/fstring.cpp +++ b/src/unit/fstring.cpp | |||
| @@ -20,6 +20,10 @@ public: | |||
| 20 | addTest( Unit::shared1 ); | 20 | addTest( Unit::shared1 ); |
| 21 | addTest( Unit::insert ); | 21 | addTest( Unit::insert ); |
| 22 | addTest( Unit::remove ); | 22 | addTest( Unit::remove ); |
| 23 | addTest( Unit::add1 ); | ||
| 24 | addTest( Unit::add2 ); | ||
| 25 | addTest( Unit::add3 ); | ||
| 26 | addTest( Unit::add4 ); | ||
| 23 | } | 27 | } |
| 24 | 28 | ||
| 25 | virtual ~Unit() | 29 | virtual ~Unit() |
| @@ -90,6 +94,40 @@ public: | |||
| 90 | a.remove( 5, 1 ); | 94 | a.remove( 5, 1 ); |
| 91 | unitTest( a = "abcdeghijklmnop" ); | 95 | unitTest( a = "abcdeghijklmnop" ); |
| 92 | } | 96 | } |
| 97 | |||
| 98 | void add1() | ||
| 99 | { | ||
| 100 | Bu::FString a("hi there"); | ||
| 101 | Bu::FString b(", yeah!"); | ||
| 102 | Bu::FString c = a + b; | ||
| 103 | |||
| 104 | unitTest( c == "hi there, yeah!" ); | ||
| 105 | } | ||
| 106 | |||
| 107 | void add2() | ||
| 108 | { | ||
| 109 | Bu::FString a("hi there"); | ||
| 110 | Bu::FString c = a + ", yeah!"; | ||
| 111 | |||
| 112 | unitTest( c == "hi there, yeah!" ); | ||
| 113 | } | ||
| 114 | |||
| 115 | void add3() | ||
| 116 | { | ||
| 117 | Bu::FString a("hi there"); | ||
| 118 | Bu::FString b(", yeah!"); | ||
| 119 | Bu::FString c = a + ", Mr. Man" + b; | ||
| 120 | |||
| 121 | unitTest( c == "hi there, Mr. Man, yeah!" ); | ||
| 122 | } | ||
| 123 | |||
| 124 | void add4() | ||
| 125 | { | ||
| 126 | Bu::FString b(", yeah!"); | ||
| 127 | Bu::FString c = "hi there" + b; | ||
| 128 | |||
| 129 | unitTest( c == "hi there, yeah!" ); | ||
| 130 | } | ||
| 93 | }; | 131 | }; |
| 94 | 132 | ||
| 95 | int main( int argc, char *argv[] ) | 133 | int main( int argc, char *argv[] ) |
