Esempio n. 1
0
void
nsTSubstring_CharT::StripChars( const char_type* aChars, uint32_t aOffset )
  {
    if (aOffset >= uint32_t(mLength))
      return;

    if (!EnsureMutable()) // XXX do this lazily?
      NS_RUNTIMEABORT("OOM");

    // XXX(darin): this code should defer writing until necessary.

    char_type* to   = mData + aOffset;
    char_type* from = mData + aOffset;
    char_type* end  = mData + mLength;

    while (from < end)
      {
        char_type theChar = *from++;
        const char_type* test = aChars;

        for (; *test && *test != theChar; ++test);

        if (!*test) {
          // Not stripped, copy this char.
          *to++ = theChar;
        }
      }
    *to = char_type(0); // add the null
    mLength = to - mData;
  }
void
nsTString_CharT::StripChars( const char* aSet )
  {
    if (!EnsureMutable())
      NS_RUNTIMEABORT("OOM");

    mLength = nsBufferRoutines<CharT>::strip_chars(mData, mLength, aSet);
  }
Esempio n. 3
0
void
nsTString_CharT::StripChars( const char* aSet )
{
  if (!EnsureMutable())
    AllocFailed(mLength);

  mLength = nsBufferRoutines<CharT>::strip_chars(mData, mLength, aSet);
}
Esempio n. 4
0
void
nsTString_CharT::ReplaceChar( char_type aOldChar, char_type aNewChar )
  {
    EnsureMutable(); // XXX do this lazily?

    for (PRUint32 i=0; i<mLength; ++i)
      {
        if (mData[i] == aOldChar)
          mData[i] = aNewChar;
      }
  }
Esempio n. 5
0
bool
nsTString_CharT::SetCharAt( PRUnichar aChar, PRUint32 aIndex )
  {
    if (aIndex >= mLength)
      return PR_FALSE;

    EnsureMutable();

    mData[aIndex] = CharT(aChar);
    return PR_TRUE;
  }
void
nsTString_CharT::ReplaceChar( char_type aOldChar, char_type aNewChar )
  {
    if (!EnsureMutable()) // XXX do this lazily?
      NS_RUNTIMEABORT("OOM");

    for (uint32_t i=0; i<mLength; ++i)
      {
        if (mData[i] == aOldChar)
          mData[i] = aNewChar;
      }
  }
bool
nsTString_CharT::SetCharAt( PRUnichar aChar, uint32_t aIndex )
  {
    if (aIndex >= mLength)
      return false;

    if (!EnsureMutable())
      NS_RUNTIMEABORT("OOM");

    mData[aIndex] = CharT(aChar);
    return true;
  }
Esempio n. 8
0
bool
nsTString_CharT::SetCharAt( char16_t aChar, uint32_t aIndex )
{
  if (aIndex >= mLength)
    return false;

  if (!EnsureMutable())
    NS_ABORT_OOM(mLength);

  mData[aIndex] = CharT(aChar);
  return true;
}
Esempio n. 9
0
void
nsTString_CharT::ReplaceChar( char_type aOldChar, char_type aNewChar )
{
  if (!EnsureMutable()) // XXX do this lazily?
    AllocFailed(mLength);

  for (uint32_t i=0; i<mLength; ++i)
  {
    if (mData[i] == aOldChar)
      mData[i] = aNewChar;
  }
}
Esempio n. 10
0
void
nsTString_CharT::ReplaceChar( const char* aSet, char_type aNewChar )
  {
    EnsureMutable(); // XXX do this lazily?

    char_type* data = mData;
    PRUint32 lenRemaining = mLength;

    while (lenRemaining)
      {
        PRInt32 i = ::FindCharInSet(data, lenRemaining, aSet);
        if (i == kNotFound)
          break;

        data[i++] = aNewChar;
        data += i;
        lenRemaining -= i;
      }
  }
void
nsTString_CharT::ReplaceChar( const char* aSet, char_type aNewChar )
  {
    if (!EnsureMutable()) // XXX do this lazily?
      NS_RUNTIMEABORT("OOM");

    char_type* data = mData;
    uint32_t lenRemaining = mLength;

    while (lenRemaining)
      {
        int32_t i = ::FindCharInSet(data, lenRemaining, aSet);
        if (i == kNotFound)
          break;

        data[i++] = aNewChar;
        data += i;
        lenRemaining -= i;
      }
  }
Esempio n. 12
0
void
nsString::ReplaceChar( const char16_t* aSet, char16_t aNewChar )
{
    if (!EnsureMutable()) // XXX do this lazily?
        NS_ABORT_OOM(mLength);

    char16_t* data = mData;
    uint32_t lenRemaining = mLength;

    while (lenRemaining)
    {
        int32_t i = ::FindCharInSet(data, lenRemaining, aSet);
        if (i == kNotFound)
            break;

        data[i++] = aNewChar;
        data += i;
        lenRemaining -= i;
    }
}
Esempio n. 13
0
void
nsTSubstring_CharT::StripChar( char_type aChar, PRInt32 aOffset )
  {
    if (mLength == 0 || aOffset >= PRInt32(mLength))
      return;

    EnsureMutable(); // XXX do this lazily?

    // XXX(darin): this code should defer writing until necessary.

    char_type* to   = mData + aOffset;
    char_type* from = mData + aOffset;
    char_type* end  = mData + mLength;

    while (from < end)
      {
        char_type theChar = *from++;
        if (aChar != theChar)
          *to++ = theChar;
      }
    *to = char_type(0); // add the null
    mLength = to - mData;
  }
Esempio n. 14
0
void
nsTString_CharT::StripChars( const char* aSet )
  {
    EnsureMutable();
    mLength = nsBufferRoutines<CharT>::strip_chars(mData, mLength, aSet);
  }