~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/htmlparser/src/nsToken.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
4
 *
 
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/
 
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
 *
 
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.
 
36
 *
 
37
 * ***** END LICENSE BLOCK ***** */
 
38
 
 
39
#include "nsToken.h"
 
40
#include "nsScanner.h"
 
41
 
 
42
 
 
43
#ifdef MATCH_CTOR_DTOR    
 
44
MOZ_DECL_CTOR_COUNTER(CToken)
 
45
#endif
 
46
 
 
47
static int TokenCount=0;
 
48
static int DelTokenCount=0;
 
49
 
 
50
int CToken::GetTokenCount(){return TokenCount-DelTokenCount;}
 
51
 
 
52
 
 
53
/**************************************************************
 
54
  And now for the CToken...
 
55
 **************************************************************/
 
56
 
 
57
/**
 
58
 *  Default constructor
 
59
 *  
 
60
 *  @update gess 7/21/98
 
61
 */
 
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);
 
67
#endif 
 
68
  mAttrCount=0;
 
69
  mNewlineCount=0;
 
70
  mLineNumber = 0;
 
71
  mTypeID=aTag;
 
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.
 
77
  mUseCount=1;
 
78
 
 
79
#ifdef NS_DEBUG
 
80
  ++TokenCount;
 
81
#endif
 
82
}
 
83
 
 
84
/**
 
85
 *  Decstructor
 
86
 *  
 
87
 *  @update gess 3/25/98
 
88
 */
 
89
CToken::~CToken() {
 
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);
 
94
#endif
 
95
  ++DelTokenCount;
 
96
  mUseCount=0;
 
97
}
 
98
 
 
99
 
 
100
/**
 
101
 *  Virtual method used to tell this toke to consume his
 
102
 *  valid chars.
 
103
 *  
 
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
 
108
 */
 
109
nsresult CToken::Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode) {
 
110
  nsresult result=NS_OK;
 
111
  return result;
 
112
}
 
113
 
 
114
/**
 
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
 
119
 */
 
120
void CToken::GetSource(nsString& anOutputString){
 
121
  anOutputString.Assign(GetStringValue());
 
122
}
 
123
 
 
124
/**
 
125
 * @update      harishd 3/23/00
 
126
 * @return  reference to string containing string value
 
127
 */
 
128
void CToken::AppendSourceTo(nsAString& anOutputString){
 
129
  anOutputString.Append(GetStringValue());
 
130
}
 
131
 
 
132
/**
 
133
 *  Sets the internal ordinal value for this token.
 
134
 *  This method is deprecated, and will soon be going away.
 
135
 *  
 
136
 *  @update gess 3/25/98
 
137
 *  @param  value -- new ordinal value for this token
 
138
 */
 
139
void CToken::SetTypeID(PRInt32 aTypeID) {
 
140
  mTypeID=aTypeID;
 
141
}
 
142
 
 
143
/**
 
144
 *  Retrieves copy of internal ordinal value.
 
145
 *  This method is deprecated, and will soon be going away.
 
146
 *  
 
147
 *  @update gess 3/25/98
 
148
 *  @return int containing ordinal value
 
149
 */
 
150
PRInt32 CToken::GetTypeID(void) {
 
151
  return mTypeID;
 
152
}
 
153
 
 
154
/**
 
155
 *  Retrieves copy of attr count for this token
 
156
 *  
 
157
 *  @update gess 3/25/98
 
158
 *  @return int containing attribute count
 
159
 */
 
160
PRInt16  CToken::GetAttributeCount(void) {
 
161
  return mAttrCount;
 
162
}
 
163
 
 
164
 
 
165
/**
 
166
 *  Retrieve type of token. This class returns -1, but 
 
167
 *  subclasses return something more meaningful.
 
168
 *  
 
169
 *  @update gess 3/25/98
 
170
 *  @return int value containing token type.
 
171
 */
 
172
PRInt32  CToken::GetTokenType(void) {
 
173
  return -1;
 
174
}
 
175
 
 
176
/**
 
177
 *  retrieve this tokens classname.  
 
178
 *  
 
179
 *  @update gess 3/25/98
 
180
 *  @return char* containing name of class
 
181
 */
 
182
const char*  CToken::GetClassName(void) {
 
183
  return "token";
 
184
}
 
185
 
 
186
 
 
187
/**
 
188
 *  
 
189
 *  @update gess 3/25/98
 
190
 */
 
191
void CToken::SelfTest(void) {
 
192
#ifdef _DEBUG
 
193
#endif
 
194
}
 
195
 
 
196