Exemplo n.º 1
0
NS_CStringSetDataRange(nsACString& aStr,
                       uint32_t aCutOffset, uint32_t aCutLength,
                       const char* aData, uint32_t aDataLength)
{
  if (aCutOffset == UINT32_MAX) {
    // append case
    if (aData) {
      aStr.Append(aData, aDataLength);
    }
    return NS_OK; // XXX report errors
  }

  if (aCutLength == UINT32_MAX) {
    aCutLength = aStr.Length() - aCutOffset;
  }

  if (aData) {
    if (aDataLength == UINT32_MAX) {
      aStr.Replace(aCutOffset, aCutLength, nsDependentCString(aData));
    } else {
      aStr.Replace(aCutOffset, aCutLength, Substring(aData, aDataLength));
    }
  } else {
    aStr.Cut(aCutOffset, aCutLength);
  }

  return NS_OK; // XXX report errors
}
Exemplo n.º 2
0
NS_CStringSetDataRange(nsACString &aStr,
                       PRUint32 aCutOffset, PRUint32 aCutLength,
                       const char *aData, PRUint32 aDataLength)
{
  if (aCutOffset == PR_UINT32_MAX)
  {
    // append case
    if (aData)
      aStr.Append(aData, aDataLength);
    return NS_OK; // XXX report errors
  }

  if (aCutLength == PR_UINT32_MAX)
    aCutLength = aStr.Length() - aCutOffset;

  if (aData)
  {
    if (aDataLength == PR_UINT32_MAX)
      aStr.Replace(aCutOffset, aCutLength, nsDependentCString(aData));
    else
      aStr.Replace(aCutOffset, aCutLength, Substring(aData, aDataLength));
  }
  else
    aStr.Cut(aCutOffset, aCutLength);

  return NS_OK; // XXX report errors
}
Exemplo n.º 3
0
static void
__ReplaceCChar (nsACString &string, const char replace, const char with)
{
	PRInt32 i = string.FindChar (replace);
  while (i >= 0 ) {
	  string.Replace (i, 1, (const char*) &with, 1);
	  i = string.FindChar (replace);
	}
}
Exemplo n.º 4
0
static void
__ReplaceCSubstring (nsACString &string, const char* replace, const char* with)
{
	PRInt32 i = string.Find (replace);
	while ( i >= 0 ) {
  	string.Replace (i, strlen (replace), with);
  	i = string.Find (replace);
  }
}