Xerces-C++ 3.3.0
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
28#include <xercesc/internal/XSerializable.hpp>
29
31
50class XMLPARSER_EXPORT XMLEntityDecl : public XSerializable, public XMemory
51{
52public:
53 // -----------------------------------------------------------------------
54 // Constructors and Destructor
55 // -----------------------------------------------------------------------
56
59
64
72 (
73 const XMLCh* const entName
75 );
76
86 (
87 const XMLCh* const entName
88 , const XMLCh* const value
90 );
91
101 (
102 const XMLCh* const entName
103 , const XMLCh value
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
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 // -----------------------------------------------------------------------
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// ---------------------------------------------------------------------------
392{
393 return fId;
394}
395
396inline const XMLCh* XMLEntityDecl::getName() const
397{
398 return fName;
399}
400
402{
403 return fNotationName;
404}
405
407{
408 return fPublicId;
409}
410
412{
413 return fSystemId;
414}
415
416inline const XMLCh* XMLEntityDecl::getBaseURI() const
417{
418 return fBaseURI;
419}
420
421inline const XMLCh* XMLEntityDecl::getValue() const
422{
423 return fValue;
424}
425
427{
428 return fValueLen;
429}
430
431inline bool XMLEntityDecl::isExternal() const
432{
433 return fIsExternal;
434}
435
436inline bool XMLEntityDecl::isUnparsed() const
437{
438 // If it has a notation, its unparsed
439 return (fNotationName != 0);
440}
441
443{
444 return fMemoryManager;
445}
446
447// ---------------------------------------------------------------------------
448// XMLEntityDecl: Setter methods
449// ---------------------------------------------------------------------------
450inline void XMLEntityDecl::setId(const XMLSize_t newId)
451{
452 fId = newId;
453}
454
455inline void XMLEntityDecl::setIsExternal(bool value)
456{
457 fIsExternal = value;
458}
459
460inline void XMLEntityDecl::setNotationName(const XMLCh* const newName)
461{
462 if (fNotationName)
463 fMemoryManager->deallocate(fNotationName);
464
465 fNotationName = XMLString::replicate(newName, fMemoryManager);
466}
467
468inline void XMLEntityDecl::setPublicId(const XMLCh* const newId)
469{
470 if (fPublicId)
471 fMemoryManager->deallocate(fPublicId);
472
473 fPublicId = XMLString::replicate(newId, fMemoryManager);
474}
475
476inline void XMLEntityDecl::setSystemId(const XMLCh* const newId)
477{
478 if (fSystemId)
479 fMemoryManager->deallocate(fSystemId);
480
481 fSystemId = XMLString::replicate(newId, fMemoryManager);
482}
483
484inline void XMLEntityDecl::setBaseURI(const XMLCh* const newId)
485{
486 if (fBaseURI)
487 fMemoryManager->deallocate(fBaseURI);
488
489 fBaseURI = XMLString::replicate(newId, fMemoryManager);
490}
491
492inline 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// ---------------------------------------------------------------------------
505inline const XMLCh* XMLEntityDecl::getKey() const
506{
507 return fName;
508}
509
511
512#endif
#define XMLPARSER_EXPORT
Definition XercesDefs.hpp:163
#define XERCES_CPP_NAMESPACE_BEGIN
Definition XercesDefs.hpp:112
#define XERCES_CPP_NAMESPACE_END
Definition XercesDefs.hpp:113
size_t XMLSize_t
Definition Xerces_autoconf_config.hpp:112
char16_t XMLCh
Definition Xerces_autoconf_config.hpp:120
Configurable memory manager.
Definition MemoryManager.hpp:40
virtual void deallocate(void *p)=0
This method deallocates memory.
This class defines that core information that defines an XML entity, no matter what validator is used...
Definition XMLEntityDecl.hpp:51
const XMLCh * getSystemId() const
Gets the system id declared for this entity.
Definition XMLEntityDecl.hpp:411
bool isExternal() const
Indicates that this entity is an external entity.
Definition XMLEntityDecl.hpp:431
bool isUnparsed() const
Indicates whether this entity is unparsed.
Definition XMLEntityDecl.hpp:436
XMLSize_t getId() const
Gets the pool id of this entity.
Definition XMLEntityDecl.hpp:391
virtual bool getIsParameter() const =0
Get the 'is parameter entity' flag.
MemoryManager * getMemoryManager() const
Get the plugged-in memory manager.
Definition XMLEntityDecl.hpp:442
void setPublicId(const XMLCh *const newId)
This method will set a new public id on this entity.
Definition XMLEntityDecl.hpp:468
XMLEntityDecl(const XMLCh *const entName, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
Constructor with a const entity name.
virtual ~XMLEntityDecl()
Default destructor.
XMLEntityDecl(const XMLCh *const entName, const XMLCh value, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
Constructor with a const entity name and single XMLCh value.
const XMLCh * getPublicId() const
Gets the public id declared for this entity.
Definition XMLEntityDecl.hpp:406
void setId(const XMLSize_t newId)
Definition XMLEntityDecl.hpp:450
XMLEntityDecl(MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
Default Constructor.
const XMLCh * getNotationName() const
Gets the notation name, if any, declared for this entity.
Definition XMLEntityDecl.hpp:401
const XMLCh * getBaseURI() const
Gets the base URI for this entity.
Definition XMLEntityDecl.hpp:416
void setNotationName(const XMLCh *const newName)
This method will set the notation name for this entity.
Definition XMLEntityDecl.hpp:460
void setIsExternal(bool value)
This method will mark whether the entity is external.
Definition XMLEntityDecl.hpp:455
virtual bool getIsSpecialChar() const =0
Get the 'is special char entity' flag.
XMLEntityDecl(const XMLCh *const entName, const XMLCh *const value, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
Constructor with a const entity name and value.
void setBaseURI(const XMLCh *const newId)
This method will set a new baseURI on this entity.
Definition XMLEntityDecl.hpp:484
void setName(const XMLCh *const entName)
This method will set the entity name.
XMLSize_t getValueLen() const
This method returns the number of characters in the value returned by getValue().
Definition XMLEntityDecl.hpp:426
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
void setSystemId(const XMLCh *const newId)
This method will set a new sysetm id on this entity.
Definition XMLEntityDecl.hpp:476
void setValue(const XMLCh *const newValue)
This method will set a new value for this entity.
Definition XMLEntityDecl.hpp:492
const XMLCh * getName() const
Returns a const pointer to the name of this entity decl.
Definition XMLEntityDecl.hpp:396
const XMLCh * getValue() const
This method returns the value of an internal entity.
Definition XMLEntityDecl.hpp:421
virtual bool getDeclaredInIntSubset() const =0
Get the 'declared in internal subset' flag.
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition PlatformUtils.hpp:121
static XMLSize_t stringLen(const char *const src)
Get the length of the string.
static char * replicate(const char *const toRep, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
Replicates a string NOTE: The returned buffer is allocated with the MemoryManager.
This class makes it possible to override the C++ memory management by adding new/delete operators to ...
Definition XMemory.hpp:41