File indexing completed on 2025-01-30 10:27:30
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #if !defined(XERCESC_INCLUDE_GUARD_DTDGRAMMAR_HPP)
0023 #define XERCESC_INCLUDE_GUARD_DTDGRAMMAR_HPP
0024
0025 #include <xercesc/util/RefHashTableOf.hpp>
0026 #include <xercesc/util/NameIdPool.hpp>
0027 #include <xercesc/util/StringPool.hpp>
0028 #include <xercesc/validators/common/Grammar.hpp>
0029 #include <xercesc/validators/DTD/DTDElementDecl.hpp>
0030 #include <xercesc/validators/DTD/DTDEntityDecl.hpp>
0031 #include <xercesc/framework/XMLDTDDescription.hpp>
0032
0033
0034 XERCES_CPP_NAMESPACE_BEGIN
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 class VALIDATORS_EXPORT DTDGrammar : public Grammar
0046 {
0047 public:
0048
0049
0050
0051 DTDGrammar(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0052 virtual ~DTDGrammar();
0053
0054
0055
0056
0057 virtual Grammar::GrammarType getGrammarType() const;
0058 virtual const XMLCh* getTargetNamespace() const;
0059
0060
0061
0062
0063 virtual XMLElementDecl* findOrAddElemDecl
0064 (
0065 const unsigned int uriId
0066 , const XMLCh* const baseName
0067 , const XMLCh* const prefixName
0068 , const XMLCh* const qName
0069 , unsigned int scope
0070 , bool& wasAdded
0071 ) ;
0072
0073 virtual XMLSize_t getElemId
0074 (
0075 const unsigned int uriId
0076 , const XMLCh* const baseName
0077 , const XMLCh* const qName
0078 , unsigned int scope
0079 ) const ;
0080
0081 virtual const XMLElementDecl* getElemDecl
0082 (
0083 const unsigned int uriId
0084 , const XMLCh* const baseName
0085 , const XMLCh* const qName
0086 , unsigned int scope
0087 ) const ;
0088
0089 virtual XMLElementDecl* getElemDecl
0090 (
0091 const unsigned int uriId
0092 , const XMLCh* const baseName
0093 , const XMLCh* const qName
0094 , unsigned int scope
0095 );
0096
0097 virtual const XMLElementDecl* getElemDecl
0098 (
0099 const unsigned int elemId
0100 ) const;
0101
0102 virtual XMLElementDecl* getElemDecl
0103 (
0104 const unsigned int elemId
0105 );
0106
0107 virtual const XMLNotationDecl* getNotationDecl
0108 (
0109 const XMLCh* const notName
0110 ) const;
0111
0112 virtual XMLNotationDecl* getNotationDecl
0113 (
0114 const XMLCh* const notName
0115 );
0116
0117 virtual bool getValidated() const;
0118
0119 virtual XMLElementDecl* putElemDecl
0120 (
0121 const unsigned int uriId
0122 , const XMLCh* const baseName
0123 , const XMLCh* const prefixName
0124 , const XMLCh* const qName
0125 , unsigned int scope
0126 , const bool notDeclared = false
0127 );
0128
0129 virtual XMLSize_t putElemDecl
0130 (
0131 XMLElementDecl* const elemDecl
0132 , const bool notDeclared = false
0133 ) ;
0134
0135 virtual XMLSize_t putNotationDecl
0136 (
0137 XMLNotationDecl* const notationDecl
0138 ) const;
0139
0140 virtual void setValidated(const bool newState);
0141
0142 virtual void reset();
0143
0144
0145
0146
0147
0148 const DTDEntityDecl* getEntityDecl(const XMLCh* const entName) const;
0149 DTDEntityDecl* getEntityDecl(const XMLCh* const entName);
0150 NameIdPool<DTDEntityDecl>* getEntityDeclPool();
0151 const NameIdPool<DTDEntityDecl>* getEntityDeclPool() const;
0152 NameIdPoolEnumerator<DTDElementDecl> getElemEnumerator() const;
0153 NameIdPoolEnumerator<DTDEntityDecl> getEntityEnumerator() const;
0154 NameIdPoolEnumerator<XMLNotationDecl> getNotationEnumerator() const;
0155
0156
0157
0158
0159
0160 virtual void setGrammarDescription( XMLGrammarDescription*);
0161 virtual XMLGrammarDescription* getGrammarDescription() const;
0162
0163
0164
0165
0166 XMLSize_t putEntityDecl(DTDEntityDecl* const entityDecl) const;
0167
0168
0169
0170
0171 DECL_XSERIALIZABLE(DTDGrammar)
0172
0173 private:
0174
0175
0176
0177 DTDGrammar(const DTDGrammar &);
0178 DTDGrammar& operator = (const DTDGrammar&);
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209 static NameIdPool<DTDEntityDecl>* fDefaultEntities;
0210 MemoryManager* fMemoryManager;
0211 NameIdPool<DTDElementDecl>* fElemDeclPool;
0212 NameIdPool<DTDElementDecl>* fElemNonDeclPool;
0213 NameIdPool<DTDEntityDecl>* fEntityDeclPool;
0214 NameIdPool<XMLNotationDecl>* fNotationDeclPool;
0215 XMLDTDDescription* fGramDesc;
0216
0217 bool fValidated;
0218
0219 friend class XMLInitializer;
0220 };
0221
0222
0223
0224
0225 inline NameIdPoolEnumerator<DTDElementDecl>
0226 DTDGrammar::getElemEnumerator() const
0227 {
0228 return NameIdPoolEnumerator<DTDElementDecl>(fElemDeclPool, fMemoryManager);
0229 }
0230
0231 inline NameIdPoolEnumerator<DTDEntityDecl>
0232 DTDGrammar::getEntityEnumerator() const
0233 {
0234 return NameIdPoolEnumerator<DTDEntityDecl>(fEntityDeclPool, fMemoryManager);
0235 }
0236
0237 inline NameIdPoolEnumerator<XMLNotationDecl>
0238 DTDGrammar::getNotationEnumerator() const
0239 {
0240 return NameIdPoolEnumerator<XMLNotationDecl>(fNotationDeclPool, fMemoryManager);
0241 }
0242
0243 inline const DTDEntityDecl*
0244 DTDGrammar::getEntityDecl(const XMLCh* const entName) const
0245 {
0246 DTDEntityDecl* decl = fDefaultEntities->getByKey(entName);
0247
0248 if (!decl)
0249 return fEntityDeclPool->getByKey(entName);
0250
0251 return decl;
0252 }
0253
0254 inline DTDEntityDecl* DTDGrammar::getEntityDecl(const XMLCh* const entName)
0255 {
0256 DTDEntityDecl* decl = fDefaultEntities->getByKey(entName);
0257
0258 if (!decl)
0259 return fEntityDeclPool->getByKey(entName);
0260
0261 return decl;
0262 }
0263
0264
0265 inline NameIdPool<DTDEntityDecl>* DTDGrammar::getEntityDeclPool()
0266 {
0267 return fEntityDeclPool;
0268 }
0269
0270 inline const NameIdPool<DTDEntityDecl>* DTDGrammar::getEntityDeclPool() const
0271 {
0272 return fEntityDeclPool;
0273 }
0274
0275
0276
0277
0278 inline XMLSize_t DTDGrammar::putEntityDecl(DTDEntityDecl* const entityDecl) const
0279 {
0280 return fEntityDeclPool->put(entityDecl);
0281 }
0282
0283
0284
0285
0286
0287 inline Grammar::GrammarType DTDGrammar::getGrammarType() const {
0288 return Grammar::DTDGrammarType;
0289 }
0290
0291 inline const XMLCh* DTDGrammar::getTargetNamespace() const {
0292 return XMLUni::fgZeroLenString;
0293 }
0294
0295
0296 inline XMLSize_t DTDGrammar::getElemId (const unsigned int
0297 , const XMLCh* const
0298 , const XMLCh* const qName
0299 , unsigned int) const
0300 {
0301
0302
0303
0304
0305 const DTDElementDecl* decl = fElemDeclPool->getByKey(qName);
0306 if (!decl)
0307 return XMLElementDecl::fgInvalidElemId;
0308 return decl->getId();
0309 }
0310
0311 inline const XMLElementDecl* DTDGrammar::getElemDecl( const unsigned int
0312 , const XMLCh* const
0313 , const XMLCh* const qName
0314 , unsigned int) const
0315 {
0316 const XMLElementDecl* elemDecl = fElemDeclPool->getByKey(qName);
0317
0318 if (!elemDecl && fElemNonDeclPool)
0319 elemDecl = fElemNonDeclPool->getByKey(qName);
0320
0321 return elemDecl;
0322 }
0323
0324 inline XMLElementDecl* DTDGrammar::getElemDecl (const unsigned int
0325 , const XMLCh* const
0326 , const XMLCh* const qName
0327 , unsigned int)
0328 {
0329 XMLElementDecl* elemDecl = fElemDeclPool->getByKey(qName);
0330
0331 if (!elemDecl && fElemNonDeclPool)
0332 elemDecl = fElemNonDeclPool->getByKey(qName);
0333
0334 return elemDecl;
0335 }
0336
0337 inline const XMLElementDecl* DTDGrammar::getElemDecl(const unsigned int elemId) const
0338 {
0339
0340 return fElemDeclPool->getById(elemId);
0341 }
0342
0343 inline XMLElementDecl* DTDGrammar::getElemDecl(const unsigned int elemId)
0344 {
0345
0346 return fElemDeclPool->getById(elemId);
0347 }
0348
0349 inline XMLSize_t
0350 DTDGrammar::putElemDecl(XMLElementDecl* const elemDecl,
0351 const bool notDeclared)
0352 {
0353 if (notDeclared)
0354 {
0355 if(!fElemNonDeclPool)
0356 fElemNonDeclPool = new (fMemoryManager) NameIdPool<DTDElementDecl>(29, 128, fMemoryManager);
0357 return fElemNonDeclPool->put((DTDElementDecl*) elemDecl);
0358 }
0359
0360 return fElemDeclPool->put((DTDElementDecl*) elemDecl);
0361 }
0362
0363
0364 inline const XMLNotationDecl* DTDGrammar::getNotationDecl(const XMLCh* const notName) const
0365 {
0366 return fNotationDeclPool->getByKey(notName);
0367 }
0368
0369 inline XMLNotationDecl* DTDGrammar::getNotationDecl(const XMLCh* const notName)
0370 {
0371 return fNotationDeclPool->getByKey(notName);
0372 }
0373
0374 inline XMLSize_t DTDGrammar::putNotationDecl(XMLNotationDecl* const notationDecl) const
0375 {
0376 return fNotationDeclPool->put(notationDecl);
0377 }
0378
0379 inline bool DTDGrammar::getValidated() const
0380 {
0381 return fValidated;
0382 }
0383
0384 inline void DTDGrammar::setValidated(const bool newState)
0385 {
0386 fValidated = newState;
0387 }
0388
0389 XERCES_CPP_NAMESPACE_END
0390
0391 #endif