fix bug 139633 - as a part of freezing nsAString, move Left/Right/Mid back into nsString, and fix consumers to start using Substring()

r=jag, sr=darin


git-svn-id: svn://10.0.0.236/trunk@120220 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
alecf%netscape.com
2002-04-29 20:29:54 +00:00
parent 9b30ae8f63
commit 61312b4eeb
33 changed files with 249 additions and 245 deletions

View File

@@ -249,6 +249,28 @@ public:
// Takes ownership of aPtr, sets the current length to aLength if specified.
void Adopt( char* aPtr, PRInt32 aLength = -1 );
/*
|Left|, |Mid|, and |Right| are annoying signatures that seem better almost
any _other_ way than they are now. Consider these alternatives
aWritable = aReadable.Left(17); // ...a member function that returns a |Substring|
aWritable = Left(aReadable, 17); // ...a global function that returns a |Substring|
Left(aReadable, 17, aWritable); // ...a global function that does the assignment
as opposed to the current signature
aReadable.Left(aWritable, 17); // ...a member function that does the assignment
or maybe just stamping them out in favor of |Substring|, they are just duplicate functionality
aWritable = Substring(aReadable, 0, 17);
*/
size_type Left( self_type&, size_type ) const;
size_type Mid( self_type&, PRUint32, PRUint32 ) const;
size_type Right( self_type&, size_type ) const;
/**********************************************************************
Searching methods...
*********************************************************************/
@@ -355,6 +377,22 @@ private:
void InsertWithConversion( char, PRUint32 );
};
inline
nsCString::size_type
nsCString::Left( nsACString& aResult, size_type aLengthToCopy ) const
{
return Mid(aResult, 0, aLengthToCopy);
}
inline
nsCString::size_type
nsCString::Right( self_type& aResult, size_type aLengthToCopy ) const
{
size_type myLength = Length();
aLengthToCopy = NS_MIN(myLength, aLengthToCopy);
return Mid(aResult, myLength-aLengthToCopy, aLengthToCopy);
}
// NS_DEF_STRING_COMPARISON_OPERATORS(nsCString, char)
// NS_DEF_DERIVED_STRING_OPERATOR_PLUS(nsCString, char)