/parser/htmlparser/public/nsIParserNode.h

http://github.com/zpao/v8monkey · C Header · 179 lines · 29 code · 25 blank · 125 comment · 0 complexity · dbecbf3e5952cc81629596ad049ee553 MD5 · raw file

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. * http://www.mozilla.org/MPL/
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. *
  15. * The Original Code is mozilla.org code.
  16. *
  17. * The Initial Developer of the Original Code is
  18. * Netscape Communications Corporation.
  19. * Portions created by the Initial Developer are Copyright (C) 1998
  20. * the Initial Developer. All Rights Reserved.
  21. *
  22. * Contributor(s):
  23. *
  24. * Alternatively, the contents of this file may be used under the terms of
  25. * either of the GNU General Public License Version 2 or later (the "GPL"),
  26. * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27. * in which case the provisions of the GPL or the LGPL are applicable instead
  28. * of those above. If you wish to allow use of your version of this file only
  29. * under the terms of either the GPL or the LGPL, and not to allow others to
  30. * use your version of this file under the terms of the MPL, indicate your
  31. * decision by deleting the provisions above and replace them with the notice
  32. * and other provisions required by the GPL or the LGPL. If you do not delete
  33. * the provisions above, a recipient may use your version of this file under
  34. * the terms of any one of the MPL, the GPL or the LGPL.
  35. *
  36. * ***** END LICENSE BLOCK ***** */
  37. /**
  38. * MODULE NOTES:
  39. * @update gess 4/1/98
  40. *
  41. * This class is defines the basic interface between the
  42. * parser and the content sink. The parser will iterate
  43. * over the collection of tokens that it sees from the
  44. * tokenizer, coverting each related "group" into one of
  45. * these. This object gets passed to the sink, and is
  46. * then immediately reused.
  47. *
  48. * If you want to hang onto one of these, you should
  49. * make your own copy.
  50. *
  51. */
  52. #ifndef NS_IPARSERNODE__
  53. #define NS_IPARSERNODE__
  54. #include "nsISupports.h"
  55. #include "prtypes.h"
  56. #include "nsStringGlue.h"
  57. #include "nsDebug.h"
  58. //#define HEAP_ALLOCATED_NODES
  59. //#define DEBUG_TRACK_NODES
  60. class nsIAtom;
  61. class CToken;
  62. // 6e59f160-2717-11d2-9246-00805f8a7ab6
  63. #define NS_IPARSER_NODE_IID \
  64. {0x6e59f160, 0x2717, 0x11d1, \
  65. {0x92, 0x46, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6}}
  66. /**
  67. * Parser nodes are the unit of exchange between the
  68. * parser and the content sink. Nodes offer access to
  69. * the current token, its attributes, and its skipped-
  70. * content if applicable.
  71. *
  72. * @update gess 3/25/98
  73. */
  74. class nsIParserNode { // XXX Should be nsAParserNode
  75. public:
  76. /**
  77. * Retrieve the name of the node
  78. * @update gess5/11/98
  79. * @return string containing node name
  80. */
  81. virtual const nsAString& GetTagName() const = 0; //to get name of tag
  82. /**
  83. * Retrieve the text from the given node
  84. * @update gess5/11/98
  85. * @return string containing node text
  86. */
  87. virtual const nsAString& GetText() const = 0; //get plain text if available
  88. /**
  89. * Retrieve the type of the parser node.
  90. * @update gess5/11/98
  91. * @return node type.
  92. */
  93. virtual PRInt32 GetNodeType() const =0;
  94. /**
  95. * Retrieve token type of parser node
  96. * @update gess5/11/98
  97. * @return token type
  98. */
  99. virtual PRInt32 GetTokenType() const =0;
  100. /**
  101. * Retrieve the number of attributes in this node.
  102. * @update gess5/11/98
  103. * @return count of attributes (may be 0)
  104. */
  105. virtual PRInt32 GetAttributeCount(bool askToken=false) const =0;
  106. /**
  107. * Retrieve the key (of key/value pair) at given index
  108. * @update gess5/11/98
  109. * @param anIndex is the index of the key you want
  110. * @return string containing key.
  111. */
  112. virtual const nsAString& GetKeyAt(PRUint32 anIndex) const = 0;
  113. /**
  114. * Retrieve the value (of key/value pair) at given index
  115. * @update gess5/11/98
  116. * @param anIndex is the index of the value you want
  117. * @return string containing value.
  118. */
  119. virtual const nsAString& GetValueAt(PRUint32 anIndex) const = 0;
  120. /**
  121. * NOTE: When the node is an entity, this will translate the entity
  122. * to it's unicode value, and store it in aString.
  123. * @update gess5/11/98
  124. * @param aString will contain the resulting unicode string value
  125. * @return int (unicode char or unicode index from table)
  126. */
  127. virtual PRInt32 TranslateToUnicodeStr(nsString& aString) const = 0;
  128. virtual void AddAttribute(CToken* aToken)=0;
  129. /**
  130. * This getter retrieves the line number from the input source where
  131. * the token occurred. Lines are interpreted as occurring between \n characters.
  132. * @update gess7/24/98
  133. * @return int containing the line number the token was found on
  134. */
  135. virtual PRInt32 GetSourceLineNumber(void) const =0;
  136. /**
  137. * This pair of methods allows us to set a generic bit (for arbitrary use)
  138. * on each node stored in the context.
  139. * @update gess 11May2000
  140. */
  141. virtual bool GetGenericState(void) const =0;
  142. virtual void SetGenericState(bool aState) =0;
  143. /** Retrieve a string containing the tag and its attributes in "source" form
  144. * @update rickg 06June2000
  145. * @return void
  146. */
  147. virtual void GetSource(nsString& aString) const = 0;
  148. /** Release all the objects you're holding
  149. * @update harishd 08/02/00
  150. * @return void
  151. */
  152. virtual nsresult ReleaseAll()=0;
  153. };
  154. #endif