Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends

CToken Class Reference

Token objects represent sequences of characters as they are consumed from the input stream (URL). More...

#include <nsToken.h>

Inheritance diagram for CToken:

List of all members.

Public Types

enum  eTokenOrigin { eSource, eResidualStyle }

Public Member Functions

void AddRef ()
 Make a note on number of times you have been referenced harishd 08/02/00.
void Release (nsFixedSizeAllocator &aArenaPool)
 Free yourself if no one is holding you.
 CToken (PRInt32 aTag=0)
 Default constructor gess7/21/98.
virtual const nsSubstringGetStringValue (void)=0
 Retrieve string value of the token gess5/11/98.
virtual void GetSource (nsString &anOutputString)
 Get string of full contents, suitable for debug dump.
virtual void AppendSourceTo (nsAString &anOutputString)
 harishd 03/23/00
void SetTypeID (PRInt32 aValue)
 Sets the ordinal value of this token (not currently used) gess5/11/98.
virtual PRInt32 GetTypeID (void)
 Getter which retrieves the current ordinal value for this token gess5/11/98.
virtual PRInt16 GetAttributeCount (void)
 Getter which retrieves the current attribute count for this token gess5/11/98.
virtual nsresult Consume (PRUnichar aChar, nsScanner &aScanner, PRInt32 aMode)
 Causes token to consume data from given scanner.
virtual PRInt32 GetTokenType (void)
 Getter which retrieves type of token gess5/11/98.
virtual PRBool IsWellFormed (void) const
 For tokens who care, this can tell us whether the token is well formed or not.
virtual PRBool IsEmpty (void)
virtual void SetEmpty (PRBool aValue)
 If aValue is TRUE then the token represents a short-hand tag.
PRInt32 GetNewlineCount ()
void SetNewlineCount (PRInt32 aCount)
PRInt32 GetLineNumber ()
void SetLineNumber (PRInt32 aLineNumber)
void SetInError (PRBool aInError)
PRBool IsInError ()
void SetAttributeCount (PRInt16 aValue)
virtual void SelfTest (void)
 perform self test.

Static Public Member Functions

static int GetTokenCount ()

Protected Member Functions

virtual ~CToken ()
 destructor gess5/11/98
virtual size_t SizeOf () const =0
 Returns the size of the token object.

Static Protected Member Functions

static void * operator new (size_t aSize, nsFixedSizeAllocator &anArena) throw ()
 harishd 08/01/00
static void operator delete (void *, size_t)
 Hide operator delete; clients should use Destroy() instead.

Protected Attributes

PRInt32 mTypeID
PRInt32 mUseCount
PRInt32 mNewlineCount
PRUint32 mLineNumber: 31
PRUint32 mInError: 1
PRInt16 mAttrCount

Friends

class nsTokenAllocator

Detailed Description

Token objects represent sequences of characters as they are consumed from the input stream (URL).

While they're pretty general in nature, we use subclasses (found in nsHTMLTokens.h) to define <start>, </end>, <text>, <comment>, <&entity>, <newline>, and <whitespace> tokens.

gess 3/25/98


Member Enumeration Documentation

Enumerator:
eSource 
eResidualStyle 

Constructor & Destructor Documentation

virtual CToken::~CToken (  )  [protected, virtual]

destructor gess5/11/98

CToken::CToken ( PRInt32  aTag = 0  ) 

Default constructor gess7/21/98.


Member Function Documentation

void CToken::AddRef (  )  [inline]

Make a note on number of times you have been referenced harishd 08/02/00.

virtual void CToken::AppendSourceTo ( nsAString anOutputString  )  [virtual]

harishd 03/23/00

Returns:
reference to string containing string value

Reimplemented in CStartToken, CEndToken, CCommentToken, CEntityToken, and CAttributeToken.

virtual nsresult CToken::Consume ( PRUnichar  aChar,
nsScanner &  aScanner,
PRInt32  aMode 
) [virtual]

Causes token to consume data from given scanner.

Note that behavior varies wildly between CToken subclasses. gess5/11/98

Parameters:
aChar -- most recent char consumed
aScanner -- input source where token should get data
Returns:
error code (0 means ok)

Reimplemented in CStartToken, CEndToken, CCommentToken, CEntityToken, CWhitespaceToken, CTextToken, CCDATASectionToken, CMarkupDeclToken, CAttributeToken, CNewlineToken, CInstructionToken, and CDoctypeDeclToken.

virtual PRInt16 CToken::GetAttributeCount ( void   )  [virtual]

Getter which retrieves the current attribute count for this token gess5/11/98.

Returns:
current attribute count
PRInt32 CToken::GetLineNumber (  )  [inline]
PRInt32 CToken::GetNewlineCount (  )  [inline]
virtual void CToken::GetSource ( nsString &  anOutputString  )  [virtual]

Get string of full contents, suitable for debug dump.

It should look exactly like the input source. gess5/11/98

Returns:
reference to string containing string value
virtual const nsSubstring& CToken::GetStringValue ( void   )  [pure virtual]

Retrieve string value of the token gess5/11/98.

Returns:
reference to string containing string value

Implemented in CStartToken, CEndToken, CCommentToken, CEntityToken, CWhitespaceToken, CTextToken, CCDATASectionToken, CMarkupDeclToken, CAttributeToken, CNewlineToken, CInstructionToken, and CDoctypeDeclToken.

static int CToken::GetTokenCount (  )  [static]
virtual PRInt32 CToken::GetTokenType ( void   )  [virtual]

Getter which retrieves type of token gess5/11/98.

Returns:
int containing token type

Reimplemented in CStartToken, CEndToken, CCommentToken, CEntityToken, CWhitespaceToken, CTextToken, CCDATASectionToken, CMarkupDeclToken, CAttributeToken, CNewlineToken, CInstructionToken, and CDoctypeDeclToken.

virtual PRInt32 CToken::GetTypeID ( void   )  [virtual]

Getter which retrieves the current ordinal value for this token gess5/11/98.

Returns:
current ordinal value

Reimplemented in CStartToken, and CEndToken.

virtual PRBool CToken::IsEmpty ( void   )  [inline, virtual]

Reimplemented in CStartToken.

PRBool CToken::IsInError (  )  [inline]
virtual PRBool CToken::IsWellFormed ( void   )  const [inline, virtual]

For tokens who care, this can tell us whether the token is well formed or not.

gess 8/30/00

Returns:
PR_FALSE; subclasses MUST override if they care.

Reimplemented in CStartToken.

static void CToken::operator delete ( void *  ,
size_t   
) [inline, static, protected]

Hide operator delete; clients should use Destroy() instead.

static void* CToken::operator new ( size_t  aSize,
nsFixedSizeAllocator anArena 
) throw () [inline, static, protected]

harishd 08/01/00

Parameters:
aSize -
aArena - Allocate memory from this pool.
void CToken::Release ( nsFixedSizeAllocator aArenaPool  )  [inline]

Free yourself if no one is holding you.

harishd 08/02/00

virtual void CToken::SelfTest ( void   )  [virtual]

perform self test.

gess5/11/98

void CToken::SetAttributeCount ( PRInt16  aValue  )  [inline]
virtual void CToken::SetEmpty ( PRBool  aValue  )  [inline, virtual]

If aValue is TRUE then the token represents a short-hand tag.

Reimplemented in CStartToken.

void CToken::SetInError ( PRBool  aInError  )  [inline]
void CToken::SetLineNumber ( PRInt32  aLineNumber  )  [inline]
void CToken::SetNewlineCount ( PRInt32  aCount  )  [inline]
void CToken::SetTypeID ( PRInt32  aValue  )  [inline]

Sets the ordinal value of this token (not currently used) gess5/11/98.

Parameters:
value is the new ord value for this token
virtual size_t CToken::SizeOf (  )  const [protected, pure virtual]

Friends And Related Function Documentation

friend class nsTokenAllocator [friend]

Member Data Documentation

PRInt16 CToken::mAttrCount [protected]
PRUint32 CToken::mInError [protected]
PRUint32 CToken::mLineNumber [protected]
PRInt32 CToken::mNewlineCount [protected]
PRInt32 CToken::mTypeID [protected]
PRInt32 CToken::mUseCount [protected]

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