Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions

nsAString Class Reference

This header provides wrapper classes around the frozen string API which are roughly equivalent to the internal string classes. More...

#include <nsStringAPI.h>

Inheritance diagram for nsAString:

List of all members.

Public Types

typedef PRUnichar char_type
typedef nsAString self_type
typedef PRUint32 size_type
typedef PRUint32 index_type
typedef PRInt32(* ComparatorFunc )(const char_type *a, const char_type *b, PRUint32 length)
 Compare strings of characters.

Public Member Functions

PRUint32 BeginReading (const char_type **begin, const char_type **end=0L) const
 Returns the length, beginning, and end of a string in one operation.
const char_typeBeginReading () const
const char_typeEndReading () const
char_type CharAt (PRUint32 aPos) const
char_type operator[] (PRUint32 aPos) const
char_type First () const
PRUint32 BeginWriting (char_type **begin, char_type **end=0L, PRUint32 newSize=PR_UINT32(4294967295))
 Get the length, begin writing, and optionally set the length of a string all in one operation.
char_typeBeginWriting (PRUint32=PR_UINT32(4294967295))
char_typeEndWriting ()
PRBool SetLength (PRUint32 aLen)
size_type Length () const
PRBool IsEmpty () const
void SetIsVoid (PRBool val)
PRBool IsVoid () const
void Assign (const self_type &aString)
void Assign (const char_type *aData, size_type aLength=PR_UINT32(4294967295))
void Assign (char_type aChar)
void AssignLiteral (const char *aStr)
self_typeoperator= (const self_type &aString)
self_typeoperator= (const char_type *aPtr)
self_typeoperator= (char_type aChar)
void Replace (index_type cutStart, size_type cutLength, const char_type *data, size_type length=size_type(-1))
void Replace (index_type cutStart, size_type cutLength, char_type c)
void Replace (index_type cutStart, size_type cutLength, const self_type &readable)
void Append (char_type c)
void Append (const char_type *data, size_type length=size_type(-1))
void Append (const self_type &readable)
void AppendLiteral (const char *aASCIIStr)
self_typeoperator+= (char_type c)
self_typeoperator+= (const char_type *data)
self_typeoperator+= (const self_type &readable)
void Insert (char_type c, index_type pos)
void Insert (const char_type *data, index_type pos, size_type length=size_type(-1))
void Insert (const self_type &readable, index_type pos)
void Cut (index_type cutStart, size_type cutLength)
void Truncate ()
void StripChars (const char *aSet)
 Remove all occurences of characters in aSet from the string.
void StripWhitespace ()
 Strip whitespace characters from the string.
void Trim (const char *aSet, PRBool aLeading=1, PRBool aTrailing=1)
PRInt32 Compare (const char_type *other, ComparatorFunc c=DefaultComparator) const
PRInt32 Compare (const self_type &other, ComparatorFunc c=DefaultComparator) const
PRBool Equals (const char_type *other, ComparatorFunc c=DefaultComparator) const
PRBool Equals (const self_type &other, ComparatorFunc c=DefaultComparator) const
PRBool operator< (const self_type &other) const
PRBool operator< (const char_type *other) const
PRBool operator<= (const self_type &other) const
PRBool operator<= (const char_type *other) const
PRBool operator== (const self_type &other) const
PRBool operator== (const char_type *other) const
PRBool operator>= (const self_type &other) const
PRBool operator>= (const char_type *other) const
PRBool operator> (const self_type &other) const
PRBool operator> (const char_type *other) const
PRBool operator!= (const self_type &other) const
PRBool operator!= (const char_type *other) const
PRBool EqualsLiteral (const char *aASCIIString) const
PRBool LowerCaseEqualsLiteral (const char *aASCIIString) const
 Case-insensitive match this string to a lowercase ASCII string.
PRInt32 Find (const self_type &aStr, ComparatorFunc c=DefaultComparator) const
 Find the first occurrence of aStr in this string.
PRInt32 Find (const self_type &aStr, PRUint32 aOffset, ComparatorFunc c=DefaultComparator) const
 Find the first occurrence of aStr in this string, beginning at aOffset.
PRInt32 Find (const char *aStr, PRBool aIgnoreCase=0) const
 Find an ASCII string within this string.
PRInt32 Find (const char *aStr, PRUint32 aOffset, PRBool aIgnoreCase=0) const
PRInt32 RFind (const self_type &aStr, ComparatorFunc c=DefaultComparator) const
 Find the last occurrence of aStr in this string.
PRInt32 RFind (const self_type &aStr, PRInt32 aOffset, ComparatorFunc c=DefaultComparator) const
 Find the last occurrence of aStr in this string, beginning at aOffset.
PRInt32 RFind (const char *aStr, PRBool aIgnoreCase=0) const
 Find the last occurrence of an ASCII string within this string.
PRInt32 RFind (const char *aStr, PRInt32 aOffset, PRBool aIgnoreCase) const
 Find the last occurrence of an ASCII string beginning at aOffset.
PRInt32 FindChar (char_type aChar, PRUint32 aOffset=0) const
 Search for the offset of the first occurrence of a character in a string.
PRInt32 RFindChar (char_type aChar) const
 Search for the offset of the last occurrence of a character in a string.
void AppendInt (int aInt, PRInt32 aRadix=10)
 Append a string representation of a number.
PRInt32 ToInteger (nsresult *aErrorCode, PRUint32 aRadix=10) const
 Convert this string to an integer.

Static Public Member Functions

static PRInt32 DefaultComparator (const char_type *a, const char_type *b, PRUint32 length)

Protected Member Functions

 ~nsAString ()

Detailed Description

This header provides wrapper classes around the frozen string API which are roughly equivalent to the internal string classes.


Member Typedef Documentation

typedef PRInt32(* nsAString::ComparatorFunc)(const char_type *a, const char_type *b, PRUint32 length)

Compare strings of characters.

Return 0 if the characters are equal,

typedef PRUint32 nsAString::index_type
typedef PRUint32 nsAString::size_type

Constructor & Destructor Documentation

nsAString::~nsAString (  )  [inline, protected]

Member Function Documentation

void nsAString::Append ( char_type  c  )  [inline]
void nsAString::Append ( const char_type data,
size_type  length = size_type(-1) 
) [inline]
void nsAString::Append ( const self_type readable  )  [inline]
void nsAString::AppendInt ( int  aInt,
PRInt32  aRadix = 10 
)

Append a string representation of a number.

void nsAString::AppendLiteral ( const char *  aASCIIStr  ) 
void nsAString::Assign ( const char_type aData,
size_type  aLength = PR_UINT32(4294967295) 
) [inline]
void nsAString::Assign ( char_type  aChar  )  [inline]
void nsAString::Assign ( const self_type aString  )  [inline]
void nsAString::AssignLiteral ( const char *  aStr  ) 
const char_type* nsAString::BeginReading (  )  const
PRUint32 nsAString::BeginReading ( const char_type **  begin,
const char_type **  end = 0L 
) const

Returns the length, beginning, and end of a string in one operation.

char_type* nsAString::BeginWriting ( PRUint32  = PR_UINT32(4294967295)  ) 
PRUint32 nsAString::BeginWriting ( char_type **  begin,
char_type **  end = 0L,
PRUint32  newSize = PR_UINT32(4294967295) 
)

Get the length, begin writing, and optionally set the length of a string all in one operation.

Parameters:
newSize Size the string to this length. Pass PR_UINT32_MAX to leave the length unchanged.
Returns:
The new length of the string, or 0 if resizing failed.
char_type nsAString::CharAt ( PRUint32  aPos  )  const [inline]
PRInt32 nsAString::Compare ( const char_type other,
ComparatorFunc  c = DefaultComparator 
) const
PRInt32 nsAString::Compare ( const self_type other,
ComparatorFunc  c = DefaultComparator 
) const
void nsAString::Cut ( index_type  cutStart,
size_type  cutLength 
) [inline]
static PRInt32 nsAString::DefaultComparator ( const char_type a,
const char_type b,
PRUint32  length 
) [static]
const char_type* nsAString::EndReading (  )  const
char_type* nsAString::EndWriting (  ) 
PRBool nsAString::Equals ( const char_type other,
ComparatorFunc  c = DefaultComparator 
) const
PRBool nsAString::Equals ( const self_type other,
ComparatorFunc  c = DefaultComparator 
) const
PRBool nsAString::EqualsLiteral ( const char *  aASCIIString  )  const
PRInt32 nsAString::Find ( const self_type aStr,
ComparatorFunc  c = DefaultComparator 
) const [inline]

Find the first occurrence of aStr in this string.

Returns:
the offset of aStr, or -1 if not found
PRInt32 nsAString::Find ( const char *  aStr,
PRBool  aIgnoreCase = 0 
) const [inline]

Find an ASCII string within this string.

Returns:
the offset of aStr, or -1 if not found.
PRInt32 nsAString::Find ( const self_type aStr,
PRUint32  aOffset,
ComparatorFunc  c = DefaultComparator 
) const

Find the first occurrence of aStr in this string, beginning at aOffset.

Returns:
the offset of aStr, or -1 if not found
PRInt32 nsAString::Find ( const char *  aStr,
PRUint32  aOffset,
PRBool  aIgnoreCase = 0 
) const
PRInt32 nsAString::FindChar ( char_type  aChar,
PRUint32  aOffset = 0 
) const

Search for the offset of the first occurrence of a character in a string.

Parameters:
aOffset the offset from the beginning of the string to begin searching
Returns:
The offset of the character from the beginning of the string, or -1 if not found.
char_type nsAString::First (  )  const [inline]
void nsAString::Insert ( char_type  c,
index_type  pos 
) [inline]
void nsAString::Insert ( const char_type data,
index_type  pos,
size_type  length = size_type(-1) 
) [inline]
void nsAString::Insert ( const self_type readable,
index_type  pos 
) [inline]
PRBool nsAString::IsEmpty (  )  const [inline]
PRBool nsAString::IsVoid (  )  const [inline]
size_type nsAString::Length (  )  const [inline]
PRBool nsAString::LowerCaseEqualsLiteral ( const char *  aASCIIString  )  const

Case-insensitive match this string to a lowercase ASCII string.

PRBool nsAString::operator!= ( const char_type other  )  const [inline]
PRBool nsAString::operator!= ( const self_type other  )  const [inline]
self_type& nsAString::operator+= ( const char_type data  )  [inline]
self_type& nsAString::operator+= ( const self_type readable  )  [inline]
self_type& nsAString::operator+= ( char_type  c  )  [inline]
PRBool nsAString::operator< ( const self_type other  )  const [inline]
PRBool nsAString::operator< ( const char_type other  )  const [inline]
PRBool nsAString::operator<= ( const char_type other  )  const [inline]
PRBool nsAString::operator<= ( const self_type other  )  const [inline]
self_type& nsAString::operator= ( const self_type aString  )  [inline]

Reimplemented in nsString_external, and nsString_external.

self_type& nsAString::operator= ( const char_type aPtr  )  [inline]

Reimplemented in nsString_external.

self_type& nsAString::operator= ( char_type  aChar  )  [inline]

Reimplemented in nsString_external.

PRBool nsAString::operator== ( const char_type other  )  const [inline]
PRBool nsAString::operator== ( const self_type other  )  const [inline]
PRBool nsAString::operator> ( const char_type other  )  const [inline]
PRBool nsAString::operator> ( const self_type other  )  const [inline]
PRBool nsAString::operator>= ( const self_type other  )  const [inline]
PRBool nsAString::operator>= ( const char_type other  )  const [inline]
char_type nsAString::operator[] ( PRUint32  aPos  )  const [inline]
void nsAString::Replace ( index_type  cutStart,
size_type  cutLength,
char_type  c 
) [inline]
void nsAString::Replace ( index_type  cutStart,
size_type  cutLength,
const char_type data,
size_type  length = size_type(-1) 
) [inline]
void nsAString::Replace ( index_type  cutStart,
size_type  cutLength,
const self_type readable 
) [inline]
PRInt32 nsAString::RFind ( const self_type aStr,
PRInt32  aOffset,
ComparatorFunc  c = DefaultComparator 
) const

Find the last occurrence of aStr in this string, beginning at aOffset.

Parameters:
aOffset the offset from the beginning of the string to begin searching. If aOffset < 0, search from end of this string.
Returns:
The offset of aStr from the beginning of the string, or -1 if not found.
PRInt32 nsAString::RFind ( const char *  aStr,
PRBool  aIgnoreCase = 0 
) const [inline]

Find the last occurrence of an ASCII string within this string.

Returns:
The offset of aStr from the beginning of the string, or -1 if not found.
PRInt32 nsAString::RFind ( const char *  aStr,
PRInt32  aOffset,
PRBool  aIgnoreCase 
) const

Find the last occurrence of an ASCII string beginning at aOffset.

Parameters:
aOffset the offset from the beginning of the string to begin searching. If aOffset < 0, search from end of this string.
Returns:
The offset of aStr from the beginning of the string, or -1 if not found.
PRInt32 nsAString::RFind ( const self_type aStr,
ComparatorFunc  c = DefaultComparator 
) const [inline]

Find the last occurrence of aStr in this string.

Returns:
The offset of aStr from the beginning of the string, or -1 if not found.
PRInt32 nsAString::RFindChar ( char_type  aChar  )  const

Search for the offset of the last occurrence of a character in a string.

Returns:
The offset of the character from the beginning of the string, or -1 if not found.
void nsAString::SetIsVoid ( PRBool  val  )  [inline]
PRBool nsAString::SetLength ( PRUint32  aLen  ) 
void nsAString::StripChars ( const char *  aSet  ) 

Remove all occurences of characters in aSet from the string.

void nsAString::StripWhitespace (  )  [inline]

Strip whitespace characters from the string.

PRInt32 nsAString::ToInteger ( nsresult aErrorCode,
PRUint32  aRadix = 10 
) const

Convert this string to an integer.

Parameters:
aErrorCode pointer to contain result code.
aRadix must be 10 or 16
void nsAString::Trim ( const char *  aSet,
PRBool  aLeading = 1,
PRBool  aTrailing = 1 
)
void nsAString::Truncate (  )  [inline]

The documentation for this class was generated from the following file: