Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends
CStartToken Class Reference

This declares start tokens, which always take the form <xxxx>. More...

#include <nsHTMLTokens.h>

Inheritance diagram for CStartToken:
Inheritance graph
[legend]
Collaboration diagram for CStartToken:
Collaboration graph
[legend]

List of all members.

Public Types

enum  eTokenOrigin { eSource, eResidualStyle }

Public Member Functions

 CStartToken (eHTMLTags aTag=eHTMLTag_unknown)
 CStartToken (const nsAString &aString)
 CStartToken (const nsAString &aName, eHTMLTags aTag)
virtual nsresult Consume (PRUnichar aChar, nsScanner &aScanner, PRInt32 aMode)
 Causes token to consume data from given scanner.
virtual PRInt32 GetTypeID (void)
 Getter which retrieves the current ordinal value for this token gess5/11/98.
virtual PRInt32 GetTokenType (void)
 Getter which retrieves type of token gess5/11/98.
virtual PRBool IsEmpty (void)
virtual void SetEmpty (PRBool aValue)
 If aValue is TRUE then the token represents a short-hand tag.
virtual const nsSubstringGetStringValue ()
 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
virtual eContainerInfo GetContainerInfo (void) const
virtual void SetContainerInfo (eContainerInfo aContainerInfo)
virtual PRBool IsWellFormed (void) const
 For tokens who care, this can tell us whether the token is well formed or not.
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.
void SetTypeID (PRInt32 aValue)
 Sets the ordinal value of this token (not currently used) gess5/11/98.
virtual PRInt16 GetAttributeCount (void)
 Getter which retrieves the current attribute count for this token gess5/11/98.
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 void Destroy (CToken *aToken, nsFixedSizeAllocator &aArenaPool)
 Destroy a token.
static int GetTokenCount ()

Public Attributes

nsString mTextValue

Protected Member Functions

virtual size_t SizeOf () const =0
 Returns the size of the token object.

Static Protected Member Functions

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

Protected Attributes

eContainerInfo mContainerInfo
PRPackedBool mEmpty
PRInt32 mTypeID
PRInt32 mUseCount
PRInt32 mNewlineCount
PRUint32 mLineNumber: 31
PRUint32 mInError: 1
PRInt16 mAttrCount

Friends

class nsTokenAllocator

Detailed Description

This declares start tokens, which always take the form <xxxx>.

This class also knows how to consume related attributes.

gess 3/25/98

Definition at line 127 of file nsHTMLTokens.h.


Member Enumeration Documentation

enum CToken::eTokenOrigin [inherited]
Enumerator:
eSource 
eResidualStyle 

Definition at line 109 of file nsToken.h.


Constructor & Destructor Documentation

Definition at line 225 of file nsHTMLTokens.cpp.

                                       : CHTMLToken(aTag) {
  mEmpty=PR_FALSE;
  mContainerInfo=eFormUnknown;
#ifdef DEBUG
  mAttributed = PR_FALSE;
#endif
}
CStartToken::CStartToken ( const nsAString &  aString)

Definition at line 233 of file nsHTMLTokens.cpp.

                                               : CHTMLToken(eHTMLTag_unknown) {
  mEmpty=PR_FALSE;
  mContainerInfo=eFormUnknown;
  mTextValue.Assign(aName);
#ifdef DEBUG
  mAttributed = PR_FALSE;
#endif
}
CStartToken::CStartToken ( const nsAString &  aName,
eHTMLTags  aTag 
)

Definition at line 242 of file nsHTMLTokens.cpp.

                                                              : CHTMLToken(aTag) {
  mEmpty=PR_FALSE;
  mContainerInfo=eFormUnknown;
  mTextValue.Assign(aName);
#ifdef DEBUG
  mAttributed = PR_FALSE;
#endif
}

Member Function Documentation

void CToken::AddRef ( void  ) [inline, inherited]

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

Definition at line 154 of file nsToken.h.

{ ++mUseCount; }
void CStartToken::AppendSourceTo ( nsAString &  anOutputString) [virtual]

harishd 03/23/00

harishd 3/23/00

Returns:
reference to string containing string value

Reimplemented from CToken.

Definition at line 375 of file nsHTMLTokens.cpp.

                                                         {
  anOutputString.Append(PRUnichar('<'));
  /*
   * Watch out for Bug 15204 
   */
  if(!mTextValue.IsEmpty())
    anOutputString.Append(mTextValue);
  else
    anOutputString.Append(GetTagName(mTypeID));

  anOutputString.Append(PRUnichar('>'));
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Causes token to consume data from given scanner.

Virtual method used to tell this toke to consume his valid chars.

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)

gess 3/25/98

Parameters:
aChar-- first char in sequence
aScanner-- object to retrieve data from
Returns:
int error code

Reimplemented from CToken.

Definition at line 308 of file nsHTMLTokens.cpp.

                                                                                {

  //if you're here, we've already Consumed the < char, and are
   //ready to Consume the rest of the open tag identifier.
   //Stop consuming as soon as you see a space or a '>'.
   //NOTE: We don't Consume the tag attributes here, nor do we eat the ">"

  nsresult result=NS_OK;
  nsScannerSharedSubstring tagIdent;

  if (aFlag & NS_IPARSER_FLAG_HTML) {
    result = aScanner.ReadTagIdentifier(tagIdent);
    mTypeID = (PRInt32)nsHTMLTags::LookupTag(tagIdent.str());
    // Save the original tag string if this is user-defined or if we
    // are viewing source
    if(eHTMLTag_userdefined==mTypeID || (aFlag & NS_IPARSER_FLAG_VIEW_SOURCE)) {
      mTextValue = tagIdent.str();
    }
  }
  else {
    result = aScanner.ReadTagIdentifier(tagIdent);
    mTextValue = tagIdent.str();
    mTypeID = nsHTMLTags::LookupTag(mTextValue);
  }

  if (NS_SUCCEEDED(result) && !(aFlag & NS_IPARSER_FLAG_VIEW_SOURCE)) {
    result = aScanner.SkipWhitespace(mNewlineCount);
  }

  if (kEOF == result && !aScanner.IsIncremental()) {
    // Take what we can get.
    result = NS_OK;
  }

  return result;
}

Here is the call graph for this function:

static void CToken::Destroy ( CToken aToken,
nsFixedSizeAllocator &  aArenaPool 
) [inline, static, inherited]

Destroy a token.

Definition at line 143 of file nsToken.h.

    {
      size_t sz = aToken->SizeOf();
      aToken->~CToken();
      aArenaPool.Free(aToken, sz);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

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

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

Retrieves copy of attr count for this token.

Returns:
current attribute count

gess 3/25/98

Returns:
int containing attribute count

Definition at line 151 of file nsToken.cpp.

                                      {
  return mAttrCount;
}

Here is the caller graph for this function:

virtual eContainerInfo CStartToken::GetContainerInfo ( void  ) const [inline, virtual]

Reimplemented from CHTMLToken.

Definition at line 147 of file nsHTMLTokens.h.

{return mContainerInfo;}
PRInt32 CToken::GetLineNumber ( void  ) [inline, inherited]

Definition at line 257 of file nsToken.h.

    { 
      return mLineNumber;
    }

Here is the caller graph for this function:

PRInt32 CToken::GetNewlineCount ( ) [inline, inherited]

Definition at line 247 of file nsToken.h.

    { 
      return mNewlineCount; 
    }

Here is the caller graph for this function:

void CStartToken::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

Reimplemented from CToken.

Definition at line 363 of file nsHTMLTokens.cpp.

                                                   {
  anOutputString.Truncate();
  AppendSourceTo(anOutputString);
}

Here is the call graph for this function:

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

Returns:
reference to string containing string value

Implements CToken.

Definition at line 346 of file nsHTMLTokens.cpp.

{
  if((eHTMLTag_unknown<mTypeID) && (mTypeID<eHTMLTag_text)) {
    if(!mTextValue.Length()) {
      mTextValue.Assign(nsHTMLTags::GetStringValue((nsHTMLTag) mTypeID));
    }
  }
  return mTextValue;
}

Here is the call graph for this function:

int CToken::GetTokenCount ( ) [static, inherited]

Definition at line 49 of file nsToken.cpp.

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

Retrieve type of token.

Returns:
int containing token type

This class returns -1, but subclasses return something more meaningful.

gess 3/25/98

Returns:
int value containing token type.

Reimplemented from CToken.

Definition at line 272 of file nsHTMLTokens.cpp.

                                      {
  return eToken_start;
}

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

Retrieves copy of internal ordinal value.

Returns:
current ordinal value

This method is deprecated, and will soon be going away.

gess 3/25/98

Returns:
int containing ordinal value

Reimplemented from CToken.

Definition at line 258 of file nsHTMLTokens.cpp.

Here is the call graph for this function:

PRBool CStartToken::IsEmpty ( void  ) [virtual]

Reimplemented from CToken.

Definition at line 294 of file nsHTMLTokens.cpp.

                                {
  return mEmpty;
}

Here is the caller graph for this function:

PRBool CToken::IsInError ( ) [inline, inherited]

Definition at line 272 of file nsToken.h.

    {
      return mInError;
    }

Here is the caller graph for this function:

virtual PRBool CStartToken::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 from CToken.

Definition at line 153 of file nsHTMLTokens.h.

                                          {
    return eWellFormed == mContainerInfo;
  }
static void CToken::operator delete ( void ,
size_t   
) [inline, static, protected, inherited]

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

Definition at line 131 of file nsToken.h.

{}
static void* CToken::operator new ( size_t  aSize,
nsFixedSizeAllocator &  anArena 
) [inline, static, protected, inherited]

harishd 08/01/00

Parameters:
aSize-
aArena- Allocate memory from this pool.

Definition at line 123 of file nsToken.h.

    {
      return anArena.Alloc(aSize);
    }
void CToken::Release ( nsFixedSizeAllocator &  aArenaPool) [inline, inherited]

Free yourself if no one is holding you.

harishd 08/02/00

Definition at line 160 of file nsToken.h.

                                                   {
      if(--mUseCount==0)
        Destroy(this, aArenaPool);
    }

Here is the call graph for this function:

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

perform self test.

gess 3/25/98

gess5/11/98

Definition at line 172 of file nsToken.cpp.

                          {
#ifdef _DEBUG
#endif
}
void CToken::SetAttributeCount ( PRInt16  aValue) [inline, inherited]

Definition at line 277 of file nsToken.h.

Here is the caller graph for this function:

virtual void CStartToken::SetContainerInfo ( eContainerInfo  aContainerInfo) [inline, virtual]

Reimplemented from CHTMLToken.

Definition at line 148 of file nsHTMLTokens.h.

                                                               {
    if (eFormUnknown==mContainerInfo) {
      mContainerInfo=aContainerInfo;
    }
  }
void CStartToken::SetEmpty ( PRBool  aValue) [virtual]

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

Reimplemented from CToken.

Definition at line 283 of file nsHTMLTokens.cpp.

                                        {
  mEmpty=aValue;
}
void CToken::SetInError ( PRBool  aInError) [inline, inherited]

Definition at line 267 of file nsToken.h.

    {
      mInError = aInError;
    }

Here is the caller graph for this function:

void CToken::SetLineNumber ( PRInt32  aLineNumber) [inline, inherited]

Definition at line 262 of file nsToken.h.

    { 
      mLineNumber = mLineNumber == 0 ? aLineNumber : mLineNumber;
    }
void CToken::SetNewlineCount ( PRInt32  aCount) [inline, inherited]

Definition at line 252 of file nsToken.h.

Here is the caller graph for this function:

void CToken::SetTypeID ( PRInt32  aValue) [inline, inherited]

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

Parameters:
valueis the new ord value for this token

Definition at line 196 of file nsToken.h.

                                   {
      mTypeID = aValue;
    }

Here is the caller graph for this function:

virtual size_t CToken::SizeOf ( ) const [protected, pure virtual, inherited]

Returns the size of the token object.

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class nsTokenAllocator [friend, inherited]

Definition at line 115 of file nsToken.h.


Member Data Documentation

PRInt16 CToken::mAttrCount [protected, inherited]

Definition at line 300 of file nsToken.h.

Definition at line 159 of file nsHTMLTokens.h.

Definition at line 160 of file nsHTMLTokens.h.

PRUint32 CToken::mInError [protected, inherited]

Definition at line 299 of file nsToken.h.

PRUint32 CToken::mLineNumber [protected, inherited]

Definition at line 298 of file nsToken.h.

PRInt32 CToken::mNewlineCount [protected, inherited]

Definition at line 297 of file nsToken.h.

Definition at line 157 of file nsHTMLTokens.h.

PRInt32 CToken::mTypeID [protected, inherited]

Definition at line 295 of file nsToken.h.

PRInt32 CToken::mUseCount [protected, inherited]

Definition at line 296 of file nsToken.h.


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