Bug 1344498 - Add fallible StripWhitespace r=njn

MozReview-Commit-ID: 8UOTEBlFxfO

--HG--
extra : rebase_source : 2c32cf4b39f9e601b9ebe1a51639000dea9f14f7
This commit is contained in:
Valentin Gosu 2017-03-23 12:52:31 +01:00
parent af6a16068b
commit 427ac28f38
2 changed files with 18 additions and 0 deletions

View File

@ -372,12 +372,14 @@ public:
using nsTSubstring_CharT::StripChars;
#endif
void StripChars(const char* aSet);
bool StripChars(const char* aSet, const fallible_t&);
/**
* This method strips whitespace throughout the string.
*/
void StripWhitespace();
bool StripWhitespace(const fallible_t&);
/**

View File

@ -407,12 +407,28 @@ nsTString_CharT::StripChars( const char* aSet )
mLength = nsBufferRoutines<CharT>::strip_chars(mData, mLength, aSet);
}
bool
nsTString_CharT::StripChars( const char* aSet, const fallible_t& )
{
if (!EnsureMutable()) {
return false;
}
mLength = nsBufferRoutines<CharT>::strip_chars(mData, mLength, aSet);
return true;
}
void
nsTString_CharT::StripWhitespace()
{
StripChars(kWhitespace);
}
bool
nsTString_CharT::StripWhitespace(const fallible_t& aFallible)
{
return StripChars(kWhitespace, aFallible);
}
/**
* nsTString::ReplaceChar,ReplaceSubstring