void
nsACString::StripChars(const char *aSet)
{
  nsCString copy(*this);

  const char_type *source, *sourceEnd;
  copy.BeginReading(&source, &sourceEnd);

  char_type *dest;
  BeginWriting(&dest);
  if (!dest)
    return;

  char_type *curDest = dest;

  for (; source < sourceEnd; ++source) {
    const char *test;
    for (test = aSet; *test; ++test) {
      if (*source == char_type(*test))
        break;
    }

    if (!*test) {
      // not stripped, copy this char
      *curDest = *source;
      ++curDest;
    }
  }

  SetLength(curDest - dest);
}
void
nsAString::AssignLiteral(const char *aStr)
{
  uint32_t len = strlen(aStr);
  PRUnichar *buf = BeginWriting(len);
  if (!buf)
    return;

  for (; *aStr; ++aStr, ++buf)
    *buf = *aStr;
}
Пример #3
0
void
nsAString::AssignLiteral(const char* aStr)
{
  uint32_t len = strlen(aStr);
  char16_t* buf = BeginWriting(len);
  if (!buf) {
    return;
  }

  for (; *aStr; ++aStr, ++buf) {
    *buf = *aStr;
  }
}
void
nsAString::AppendLiteral(const char *aASCIIStr)
{
  uint32_t appendLen = strlen(aASCIIStr);

  uint32_t thisLen = Length();
  PRUnichar *begin, *end;
  BeginWriting(&begin, &end, appendLen + thisLen);
  if (!begin)
    return;

  for (begin += thisLen; begin < end; ++begin, ++aASCIIStr)
    *begin = *aASCIIStr;
}