1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Netscape Public License
6
* Version 1.1 (the "License"); you may not use this file except in
7
* compliance with the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/NPL/
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
15
* The Original Code is mozilla.org code.
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.
25
* Alternatively, the contents of this file may be used under the terms of
26
* either the GNU General Public License Version 2 or later (the "GPL"), or
27
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
* in which case the provisions of the GPL or the LGPL are applicable instead
29
* of those above. If you wish to allow use of your version of this file only
30
* under the terms of either the GPL or the LGPL, and not to allow others to
31
* use your version of this file under the terms of the NPL, indicate your
32
* decision by deleting the provisions above and replace them with the notice
33
* and other provisions required by the GPL or the LGPL. If you do not delete
34
* the provisions above, a recipient may use your version of this file under
35
* the terms of any one of the NPL, the GPL or the LGPL.
37
* ***** END LICENSE BLOCK ***** */
40
#include "nsScanner.h"
43
#ifdef MATCH_CTOR_DTOR
44
MOZ_DECL_CTOR_COUNTER(CToken)
47
static int TokenCount=0;
48
static int DelTokenCount=0;
50
int CToken::GetTokenCount(){return TokenCount-DelTokenCount;}
53
/**************************************************************
54
And now for the CToken...
55
**************************************************************/
60
* @update gess 7/21/98
62
CToken::CToken(PRInt32 aTag) {
63
// Tokens are allocated through the arena ( not heap allocated..yay ).
64
// We, therefore, don't need this macro anymore..
65
#ifdef MATCH_CTOR_DTOR
66
MOZ_COUNT_CTOR(CToken);
72
// Note that the use count starts with 1 instead of 0. This
73
// is because of the assumption that any token created is in
74
// use and therefore does not require an explicit addref, or
75
// rather IF_HOLD. This, also, will make sure that tokens created
76
// on the stack do not accidently hit the arena recycler.
87
* @update gess 3/25/98
90
// Tokens are allocated through the arena ( not heap allocated..yay ).
91
// We, therefore, don't need this macro anymore..
92
#ifdef MATCH_CTOR_DTOR
93
MOZ_COUNT_DTOR(CToken);
101
* Virtual method used to tell this toke to consume his
104
* @update gess 3/25/98
105
* @param aChar -- first char in sequence
106
* @param aScanner -- object to retrieve data from
107
* @return int error code
109
nsresult CToken::Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode) {
110
nsresult result=NS_OK;
115
* Get string of full contents, suitable for debug dump.
116
* It should look exactly like the input source.
117
* @update gess5/11/98
118
* @return reference to string containing string value
120
void CToken::GetSource(nsString& anOutputString){
121
anOutputString.Assign(GetStringValue());
125
* @update harishd 3/23/00
126
* @return reference to string containing string value
128
void CToken::AppendSourceTo(nsAString& anOutputString){
129
anOutputString.Append(GetStringValue());
133
* Sets the internal ordinal value for this token.
134
* This method is deprecated, and will soon be going away.
136
* @update gess 3/25/98
137
* @param value -- new ordinal value for this token
139
void CToken::SetTypeID(PRInt32 aTypeID) {
144
* Retrieves copy of internal ordinal value.
145
* This method is deprecated, and will soon be going away.
147
* @update gess 3/25/98
148
* @return int containing ordinal value
150
PRInt32 CToken::GetTypeID(void) {
155
* Retrieves copy of attr count for this token
157
* @update gess 3/25/98
158
* @return int containing attribute count
160
PRInt16 CToken::GetAttributeCount(void) {
166
* Retrieve type of token. This class returns -1, but
167
* subclasses return something more meaningful.
169
* @update gess 3/25/98
170
* @return int value containing token type.
172
PRInt32 CToken::GetTokenType(void) {
177
* retrieve this tokens classname.
179
* @update gess 3/25/98
180
* @return char* containing name of class
182
const char* CToken::GetClassName(void) {
189
* @update gess 3/25/98
191
void CToken::SelfTest(void) {