]> git.saurik.com Git - iphone-api.git/blob - WebCore/Tokenizer.h
Adding the WebCore headers (for Cydget).
[iphone-api.git] / WebCore / Tokenizer.h
1 /*
2 * This file is part of the DOM implementation for KDE.
3 *
4 * Copyright (C) 2000 Peter Kelly (pmk@post.com)
5 * Copyright (C) 2005, 2006 Apple Computer, Inc.
6 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org)
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 *
23 */
24
25 #ifndef Tokenizer_h
26 #define Tokenizer_h
27
28 namespace WebCore {
29
30 class SegmentedString;
31
32 class Tokenizer {
33 public:
34 virtual ~Tokenizer() { }
35
36 // Script output must be prepended, while new data
37 // received during executing a script must be appended, hence the
38 // extra bool to be able to distinguish between both cases.
39 // document.write() always uses false, while the loader uses true.
40 virtual bool write(const SegmentedString&, bool appendData) = 0;
41 virtual void finish() = 0;
42 virtual bool isWaitingForScripts() const = 0;
43 virtual void stopParsing() { m_parserStopped = true; }
44 virtual bool processingData() const { return false; }
45 virtual int executingScript() const { return 0; }
46
47 virtual bool wantsRawData() const { return false; }
48 virtual bool writeRawData(const char* /*data*/, int /*length*/) { return false; }
49
50 bool inViewSourceMode() const { return m_inViewSourceMode; }
51 void setInViewSourceMode(bool mode) { m_inViewSourceMode = mode; }
52
53 virtual bool wellFormed() const { return true; }
54
55 virtual int lineNumber() const { return -1; }
56 virtual int columnNumber() const { return -1; }
57
58 virtual void executeScriptsWaitingForStylesheets() {}
59
60 virtual bool isHTMLTokenizer() const { return false; }
61
62 virtual void parsePending() { }
63
64 protected:
65 Tokenizer(bool viewSourceMode = false)
66 : m_parserStopped(false)
67 , m_inViewSourceMode(viewSourceMode)
68 {
69 }
70
71 // The tokenizer has buffers, so parsing may continue even after
72 // it stops receiving data. We use m_parserStopped to stop the tokenizer
73 // even when it has buffered data.
74 bool m_parserStopped;
75 bool m_inViewSourceMode;
76 };
77
78 } // namespace WebCore
79
80 #endif // Tokenizer_h