Xerces-C++ 3.2.4

XMLEntityDecl.hpp
Go to the documentation of this file.
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$
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_XMLENTITYDECL_HPP)
23#define XERCESC_INCLUDE_GUARD_XMLENTITYDECL_HPP
24
25#include <xercesc/util/XMemory.hpp>
26#include <xercesc/util/PlatformUtils.hpp>
27#include <xercesc/util/XMLString.hpp>
28#include <xercesc/internal/XSerializable.hpp>
29
30 XERCES_CPP_NAMESPACE_BEGIN
31
50 class XMLPARSER_EXPORT XMLEntityDecl : public XSerializable, public XMemory
51{
52 public:
53 // -----------------------------------------------------------------------
54 // Constructors and Destructor
55 // -----------------------------------------------------------------------
56
59
63 XMLEntityDecl(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
64
71 XMLEntityDecl
72 (
73 const XMLCh* const entName
74 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
75 );
76
85 XMLEntityDecl
86 (
87 const XMLCh* const entName
88 , const XMLCh* const value
89 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
90 );
91
100 XMLEntityDecl
101 (
102 const XMLCh* const entName
103 , const XMLCh value
104 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
105 );
107
110
114 virtual ~XMLEntityDecl();
115
117
118
119 // -----------------------------------------------------------------------
120 // Virtual entity decl interface
121 // -----------------------------------------------------------------------
122
125
133 virtual bool getDeclaredInIntSubset() const = 0;
134
140 virtual bool getIsParameter() const = 0;
141
147 virtual bool getIsSpecialChar() const = 0;
148
150
151
152 // -----------------------------------------------------------------------
153 // Getter methods
154 // -----------------------------------------------------------------------
155
158
163 XMLSize_t getId() const;
164
170 const XMLCh* getName() const;
171
176 const XMLCh* getNotationName() const;
177
182 const XMLCh* getPublicId() const;
183
188 const XMLCh* getSystemId() const;
189
193 const XMLCh* getBaseURI() const;
194
200 const XMLCh* getValue() const;
201
207 XMLSize_t getValueLen() const;
208
213 bool isExternal() const;
214
220 bool isUnparsed() const;
221
229 MemoryManager* getMemoryManager() const;
230
232
233
234 // -----------------------------------------------------------------------
235 // Setter methods
236 // -----------------------------------------------------------------------
237
240
249 void setName
250 (
251 const XMLCh* const entName
252 );
253
259 void setIsExternal(bool value);
260
267 void setNotationName(const XMLCh* const newName);
268
275 void setPublicId(const XMLCh* const newId);
276
286 void setSystemId(const XMLCh* const newId);
287
294 void setBaseURI(const XMLCh* const newId);
295
303 void setValue(const XMLCh* const newValue);
304
306
307 /* For internal use only */
308 void setId(const XMLSize_t newId);
309
310
311 // -----------------------------------------------------------------------
312 // Support named pool syntax
313 // -----------------------------------------------------------------------
314
317
324 const XMLCh* getKey() const;
325
327
328 /***
329 * Support for Serialization/De-serialization
330 ***/
331 DECL_XSERIALIZABLE(XMLEntityDecl)
332
333private :
334 // -----------------------------------------------------------------------
335 // Unimplemented constructors and operators
336 // -----------------------------------------------------------------------
337 XMLEntityDecl(const XMLEntityDecl&);
338 XMLEntityDecl& operator=(XMLEntityDecl&);
339
340
341 // -----------------------------------------------------------------------
342 // XMLEntityDecl: Private helper methods
343 // -----------------------------------------------------------------------
344 void cleanUp();
345
346
347 // -----------------------------------------------------------------------
348 // Private data members
349 //
350 // fId
351 // This is the unique id given to this entity decl.
352 //
353 // fName
354 // The name of the entity. Entity names are never namespace based.
355 //
356 // fNotationName
357 // The optional notation of the entity. If there was none, then its
358 // empty.
359 //
360 // fPublicId
361 // The public id of the entity, which can be empty.
362 //
363 // fSystemId
364 // The system id of the entity.
365 //
366 // fValue
367 // fValueLen
368 // The entity's value and length, which is only valid if its an
369 // internal style entity.
370 //
371 // fBaseURI
372 // The base URI of the entity. According to XML InfoSet, such value
373 // is the URI where it is declared (NOT referenced).
374 // -----------------------------------------------------------------------
375 XMLSize_t fId;
376 XMLSize_t fValueLen;
377 XMLCh* fValue;
378 XMLCh* fName;
379 XMLCh* fNotationName;
380 XMLCh* fPublicId;
381 XMLCh* fSystemId;
382 XMLCh* fBaseURI;
383 bool fIsExternal;
384 MemoryManager* fMemoryManager;
385};
386
387
388// ---------------------------------------------------------------------------
389// XMLEntityDecl: Getter methods
390// ---------------------------------------------------------------------------
391 inline XMLSize_t XMLEntityDecl::getId() const
392{
393 return fId;
394}
395
396 inline const XMLCh* XMLEntityDecl::getName() const
397{
398 return fName;
399}
400
401 inline const XMLCh* XMLEntityDecl::getNotationName() const
402{
403 return fNotationName;
404}
405
406 inline const XMLCh* XMLEntityDecl::getPublicId() const
407{
408 return fPublicId;
409}
410
411 inline const XMLCh* XMLEntityDecl::getSystemId() const
412{
413 return fSystemId;
414}
415
416 inline const XMLCh* XMLEntityDecl::getBaseURI() const
417{
418 return fBaseURI;
419}
420
421 inline const XMLCh* XMLEntityDecl::getValue() const
422{
423 return fValue;
424}
425
426 inline XMLSize_t XMLEntityDecl::getValueLen() const
427{
428 return fValueLen;
429}
430
431 inline bool XMLEntityDecl::isExternal() const
432{
433 return fIsExternal;
434}
435
436 inline bool XMLEntityDecl::isUnparsed() const
437{
438 // If it has a notation, its unparsed
439 return (fNotationName != 0);
440}
441
442 inline MemoryManager* XMLEntityDecl::getMemoryManager() const
443{
444 return fMemoryManager;
445}
446
447// ---------------------------------------------------------------------------
448// XMLEntityDecl: Setter methods
449// ---------------------------------------------------------------------------
450 inline void XMLEntityDecl::setId(const XMLSize_t newId)
451{
452 fId = newId;
453}
454
455 inline void XMLEntityDecl::setIsExternal(bool value)
456{
457 fIsExternal = value;
458}
459
460 inline void XMLEntityDecl::setNotationName(const XMLCh* const newName)
461{
462 if (fNotationName)
463 fMemoryManager->deallocate(fNotationName);
464
465 fNotationName = XMLString::replicate(newName, fMemoryManager);
466}
467
468 inline void XMLEntityDecl::setPublicId(const XMLCh* const newId)
469{
470 if (fPublicId)
471 fMemoryManager->deallocate(fPublicId);
472
473 fPublicId = XMLString::replicate(newId, fMemoryManager);
474}
475
476 inline void XMLEntityDecl::setSystemId(const XMLCh* const newId)
477{
478 if (fSystemId)
479 fMemoryManager->deallocate(fSystemId);
480
481 fSystemId = XMLString::replicate(newId, fMemoryManager);
482}
483
484 inline void XMLEntityDecl::setBaseURI(const XMLCh* const newId)
485{
486 if (fBaseURI)
487 fMemoryManager->deallocate(fBaseURI);
488
489 fBaseURI = XMLString::replicate(newId, fMemoryManager);
490}
491
492 inline void XMLEntityDecl::setValue(const XMLCh* const newValue)
493{
494 if (fValue)
495 fMemoryManager->deallocate(fValue);
496
497 fValue = XMLString::replicate(newValue, fMemoryManager);
498 fValueLen = XMLString::stringLen(newValue);
499}
500
501
502// ---------------------------------------------------------------------------
503// XMLEntityDecl: Support named pool syntax
504// ---------------------------------------------------------------------------
505 inline const XMLCh* XMLEntityDecl::getKey() const
506{
507 return fName;
508}
509
510 XERCES_CPP_NAMESPACE_END
511
512#endif
PlatformUtils.hpp
XMLString.hpp
XMemory.hpp
XMLPARSER_EXPORT
#define XMLPARSER_EXPORT
Definition: XercesDefs.hpp:163
XERCES_CPP_NAMESPACE_BEGIN
#define XERCES_CPP_NAMESPACE_BEGIN
Definition: XercesDefs.hpp:112
XERCES_CPP_NAMESPACE_END
#define XERCES_CPP_NAMESPACE_END
Definition: XercesDefs.hpp:113
XMLCh
uint16_t XMLCh
Definition: Xerces_autoconf_config.hpp:120
XMLSize_t
size_t XMLSize_t
Definition: Xerces_autoconf_config.hpp:112
MemoryManager
Configurable memory manager.
Definition: MemoryManager.hpp:40
MemoryManager::deallocate
virtual void deallocate(void *p)=0
This method deallocates memory.
XMLEntityDecl
This class defines that core information that defines an XML entity, no matter what validator is used...
Definition: XMLEntityDecl.hpp:51
XMLEntityDecl::getSystemId
const XMLCh * getSystemId() const
Gets the system id declared for this entity.
Definition: XMLEntityDecl.hpp:411
XMLEntityDecl::isExternal
bool isExternal() const
Indicates that this entity is an external entity.
Definition: XMLEntityDecl.hpp:431
XMLEntityDecl::isUnparsed
bool isUnparsed() const
Indicates whether this entity is unparsed.
Definition: XMLEntityDecl.hpp:436
XMLEntityDecl::getId
XMLSize_t getId() const
Gets the pool id of this entity.
Definition: XMLEntityDecl.hpp:391
XMLEntityDecl::getIsParameter
virtual bool getIsParameter() const =0
Get the 'is parameter entity' flag.
XMLEntityDecl::getMemoryManager
MemoryManager * getMemoryManager() const
Get the plugged-in memory manager.
Definition: XMLEntityDecl.hpp:442
XMLEntityDecl::setPublicId
void setPublicId(const XMLCh *const newId)
This method will set a new public id on this entity.
Definition: XMLEntityDecl.hpp:468
XMLEntityDecl::XMLEntityDecl
XMLEntityDecl(const XMLCh *const entName, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
Constructor with a const entity name.
XMLEntityDecl::~XMLEntityDecl
virtual ~XMLEntityDecl()
Default destructor.
XMLEntityDecl::XMLEntityDecl
XMLEntityDecl(const XMLCh *const entName, const XMLCh value, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
Constructor with a const entity name and single XMLCh value.
XMLEntityDecl::getPublicId
const XMLCh * getPublicId() const
Gets the public id declared for this entity.
Definition: XMLEntityDecl.hpp:406
XMLEntityDecl::setId
void setId(const XMLSize_t newId)
Definition: XMLEntityDecl.hpp:450
XMLEntityDecl::XMLEntityDecl
XMLEntityDecl(MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
Default Constructor.
XMLEntityDecl::getNotationName
const XMLCh * getNotationName() const
Gets the notation name, if any, declared for this entity.
Definition: XMLEntityDecl.hpp:401
XMLEntityDecl::getBaseURI
const XMLCh * getBaseURI() const
Gets the base URI for this entity.
Definition: XMLEntityDecl.hpp:416
XMLEntityDecl::setNotationName
void setNotationName(const XMLCh *const newName)
This method will set the notation name for this entity.
Definition: XMLEntityDecl.hpp:460
XMLEntityDecl::setIsExternal
void setIsExternal(bool value)
This method will mark whether the entity is external.
Definition: XMLEntityDecl.hpp:455
XMLEntityDecl::getIsSpecialChar
virtual bool getIsSpecialChar() const =0
Get the 'is special char entity' flag.
XMLEntityDecl::XMLEntityDecl
XMLEntityDecl(const XMLCh *const entName, const XMLCh *const value, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
Constructor with a const entity name and value.
XMLEntityDecl::setBaseURI
void setBaseURI(const XMLCh *const newId)
This method will set a new baseURI on this entity.
Definition: XMLEntityDecl.hpp:484
XMLEntityDecl::setName
void setName(const XMLCh *const entName)
This method will set the entity name.
XMLEntityDecl::getValueLen
XMLSize_t getValueLen() const
This method returns the number of characters in the value returned by getValue().
Definition: XMLEntityDecl.hpp:426
XMLEntityDecl::getKey
const XMLCh * getKey() const
This method allows objects of this class to be used within a standard keyed collection used commonly ...
Definition: XMLEntityDecl.hpp:505
XMLEntityDecl::setSystemId
void setSystemId(const XMLCh *const newId)
This method will set a new sysetm id on this entity.
Definition: XMLEntityDecl.hpp:476
XMLEntityDecl::setValue
void setValue(const XMLCh *const newValue)
This method will set a new value for this entity.
Definition: XMLEntityDecl.hpp:492
XMLEntityDecl::getName
const XMLCh * getName() const
Returns a const pointer to the name of this entity decl.
Definition: XMLEntityDecl.hpp:396
XMLEntityDecl::getValue
const XMLCh * getValue() const
This method returns the value of an internal entity.
Definition: XMLEntityDecl.hpp:421
XMLEntityDecl::getDeclaredInIntSubset
virtual bool getDeclaredInIntSubset() const =0
Get the 'declared in internal subset' flag.
XMLPlatformUtils::fgMemoryManager
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition: PlatformUtils.hpp:121
XMLString::stringLen
static XMLSize_t stringLen(const char *const src)
Get the length of the string.
XMLString::replicate
static char * replicate(const char *const toRep, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
Replicates a string NOTE: The returned buffer is allocated with the MemoryManager.
XMemory
This class makes it possible to override the C++ memory management by adding new/delete operators to ...
Definition: XMemory.hpp:41