diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/fbasicstring.h | 28 | ||||
-rw-r--r-- | src/list.h | 18 | ||||
-rw-r--r-- | src/unit/fstring.unit | 9 |
3 files changed, 41 insertions, 14 deletions
diff --git a/src/fbasicstring.h b/src/fbasicstring.h index cac7dd7..a532d69 100644 --- a/src/fbasicstring.h +++ b/src/fbasicstring.h | |||
@@ -999,7 +999,7 @@ namespace Bu | |||
999 | * Plus equals operator for FString. | 999 | * Plus equals operator for FString. |
1000 | *@param pData (const chr *) The data to append to your FString. | 1000 | *@param pData (const chr *) The data to append to your FString. |
1001 | */ | 1001 | */ |
1002 | MyType &operator +=( const chr *pData ) | 1002 | MyType &operator+=( const chr *pData ) |
1003 | { | 1003 | { |
1004 | append( pData ); | 1004 | append( pData ); |
1005 | 1005 | ||
@@ -1010,7 +1010,7 @@ namespace Bu | |||
1010 | * Plus equals operator for FString. | 1010 | * Plus equals operator for FString. |
1011 | *@param pData (const MyType &) The FString to append to your FString. | 1011 | *@param pData (const MyType &) The FString to append to your FString. |
1012 | */ | 1012 | */ |
1013 | MyType &operator +=( const MyType &rSrc ) | 1013 | MyType &operator+=( const MyType &rSrc ) |
1014 | { | 1014 | { |
1015 | if( rSrc.nLength == 0 ) | 1015 | if( rSrc.nLength == 0 ) |
1016 | return (*this); | 1016 | return (*this); |
@@ -1024,7 +1024,7 @@ namespace Bu | |||
1024 | * Plus equals operator for FString. | 1024 | * Plus equals operator for FString. |
1025 | *@param pData (const chr) The character to append to your FString. | 1025 | *@param pData (const chr) The character to append to your FString. |
1026 | */ | 1026 | */ |
1027 | MyType &operator +=( const chr cData ) | 1027 | MyType &operator+=( const chr cData ) |
1028 | { | 1028 | { |
1029 | if( pLast && pLast->nLength < nMinSize ) | 1029 | if( pLast && pLast->nLength < nMinSize ) |
1030 | { | 1030 | { |
@@ -1046,7 +1046,7 @@ namespace Bu | |||
1046 | *@param pData (const chr *) The character array to append to your | 1046 | *@param pData (const chr *) The character array to append to your |
1047 | * FString. | 1047 | * FString. |
1048 | */ | 1048 | */ |
1049 | MyType &operator =( const chr *pData ) | 1049 | MyType &operator=( const chr *pData ) |
1050 | { | 1050 | { |
1051 | clear(); | 1051 | clear(); |
1052 | append( pData ); | 1052 | append( pData ); |
@@ -1054,7 +1054,7 @@ namespace Bu | |||
1054 | return (*this); | 1054 | return (*this); |
1055 | } | 1055 | } |
1056 | 1056 | ||
1057 | MyType &operator =( const std::basic_string<chr> &rData ) | 1057 | MyType &operator=( const std::basic_string<chr> &rData ) |
1058 | { | 1058 | { |
1059 | clear(); | 1059 | clear(); |
1060 | append( rData.c_str(), rData.size() ); | 1060 | append( rData.c_str(), rData.size() ); |
@@ -1062,21 +1062,21 @@ namespace Bu | |||
1062 | return (*this); | 1062 | return (*this); |
1063 | } | 1063 | } |
1064 | 1064 | ||
1065 | MyType operator +( const MyType &rRight ) | 1065 | MyType operator+( const MyType &rRight ) const |
1066 | { | 1066 | { |
1067 | MyType ret( *this ); | 1067 | MyType ret( *this ); |
1068 | ret.append( rRight ); | 1068 | ret.append( rRight ); |
1069 | return ret; | 1069 | return ret; |
1070 | } | 1070 | } |
1071 | 1071 | ||
1072 | MyType operator +( const chr *pRight ) | 1072 | MyType operator+( const chr *pRight ) const |
1073 | { | 1073 | { |
1074 | MyType ret( *this ); | 1074 | MyType ret( *this ); |
1075 | ret.append( pRight ); | 1075 | ret.append( pRight ); |
1076 | return ret; | 1076 | return ret; |
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | MyType operator +( chr *pRight ) | 1079 | MyType operator+( chr *pRight ) const |
1080 | { | 1080 | { |
1081 | MyType ret( *this ); | 1081 | MyType ret( *this ); |
1082 | ret.append( pRight ); | 1082 | ret.append( pRight ); |
@@ -1171,7 +1171,7 @@ namespace Bu | |||
1171 | * Assignment operator. | 1171 | * Assignment operator. |
1172 | *@param rSrc (const MyType &) The FString to set your FString to. | 1172 | *@param rSrc (const MyType &) The FString to set your FString to. |
1173 | */ | 1173 | */ |
1174 | MyType &operator =( const MyType &rSrc ) | 1174 | MyType &operator=( const MyType &rSrc ) |
1175 | { | 1175 | { |
1176 | copyFrom( rSrc ); | 1176 | copyFrom( rSrc ); |
1177 | 1177 | ||
@@ -1183,7 +1183,7 @@ namespace Bu | |||
1183 | *@param pData (const chr *) The character array to compare your FString | 1183 | *@param pData (const chr *) The character array to compare your FString |
1184 | * to. | 1184 | * to. |
1185 | */ | 1185 | */ |
1186 | bool operator ==( const chr *pData ) const | 1186 | bool operator==( const chr *pData ) const |
1187 | { | 1187 | { |
1188 | if( pFirst == NULL ) { | 1188 | if( pFirst == NULL ) { |
1189 | if( pData == NULL ) | 1189 | if( pData == NULL ) |
@@ -1212,7 +1212,7 @@ namespace Bu | |||
1212 | * Equals comparison operator. | 1212 | * Equals comparison operator. |
1213 | *@param pData (const MyType &) The FString to compare your FString to. | 1213 | *@param pData (const MyType &) The FString to compare your FString to. |
1214 | */ | 1214 | */ |
1215 | bool operator ==( const MyType &pData ) const | 1215 | bool operator==( const MyType &pData ) const |
1216 | { | 1216 | { |
1217 | if( pFirst == pData.pFirst ) | 1217 | if( pFirst == pData.pFirst ) |
1218 | return true; | 1218 | return true; |
@@ -1239,7 +1239,7 @@ namespace Bu | |||
1239 | *@param pData (const chr *) The character array to compare your FString | 1239 | *@param pData (const chr *) The character array to compare your FString |
1240 | * to. | 1240 | * to. |
1241 | */ | 1241 | */ |
1242 | bool operator !=(const chr *pData ) const | 1242 | bool operator!=(const chr *pData ) const |
1243 | { | 1243 | { |
1244 | return !(*this == pData); | 1244 | return !(*this == pData); |
1245 | } | 1245 | } |
@@ -1248,7 +1248,7 @@ namespace Bu | |||
1248 | * Not equals comparison operator. | 1248 | * Not equals comparison operator. |
1249 | *@param pData (const MyType &) The FString to compare your FString to. | 1249 | *@param pData (const MyType &) The FString to compare your FString to. |
1250 | */ | 1250 | */ |
1251 | bool operator !=(const MyType &pData ) const | 1251 | bool operator!=(const MyType &pData ) const |
1252 | { | 1252 | { |
1253 | return !(*this == pData); | 1253 | return !(*this == pData); |
1254 | } | 1254 | } |
@@ -1759,7 +1759,7 @@ namespace Bu | |||
1759 | mutable chunkalloc aChunk; | 1759 | mutable chunkalloc aChunk; |
1760 | }; | 1760 | }; |
1761 | 1761 | ||
1762 | template<class T> FBasicString<T> operator +( const T *pLeft, const FBasicString<T> &rRight ) | 1762 | template<class T> FBasicString<T> operator+( const T *pLeft, const FBasicString<T> &rRight ) |
1763 | { | 1763 | { |
1764 | Bu::FBasicString<T> ret( pLeft ); | 1764 | Bu::FBasicString<T> ret( pLeft ); |
1765 | ret.append( rRight ); | 1765 | ret.append( rRight ); |
@@ -669,6 +669,24 @@ namespace Bu | |||
669 | long nSize; | 669 | long nSize; |
670 | cmpfunc cmp; | 670 | cmpfunc cmp; |
671 | }; | 671 | }; |
672 | |||
673 | class Formatter; | ||
674 | Formatter &operator<<( Formatter &rOut, char *sStr ); | ||
675 | Formatter &operator<<( Formatter &rOut, signed char c ); | ||
676 | template<typename value> | ||
677 | Formatter &operator<<( Formatter &f, const Bu::List<value> &l ) | ||
678 | { | ||
679 | f << '['; | ||
680 | for( typename Bu::List<value>::const_iterator i = l.begin(); i; i++ ) | ||
681 | { | ||
682 | if( i != l.begin() ) | ||
683 | f << ", "; | ||
684 | f << *i; | ||
685 | } | ||
686 | f << ']'; | ||
687 | |||
688 | return f; | ||
689 | } | ||
672 | } | 690 | } |
673 | 691 | ||
674 | #endif | 692 | #endif |
diff --git a/src/unit/fstring.unit b/src/unit/fstring.unit index a0d62da..fbebd39 100644 --- a/src/unit/fstring.unit +++ b/src/unit/fstring.unit | |||
@@ -129,6 +129,15 @@ | |||
129 | unitTest( c == "Hello/Dude" ); | 129 | unitTest( c == "Hello/Dude" ); |
130 | } | 130 | } |
131 | 131 | ||
132 | {%add7} | ||
133 | { | ||
134 | const Bu::FString a("hello "); | ||
135 | Bu::FString b(" how "); | ||
136 | unitTest( a == "hello " ); | ||
137 | unitTest( a + "dude" == "hello dude" ); | ||
138 | unitTest( a + "dude" + b + "are you?" == "hello dude how are you?" ); | ||
139 | } | ||
140 | |||
132 | {%subStr1} | 141 | {%subStr1} |
133 | { | 142 | { |
134 | Bu::FString a("abcdefghijklmnop"); | 143 | Bu::FString a("abcdefghijklmnop"); |