ICU-2950 add public operator + to UnicodeString
X-SVN-Rev: 13544
This commit is contained in:
parent
4171085928
commit
e207ba9a7c
@ -3069,8 +3069,21 @@ private:
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a new UnicodeString with the concatenation of two others.
|
||||
*
|
||||
* @param s1 The first string to be copied to the new one.
|
||||
* @param s2 The second string to be copied to the new one, after s1.
|
||||
* @return UnicodeString(s1).append(s2)
|
||||
* @draft ICU 2.8
|
||||
*/
|
||||
inline UnicodeString
|
||||
operator+ (const UnicodeString &s1, const UnicodeString &s2);
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
// inline implementations -------------------------------------------------- ***
|
||||
|
||||
//========================================
|
||||
// Array copying
|
||||
//========================================
|
||||
@ -4003,6 +4016,15 @@ UnicodeString::reverse(int32_t start,
|
||||
int32_t _length)
|
||||
{ return doReverse(start, _length); }
|
||||
|
||||
// functions that are not UnicodeString members ---------------------------- ***
|
||||
|
||||
inline UnicodeString
|
||||
operator+ (const UnicodeString &s1, const UnicodeString &s2) {
|
||||
return
|
||||
UnicodeString(s1.length()+s2.length()+1, (UChar32)0, 0).
|
||||
append(s1).
|
||||
append(s2);
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
|
@ -51,16 +51,6 @@ UnicodeString
|
||||
UCharToUnicodeString(UChar c)
|
||||
{ return UnicodeString(c); }
|
||||
|
||||
// [LIU] Just to get things working
|
||||
UnicodeString
|
||||
operator+(const UnicodeString& left,
|
||||
const UnicodeString& right)
|
||||
{
|
||||
UnicodeString str(left);
|
||||
str += right;
|
||||
return str;
|
||||
}
|
||||
|
||||
// [rtg] Just to get things working
|
||||
UnicodeString
|
||||
operator+(const UnicodeString& left,
|
||||
|
@ -26,7 +26,6 @@ U_NAMESPACE_USE
|
||||
//convenience classes to ease porting code that uses the Java
|
||||
//string-concatenation operator (moved from findword test by rtg)
|
||||
UnicodeString UCharToUnicodeString(UChar c);
|
||||
UnicodeString operator+(const UnicodeString& left, const UnicodeString& right);
|
||||
UnicodeString operator+(const UnicodeString& left, long num);
|
||||
UnicodeString operator+(const UnicodeString& left, unsigned long num);
|
||||
UnicodeString operator+(const UnicodeString& left, double num);
|
||||
|
@ -171,6 +171,14 @@ UnicodeStringTest::TestBasicManipulation()
|
||||
errln("UnicodeString::setTo(const UnicodeString&, int32_t) failed");
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// op+ is new in ICU 2.8
|
||||
UnicodeString s=UnicodeString("abc", "")+UnicodeString("def", "")+UnicodeString("ghi", "");
|
||||
if(s!=UnicodeString("abcdefghi", "")) {
|
||||
errln("operator+(UniStr, UniStr) failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user