Classes | Public Member Functions | Static Public Member Functions

nsTextFragment Class Reference

A fragment of text. More...

#include <nsTextFragment.h>

Collaboration diagram for nsTextFragment:

List of all members.

Classes

struct  FragmentBits

Public Member Functions

 nsTextFragment ()
 Default constructor.
 ~nsTextFragment ()
nsTextFragmentoperator= (const nsTextFragment &aOther)
 Change the contents of this fragment to be a copy of the the argument fragment.
PRBool Is2b () const
 Return PR_TRUE if this fragment is represented by PRUnichar data.
PRBool IsBidi () const
 Return PR_TRUE if this fragment contains Bidi text For performance reasons this flag is not set automatically, but requires an explicit call to UpdateBidiFlag().
const PRUnicharGet2b () const
 Get a pointer to constant PRUnichar data.
const char * Get1b () const
 Get a pointer to constant char data.
PRUint32 GetLength () const
 Get the length of the fragment.
PRBool CanGrowBy (size_t n) const
void SetTo (const PRUnichar *aBuffer, PRInt32 aLength)
 Change the contents of this fragment to be a copy of the given buffer.
void Append (const PRUnichar *aBuffer, PRUint32 aLength)
 Append aData to the end of this fragment.
void AppendTo (nsAString &aString) const
 Append the contents of this string fragment to aString.
void AppendTo (nsAString &aString, PRInt32 aOffset, PRInt32 aLength) const
 Append a substring of the contents of this string fragment to aString.
void CopyTo (PRUnichar *aDest, PRInt32 aOffset, PRInt32 aCount)
 Make a copy of the fragments contents starting at offset for count characters.
PRUnichar CharAt (PRInt32 aIndex) const
 Return the character in the text-fragment at the given index.
void UpdateBidiFlag (const PRUnichar *aBuffer, PRUint32 aLength)
 Scan the contents of the fragment and turn on mState.mIsBidi if it includes any Bidi characters.

Static Public Member Functions

static nsresult Init ()
static void Shutdown ()

Detailed Description

A fragment of text.

If mIs2b is 1 then the m2b pointer is valid otherwise the m1b pointer is valid. If m1b is used then each byte of data represents a single ucs2 character with the high byte being zero.

This class does not have a virtual destructor therefore it is not meant to be subclassed.


Constructor & Destructor Documentation

nsTextFragment::nsTextFragment (  )  [inline]

Default constructor.

Initialize the fragment to be empty.

nsTextFragment::~nsTextFragment (  ) 

Member Function Documentation

void nsTextFragment::Append ( const PRUnichar aBuffer,
PRUint32  aLength 
)

Append aData to the end of this fragment.

void nsTextFragment::AppendTo ( nsAString aString  )  const [inline]

Append the contents of this string fragment to aString.

void nsTextFragment::AppendTo ( nsAString aString,
PRInt32  aOffset,
PRInt32  aLength 
) const [inline]

Append a substring of the contents of this string fragment to aString.

Parameters:
aOffset where to start the substring in this text fragment
aLength the length of the substring
PRBool nsTextFragment::CanGrowBy ( size_t  n  )  const [inline]
PRUnichar nsTextFragment::CharAt ( PRInt32  aIndex  )  const [inline]

Return the character in the text-fragment at the given index.

This always returns a PRUnichar.

void nsTextFragment::CopyTo ( PRUnichar aDest,
PRInt32  aOffset,
PRInt32  aCount 
)

Make a copy of the fragments contents starting at offset for count characters.

The offset and count will be adjusted to lie within the fragments data. The fragments data is converted if necessary.

const char* nsTextFragment::Get1b (  )  const [inline]

Get a pointer to constant char data.

const PRUnichar* nsTextFragment::Get2b (  )  const [inline]

Get a pointer to constant PRUnichar data.

PRUint32 nsTextFragment::GetLength (  )  const [inline]

Get the length of the fragment.

The length is the number of logical characters, not the number of bytes to store the characters.

static nsresult nsTextFragment::Init (  )  [static]
PRBool nsTextFragment::Is2b (  )  const [inline]

Return PR_TRUE if this fragment is represented by PRUnichar data.

PRBool nsTextFragment::IsBidi (  )  const [inline]

Return PR_TRUE if this fragment contains Bidi text For performance reasons this flag is not set automatically, but requires an explicit call to UpdateBidiFlag().

nsTextFragment& nsTextFragment::operator= ( const nsTextFragment aOther  ) 

Change the contents of this fragment to be a copy of the the argument fragment.

void nsTextFragment::SetTo ( const PRUnichar aBuffer,
PRInt32  aLength 
)

Change the contents of this fragment to be a copy of the given buffer.

static void nsTextFragment::Shutdown (  )  [static]
void nsTextFragment::UpdateBidiFlag ( const PRUnichar aBuffer,
PRUint32  aLength 
)

Scan the contents of the fragment and turn on mState.mIsBidi if it includes any Bidi characters.


Member Data Documentation

const char* nsTextFragment::m1b

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