PageRenderTime 18ms CodeModel.GetById 9ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/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
 39/**
 40 * MODULE NOTES:
 41 * @update  gess 4/1/98
 42 * 
 43 * This class is defines the basic interface between the
 44 * parser and the content sink. The parser will iterate
 45 * over the collection of tokens that it sees from the
 46 * tokenizer, coverting each related "group" into one of
 47 * these. This object gets passed to the sink, and is
 48 * then immediately reused.
 49 *
 50 * If you want to hang onto one of these, you should
 51 * make your own copy.
 52 *
 53 */
 54
 55#ifndef NS_IPARSERNODE__
 56#define NS_IPARSERNODE__
 57
 58#include "nsISupports.h"
 59#include "prtypes.h"
 60#include "nsStringGlue.h"
 61#include "nsDebug.h"
 62
 63//#define HEAP_ALLOCATED_NODES 
 64//#define DEBUG_TRACK_NODES
 65
 66class nsIAtom;
 67class CToken;
 68
 69// 6e59f160-2717-11d2-9246-00805f8a7ab6
 70#define NS_IPARSER_NODE_IID      \
 71  {0x6e59f160, 0x2717,  0x11d1,  \
 72  {0x92, 0x46, 0x00,    0x80, 0x5f, 0x8a, 0x7a, 0xb6}}
 73
 74/**
 75 *  Parser nodes are the unit of exchange between the 
 76 *  parser and the content sink. Nodes offer access to
 77 *  the current token, its attributes, and its skipped-
 78 *  content if applicable.
 79 *  
 80 *  @update  gess 3/25/98
 81 */
 82class nsIParserNode { // XXX Should be nsAParserNode
 83            
 84  public:
 85
 86
 87    /**
 88     * Retrieve the name of the node
 89     * @update	gess5/11/98
 90     * @return  string containing node name
 91     */
 92    virtual const nsAString& GetTagName() const = 0;  //to get name of tag
 93
 94    /**
 95     * Retrieve the text from the given node
 96     * @update	gess5/11/98
 97     * @return  string containing node text
 98     */
 99    virtual const nsAString& GetText() const = 0;  //get plain text if available
100
101    /**
102     * Retrieve the type of the parser node.
103     * @update	gess5/11/98
104     * @return  node type.
105     */
106    virtual PRInt32 GetNodeType()  const =0;
107
108    /**
109     * Retrieve token type of parser node
110     * @update	gess5/11/98
111     * @return  token type
112     */
113    virtual PRInt32 GetTokenType()  const =0;
114
115    /**
116     * Retrieve the number of attributes in this node.
117     * @update	gess5/11/98
118     * @return  count of attributes (may be 0)
119     */
120    virtual PRInt32 GetAttributeCount(bool askToken=false) const =0;
121
122    /**
123     * Retrieve the key (of key/value pair) at given index
124     * @update	gess5/11/98
125     * @param   anIndex is the index of the key you want
126     * @return  string containing key.
127     */
128    virtual const nsAString& GetKeyAt(PRUint32 anIndex) const = 0;
129
130    /**
131     * Retrieve the value (of key/value pair) at given index
132     * @update	gess5/11/98
133     * @param   anIndex is the index of the value you want
134     * @return  string containing value.
135     */
136    virtual const nsAString& GetValueAt(PRUint32 anIndex) const = 0;
137
138    /**
139     * NOTE: When the node is an entity, this will translate the entity
140     *       to it's unicode value, and store it in aString.
141     * @update	gess5/11/98
142     * @param   aString will contain the resulting unicode string value
143     * @return  int (unicode char or unicode index from table)
144     */
145    virtual PRInt32 TranslateToUnicodeStr(nsString& aString) const = 0;
146
147
148    virtual void AddAttribute(CToken* aToken)=0;
149
150    /**
151     * This getter retrieves the line number from the input source where
152     * the token occurred. Lines are interpreted as occurring between \n characters.
153     * @update	gess7/24/98
154     * @return  int containing the line number the token was found on
155     */
156    virtual PRInt32 GetSourceLineNumber(void) const =0;
157
158    /**
159     * This pair of methods allows us to set a generic bit (for arbitrary use)
160     * on each node stored in the context.
161     * @update	gess 11May2000
162     */
163    virtual bool    GetGenericState(void) const =0;
164    virtual void    SetGenericState(bool aState) =0;
165
166    /** Retrieve a string containing the tag and its attributes in "source" form
167     * @update	rickg 06June2000
168     * @return  void
169     */
170    virtual void GetSource(nsString& aString) const = 0;
171
172    /** Release all the objects you're holding
173     * @update	harishd 08/02/00
174     * @return  void
175     */
176    virtual nsresult ReleaseAll()=0;
177};
178
179#endif