1 | /* |
---|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
---|
3 | * contributor license agreements. See the NOTICE file distributed with |
---|
4 | * this work for additional information regarding copyright ownership. |
---|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
6 | * (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 | * |
---|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
10 | * |
---|
11 | * Unless required by applicable law or agreed to in writing, software |
---|
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
14 | * See the License for the specific language governing permissions and |
---|
15 | * limitations under the License. |
---|
16 | */ |
---|
17 | |
---|
18 | /* |
---|
19 | * $Id: XMLPScanToken.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
20 | */ |
---|
21 | |
---|
22 | |
---|
23 | #if !defined(XMLPSCANTOKEN_HPP) |
---|
24 | #define XMLPSCANTOKEN_HPP |
---|
25 | |
---|
26 | #include <xercesc/util/XMemory.hpp> |
---|
27 | |
---|
28 | XERCES_CPP_NAMESPACE_BEGIN |
---|
29 | |
---|
30 | class XMLScanner; |
---|
31 | |
---|
32 | /** |
---|
33 | * This simple class is used as a sanity check when the scanner is used to |
---|
34 | * do progressive parsing. It insures that things are not done out of |
---|
35 | * sequence and that sequences of scan calls are made correctly to the |
---|
36 | * right scanner instances. |
---|
37 | * |
---|
38 | * To client code, it is just a magic cookie which is obtained when a |
---|
39 | * progressive parse is begun, and which is passed back in on each subsequent |
---|
40 | * call of the progressive parse. |
---|
41 | */ |
---|
42 | class XMLPARSER_EXPORT XMLPScanToken : public XMemory |
---|
43 | { |
---|
44 | public : |
---|
45 | // ----------------------------------------------------------------------- |
---|
46 | // Constructors and Destructor |
---|
47 | // ----------------------------------------------------------------------- |
---|
48 | /** @name Constructor */ |
---|
49 | //@{ |
---|
50 | XMLPScanToken(); |
---|
51 | XMLPScanToken(const XMLPScanToken& toCopy); |
---|
52 | //@} |
---|
53 | |
---|
54 | /** @name Destructor */ |
---|
55 | //@{ |
---|
56 | ~XMLPScanToken(); |
---|
57 | //@} |
---|
58 | |
---|
59 | |
---|
60 | // ----------------------------------------------------------------------- |
---|
61 | // Public operators |
---|
62 | // ----------------------------------------------------------------------- |
---|
63 | XMLPScanToken& operator=(const XMLPScanToken& toCopy); |
---|
64 | |
---|
65 | |
---|
66 | protected : |
---|
67 | // ----------------------------------------------------------------------- |
---|
68 | // XMLScanner is our friend, can you say friend? Sure... |
---|
69 | // ----------------------------------------------------------------------- |
---|
70 | friend class XMLScanner; |
---|
71 | |
---|
72 | |
---|
73 | // ----------------------------------------------------------------------- |
---|
74 | // Hidden methods for use by XMLScanner |
---|
75 | // ----------------------------------------------------------------------- |
---|
76 | void set |
---|
77 | ( |
---|
78 | const XMLUInt32 scannerId |
---|
79 | , const XMLUInt32 sequenceId |
---|
80 | ); |
---|
81 | |
---|
82 | |
---|
83 | private : |
---|
84 | // ----------------------------------------------------------------------- |
---|
85 | // Private data members |
---|
86 | // |
---|
87 | // fScannerId |
---|
88 | // This field is set to the id of the scanner, to catch problems |
---|
89 | // where a token is gotten from one scanner and passed to another. |
---|
90 | // Each scanner is assigned an incrementing id. |
---|
91 | // |
---|
92 | // fSequenceId |
---|
93 | // In order to avoid problems such as calling scanNext() without |
---|
94 | // a call to scanFirst() and such, this value is set when scanFirst() |
---|
95 | // is called and matches this token to the current sequence id of |
---|
96 | // the scanner. |
---|
97 | // ----------------------------------------------------------------------- |
---|
98 | XMLUInt32 fScannerId; |
---|
99 | XMLUInt32 fSequenceId; |
---|
100 | }; |
---|
101 | |
---|
102 | |
---|
103 | // --------------------------------------------------------------------------- |
---|
104 | // XMLPScanToken: Constructors and Operators |
---|
105 | // --------------------------------------------------------------------------- |
---|
106 | inline XMLPScanToken::XMLPScanToken() : |
---|
107 | |
---|
108 | fScannerId(0) |
---|
109 | , fSequenceId(0) |
---|
110 | { |
---|
111 | } |
---|
112 | |
---|
113 | inline XMLPScanToken::XMLPScanToken(const XMLPScanToken& toCopy) : |
---|
114 | XMemory(toCopy) |
---|
115 | , fScannerId(toCopy.fScannerId) |
---|
116 | , fSequenceId(toCopy.fSequenceId) |
---|
117 | { |
---|
118 | } |
---|
119 | |
---|
120 | inline XMLPScanToken::~XMLPScanToken() |
---|
121 | { |
---|
122 | } |
---|
123 | |
---|
124 | |
---|
125 | // --------------------------------------------------------------------------- |
---|
126 | // XMLPScanToken: Public operators |
---|
127 | // --------------------------------------------------------------------------- |
---|
128 | inline XMLPScanToken& XMLPScanToken::operator=(const XMLPScanToken& toCopy) |
---|
129 | { |
---|
130 | if (this == &toCopy) |
---|
131 | return *this; |
---|
132 | |
---|
133 | fScannerId = toCopy.fScannerId; |
---|
134 | fSequenceId = toCopy.fSequenceId; |
---|
135 | |
---|
136 | return *this; |
---|
137 | } |
---|
138 | |
---|
139 | |
---|
140 | // --------------------------------------------------------------------------- |
---|
141 | // XMLPScanToken: Hidden methods |
---|
142 | // --------------------------------------------------------------------------- |
---|
143 | inline void XMLPScanToken::set( const XMLUInt32 scannerId |
---|
144 | , const XMLUInt32 sequenceId) |
---|
145 | { |
---|
146 | fScannerId = scannerId; |
---|
147 | fSequenceId = sequenceId; |
---|
148 | } |
---|
149 | |
---|
150 | XERCES_CPP_NAMESPACE_END |
---|
151 | |
---|
152 | #endif |
---|