Back to index

lightning-sunbird  0.9+nobinonly
Functions
nsStringUtils.h File Reference
#include "nsStringAPI.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void AppendInt (nsAString &str, PRInt32 val)
 Append integer to string.
void AppendInt (nsAString &str, PRInt64 val)
PRInt32 FindChar (const nsAString &str, PRUnichar c)
 Find a char in the given string.
PRInt32 RFindChar (const nsAString &str, PRUnichar c)
 Find a char in the given string, searching from the end of the string.

Function Documentation

void AppendInt ( nsAString &  str,
PRInt32  val 
)

Append integer to string.

Definition at line 49 of file nsStringUtils.cpp.

{
  char buf[32];
  PR_snprintf(buf, sizeof(buf), "%ld", val);
  str.Append(NS_ConvertASCIItoUTF16(buf));
}

Here is the call graph for this function:

void AppendInt ( nsAString &  str,
PRInt64  val 
)

Definition at line 42 of file nsStringUtils.cpp.

{
  char buf[32];
  PR_snprintf(buf, sizeof(buf), "%lld", val);
  str.Append(NS_ConvertASCIItoUTF16(buf));
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 FindChar ( const nsAString &  str,
PRUnichar  c 
)

Find a char in the given string.

Returns:
offset of char, or -1 if not found.

Definition at line 56 of file nsStringUtils.cpp.

{
  const PRUnichar *start;
  PRUint32 len = NS_StringGetData(str, &start);
  const PRUnichar *iter = start, *end = start + len;
  for (; iter != end; ++iter) {
    if (*iter == c)
      return iter - start;
  }
  return -1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 RFindChar ( const nsAString &  str,
PRUnichar  c 
)

Find a char in the given string, searching from the end of the string.

Returns:
offset of char, or -1 if not found.

Definition at line 68 of file nsStringUtils.cpp.

{
  const PRUnichar *start;
  PRUint32 len = NS_StringGetData(str, &start);
  const PRUnichar *end = start + len, *iter = end - 1;
  for (; iter >= start; --iter) {
    if (*iter == c)
      return iter - start;
  }
  return -1;
}

Here is the call graph for this function: