Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Public Attributes | Static Protected Member Functions | Protected Attributes
nsCParserStartNode Class Reference

#include <nsParserNode.h>

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

List of all members.

Public Member Functions

 nsCParserStartNode ()
 nsCParserStartNode (CToken *aToken, nsTokenAllocator *aTokenAllocator, nsNodeAllocator *aNodeAllocator=0)
virtual ~nsCParserStartNode ()
virtual nsresult Init (CToken *aToken, nsTokenAllocator *aTokenAllocator, nsNodeAllocator *aNodeAllocator=0)
 Init gess5/11/98.
virtual void AddAttribute (CToken *aToken)
 gess5/11/98
virtual PRInt32 GetAttributeCount (PRBool askToken=PR_FALSE) const
 Retrieve the number of attributes in this node.
virtual const nsAString & GetKeyAt (PRUint32 anIndex) const
 Retrieve the key (of key/value pair) at given index gess5/11/98.
virtual const nsAString & GetValueAt (PRUint32 anIndex) const
 Retrieve the value (of key/value pair) at given index gess5/11/98.
virtual CTokenPopAttributeToken ()
 This method pop the attribute token from the given index harishd 03/25/99.
virtual CTokenPopAttributeTokenFront ()
 Like PopAttributeToken, but pops off the front of the attribute list.
virtual void GetSource (nsString &aString)
 Retrieve a string containing the tag and its attributes in "source" form rickg 06June2000.
virtual nsresult ReleaseAll ()
 Release all the objects you're holding harishd 08/02/00.
void AddRef ()
void Release (nsFixedSizeAllocator &aPool)
virtual const nsAString & GetTagName () const
 Retrieve the name of the node gess5/11/98.
virtual const nsAString & GetText () const
 Retrieve the text from the given node gess5/11/98.
virtual PRInt32 GetNodeType () const
 Retrieve the type of the parser node.
virtual PRInt32 GetTokenType () const
 Retrieve token type of parser node gess5/11/98.
virtual PRInt32 TranslateToUnicodeStr (nsString &aString) const
 NOTE: When the node is an entity, this will translate the entity to it's unicode value, and store it in aString.
virtual PRInt32 GetSourceLineNumber (void) const
 This getter retrieves the line number from the input source where the token occured.
virtual PRBool GetGenericState (void) const
 This pair of methods allows us to set a generic bit (for arbitrary use) on each node stored in the context.
virtual void SetGenericState (PRBool aState)

Static Public Member Functions

static nsCParserNodeCreate (CToken *aToken, nsTokenAllocator *aTokenAllocator, nsNodeAllocator *aNodeAllocator)
static void Destroy (nsCParserNode *aNode, nsFixedSizeAllocator &aPool)

Public Attributes

PRPackedBool mGenericState
PRInt32 mUseCount
CTokenmToken
nsTokenAllocatormTokenAllocator

Static Protected Member Functions

static voidoperator new (size_t) CPP_THROW_NEW
 Hide operator new; clients should use Create() instead.
static void operator delete (void *, size_t)
 Hide operator delete; clients should use Destroy() instead.

Protected Attributes

nsDeque mAttributes
PRInt32 mRefCnt

Detailed Description

Definition at line 275 of file nsParserNode.h.


Constructor & Destructor Documentation

Definition at line 292 of file nsParserNode.h.

Here is the caller graph for this function:

nsCParserStartNode::nsCParserStartNode ( CToken aToken,
nsTokenAllocator aTokenAllocator,
nsNodeAllocator aNodeAllocator = 0 
) [inline]

Definition at line 295 of file nsParserNode.h.

      : nsCParserNode(aToken, aTokenAllocator, aNodeAllocator), mAttributes(0) { }
virtual nsCParserStartNode::~nsCParserStartNode ( ) [inline, virtual]

Definition at line 300 of file nsParserNode.h.

    {
      NS_ASSERTION(mTokenAllocator || mAttributes.GetSize() == 0,
                   "Error: no token allocator");
      CToken* theAttrToken = 0;
      while ((theAttrToken = NS_STATIC_CAST(CToken*, mAttributes.Pop()))) {
        IF_FREE(theAttrToken, mTokenAllocator);
      }
    }

Member Function Documentation

void nsCParserStartNode::AddAttribute ( CToken aToken) [virtual]

gess5/11/98

Parameters:
@return

Reimplemented from nsCParserNode.

Definition at line 310 of file nsParserNode.cpp.

{
  NS_ASSERTION(0 != aToken, "Error: Token shouldn't be null!");
  mAttributes.Push(aToken);
}

Here is the caller graph for this function:

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

Definition at line 75 of file nsParserNode.h.

    {
      ++mRefCnt;
    }
static nsCParserNode* nsCParserStartNode::Create ( CToken aToken,
nsTokenAllocator aTokenAllocator,
nsNodeAllocator aNodeAllocator 
) [inline, static]

Reimplemented from nsCParserNode.

Definition at line 278 of file nsParserNode.h.

    {
#ifdef HEAP_ALLOCATED_NODES
      return new
#else
      nsFixedSizeAllocator& pool = aNodeAllocator->GetArenaPool();
      void* place = pool.Alloc(sizeof(nsCParserStartNode));
      return ::new (place)
#endif
        nsCParserStartNode(aToken, aTokenAllocator, aNodeAllocator);
    }

Here is the call graph for this function:

static void nsCParserNode::Destroy ( nsCParserNode aNode,
nsFixedSizeAllocator &  aPool 
) [inline, static, inherited]

Definition at line 116 of file nsParserNode.h.

    {
#ifdef HEAP_ALLOCATED_NODES
      delete aNode;
#else
      aNode->~nsCParserNode();
      aPool.Free(aNode, sizeof(*aNode));
#endif
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Retrieve the number of attributes in this node.

Retrieve the number of attributes on this node.

gess5/11/98

Returns:
count of attributes (may be 0)

gess 3/25/98

Parameters:
@returnint -- representing attribute count

Reimplemented from nsCParserNode.

Definition at line 317 of file nsParserNode.cpp.

{
  PRInt32 result = 0;
  if (askToken) {
    result = mToken ? mToken->GetAttributeCount() : 0;
  }
  else {
    result = mAttributes.GetSize();
  }
  return result;
}

Here is the call graph for this function:

virtual PRBool nsCParserNode::GetGenericState ( void  ) const [inline, virtual, inherited]

This pair of methods allows us to set a generic bit (for arbitrary use) on each node stored in the context.

gess 11May2000

Implements nsIParserNode.

Definition at line 255 of file nsParserNode.h.

{return mGenericState;}
const nsAString & nsCParserStartNode::GetKeyAt ( PRUint32  anIndex) const [virtual]

Retrieve the key (of key/value pair) at given index gess5/11/98.

Retrieve the string rep of the attribute key at the given index.

Parameters:
anIndexis the index of the key you want
Returns:
string containing key.

gess 3/25/98

Parameters:
anIndex--offset of attribute to retrieve
Returns:
string rep of given attribute text key

Reimplemented from nsCParserNode.

Definition at line 330 of file nsParserNode.cpp.

{
  if ((PRInt32)anIndex < mAttributes.GetSize()) {
    CAttributeToken* attr = 
      NS_STATIC_CAST(CAttributeToken*, mAttributes.ObjectAt(anIndex));
    if (attr) {
      return attr->GetKey();
    }
  }
  return EmptyString();
}

Here is the call graph for this function:

PRInt32 nsCParserNode::GetNodeType ( void  ) const [virtual, inherited]

Retrieve the type of the parser node.

Get node type, meaning, get the tag type of the underlying token.

gess5/11/98

Returns:
node type.

gess 3/25/98

Parameters:
@returnint value that represents tag type

Implements nsIParserNode.

Definition at line 174 of file nsParserNode.cpp.

{
  return (mToken) ? mToken->GetTypeID() : 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsCParserStartNode::GetSource ( nsString aString) [virtual]

Retrieve a string containing the tag and its attributes in "source" form rickg 06June2000.

Returns:
void

Reimplemented from nsCParserNode.

Definition at line 367 of file nsParserNode.cpp.

{
  aString.Assign(PRUnichar('<'));
  const PRUnichar* theTagName = 
    nsHTMLTags::GetStringValue(nsHTMLTag(mToken->GetTypeID()));
  if (theTagName) {
    aString.Append(theTagName);
  }
  PRInt32 index;
  PRInt32 size = mAttributes.GetSize();
  for (index = 0 ; index < size; ++index) {
    CAttributeToken *theToken = 
      NS_STATIC_CAST(CAttributeToken*, mAttributes.ObjectAt(index));
    if (theToken) {
      theToken->AppendSourceTo(aString);
      aString.Append(PRUnichar(' ')); //this will get removed...
    }
  }
  aString.Append(PRUnichar('>'));
}

Here is the call graph for this function:

PRInt32 nsCParserNode::GetSourceLineNumber ( void  ) const [virtual, inherited]

This getter retrieves the line number from the input source where the token occured.

Lines are interpreted as occuring between
characters. gess7/24/98

Returns:
int containing the line number the token was found on

Implements nsIParserNode.

Definition at line 252 of file nsParserNode.cpp.

                                             {
  return mToken ? mToken->GetLineNumber() : 0;
}

Here is the call graph for this function:

const nsAString & nsCParserNode::GetTagName ( ) const [virtual, inherited]

Retrieve the name of the node gess5/11/98.

Gets the name of this node.

Returns:
string containing node name

Currently unused.

gess 3/25/98

Parameters:
@returnstring ref containing node name

Implements nsIParserNode.

Definition at line 143 of file nsParserNode.cpp.

                                {
  return EmptyString();
}
const nsAString & nsCParserNode::GetText ( ) const [virtual, inherited]

Retrieve the text from the given node gess5/11/98.

Get text value of this node, which translates into getting the text value of the underlying token.

Returns:
string containing node text

gess 3/25/98

Parameters:
@returnstring ref of text from internal token

Implements nsIParserNode.

Definition at line 157 of file nsParserNode.cpp.

{
  if (mToken) {
    return mToken->GetStringValue();
  }
  return EmptyString();
}

Here is the call graph for this function:

PRInt32 nsCParserNode::GetTokenType ( void  ) const [virtual, inherited]

Retrieve token type of parser node gess5/11/98.

Gets the token type, which corresponds to a value from eHTMLTokens_xxx.

Returns:
token type

gess 3/25/98

Parameters:
@return

Implements nsIParserNode.

Definition at line 189 of file nsParserNode.cpp.

{
  return (mToken) ? mToken->GetTokenType() : 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const nsAString & nsCParserStartNode::GetValueAt ( PRUint32  anIndex) const [virtual]

Retrieve the value (of key/value pair) at given index gess5/11/98.

Retrieve the string rep of the attribute at given offset.

Parameters:
anIndexis the index of the value you want
Returns:
string containing value.

gess 3/25/98

Parameters:
anIndex--offset of attribute to retrieve
Returns:
string rep of given attribute text value

Reimplemented from nsCParserNode.

Definition at line 343 of file nsParserNode.cpp.

{
  if (PRInt32(anIndex) < mAttributes.GetSize()) {
    CAttributeToken* attr = 
      NS_STATIC_CAST(CAttributeToken*, mAttributes.ObjectAt(anIndex));
    if (attr) {
      return attr->GetValue();
    }
  }
  return EmptyString();
}

Here is the call graph for this function:

nsresult nsCParserStartNode::Init ( CToken aToken,
nsTokenAllocator aTokenAllocator,
nsNodeAllocator aNodeAllocator = 0 
) [virtual]

Init gess5/11/98.

Init.

gess 3/25/98

Parameters:
@return

Reimplemented from nsCParserNode.

Definition at line 302 of file nsParserNode.cpp.

{
  NS_ASSERTION(mAttributes.GetSize() == 0, "attributes not recycled!");
  return nsCParserNode::Init(aToken, aTokenAllocator, aNodeAllocator);
}

Here is the caller graph for this function:

static void nsCParserNode::operator delete ( void ,
size_t   
) [inline, static, protected, inherited]

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

Definition at line 97 of file nsParserNode.h.

{}
static void* nsCParserNode::operator new ( size_t  ) [inline, static, protected, inherited]

Hide operator new; clients should use Create() instead.

Definition at line 92 of file nsParserNode.h.

{ return 0; }

This method pop the attribute token from the given index harishd 03/25/99.

This method pop the attribute token harishd 03/25/99.

Returns:
token at anIndex

Reimplemented from nsCParserNode.

Definition at line 356 of file nsParserNode.cpp.

{
  return NS_STATIC_CAST(CToken*, mAttributes.Pop());
}

Like PopAttributeToken, but pops off the front of the attribute list.

Reimplemented from nsCParserNode.

Definition at line 362 of file nsParserNode.cpp.

{
  return NS_STATIC_CAST(CToken*, mAttributes.PopFront());
}
void nsCParserNode::Release ( nsFixedSizeAllocator &  aPool) [inline, inherited]

Definition at line 80 of file nsParserNode.h.

    {
      if (--mRefCnt == 0)
        Destroy(this, aPool);
    }

Here is the call graph for this function:

Release all the objects you're holding harishd 08/02/00.

Release all the objects you're holding to.

Returns:
void

harishd 08/02/00

Returns:
void

Reimplemented from nsCParserNode.

Definition at line 388 of file nsParserNode.cpp.

{
  NS_ASSERTION(0!=mTokenAllocator, "Error: no token allocator");
  CToken* theAttrToken;
  while ((theAttrToken = NS_STATIC_CAST(CToken*, mAttributes.Pop()))) {
    IF_FREE(theAttrToken, mTokenAllocator);
  }
  nsCParserNode::ReleaseAll();
  return NS_OK; 
}

Here is the caller graph for this function:

virtual void nsCParserNode::SetGenericState ( PRBool  aState) [inline, virtual, inherited]

Implements nsIParserNode.

Definition at line 256 of file nsParserNode.h.

{mGenericState=aState;}
PRInt32 nsCParserNode::TranslateToUnicodeStr ( nsString aString) const [virtual, inherited]

NOTE: When the node is an entity, this will translate the entity to it's unicode value, and store it in aString.

gess5/11/98

Parameters:
aStringwill contain the resulting unicode string value
Returns:
int (unicode char or unicode index from table)

Implements nsIParserNode.

Definition at line 237 of file nsParserNode.cpp.

{
  if (eToken_entity == mToken->GetTokenType()) {
    return ((CEntityToken*)mToken)->TranslateToUnicodeStr(aString);
  }
  return -1;
}

Here is the call graph for this function:


Member Data Documentation

nsDeque nsCParserStartNode::mAttributes [protected]

Definition at line 322 of file nsParserNode.h.

Definition at line 264 of file nsParserNode.h.

PRInt32 nsCParserNode::mRefCnt [protected, inherited]

Definition at line 71 of file nsParserNode.h.

Definition at line 266 of file nsParserNode.h.

Definition at line 268 of file nsParserNode.h.

Definition at line 265 of file nsParserNode.h.


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