Xerces-C++ 3.2.3

XMLElementDecl.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_XMLELEMENTDECL_HPP)
23 #define XERCESC_INCLUDE_GUARD_XMLELEMENTDECL_HPP
24
25 #include <xercesc/framework/XMLAttr.hpp>
26 #include <xercesc/framework/XMLAttDefList.hpp>
27 #include <xercesc/util/XMLString.hpp>
28 #include <xercesc/util/PlatformUtils.hpp>
29 #include <xercesc/internal/XSerializable.hpp>
30
31 XERCES_CPP_NAMESPACE_BEGIN
32
33 class ContentSpecNode;
34 class XMLContentModel;
35
51 class XMLPARSER_EXPORT XMLElementDecl : public XSerializable, public XMemory
52 {
53 public:
54 // -----------------------------------------------------------------------
55 // Class specific types
56 //
57 // CreateReasons
58 // This type is used to store how an element declaration got into
59 // the grammar's element pool. They are faulted in for various
60 // reasons.
61 //
62 // LookupOpts
63 // These are the values used by the attribute lookup methods.
64 //
65 // CharDataOpts
66 // This is used to indicate how this type of element reacts to
67 // character data as content.
68 // -----------------------------------------------------------------------
69 enum CreateReasons
70 {
71 NoReason
72 , Declared
73 , AttList
74 , InContentModel
75 , AsRootElem
76 , JustFaultIn
77 };
78
79 enum CharDataOpts
80 {
81 NoCharData
82 , SpacesOk
83 , AllCharData
84 };
85
86
87 // -----------------------------------------------------------------------
88 // Public static data
89 //
90 // fgInvalidElemId
91 // A value to represent an invalid element node id.
92 //
93 // fgPCDataElemId
94 // This is the value to use to represent a PCDATA node when an
95 // element id is required.
96 //
97 // fgPCDataElemName
98 // This is the value to use to represent a PCDATA node when an
99 // element name is required.
100 // -----------------------------------------------------------------------
101 static const unsigned int fgInvalidElemId;
102 static const unsigned int fgPCDataElemId;
103 static const XMLCh fgPCDataElemName[];
104
105
106
107 // -----------------------------------------------------------------------
108 // Destructor
109 // -----------------------------------------------------------------------
112 virtual ~XMLElementDecl();
114
115
116 // -----------------------------------------------------------------------
117 // The virtual element decl interface
118 // -----------------------------------------------------------------------
119
122
134 virtual XMLAttDefList& getAttDefList() const = 0;
135
143 virtual CharDataOpts getCharDataOpts() const = 0;
144
151 virtual bool hasAttDefs() const = 0;
152
160 virtual const ContentSpecNode* getContentSpec() const = 0;
161
167 virtual ContentSpecNode* getContentSpec() = 0;
168
178 virtual void setContentSpec(ContentSpecNode* toAdopt) = 0;
179
191 virtual XMLContentModel* getContentModel() = 0;
192
204 virtual void setContentModel(XMLContentModel* const newModelToAdopt) = 0;
205
218 virtual const XMLCh* getFormattedContentModel () const = 0;
219
221
222
223 // -----------------------------------------------------------------------
224 // Getter methods
225 // -----------------------------------------------------------------------
226
229
237 const XMLCh* getBaseName() const;
238 XMLCh* getBaseName();
239
246 unsigned int getURI() const;
247
255 const QName* getElementName() const;
256 QName* getElementName();
257
266 const XMLCh* getFullName() const;
267
279 CreateReasons getCreateReason() const;
280
290 XMLSize_t getId() const;
291
301 bool isDeclared() const;
302
311 bool isExternal() const;
312
320 MemoryManager* getMemoryManager() const;
321
323
324
325 // -----------------------------------------------------------------------
326 // Setter methods
327 // -----------------------------------------------------------------------
328
331
342 void setElementName(const XMLCh* const prefix
343 , const XMLCh* const localPart
344 , const int uriId );
345
355 void setElementName(const XMLCh* const rawName
356 , const int uriId );
357
366 void setElementName(const QName* const elementName);
367
378 void setCreateReason(const CreateReasons newReason);
379
386 void setId(const XMLSize_t newId);
387
388
392 void setExternalElemDeclaration(const bool aValue);
393
395
396
397 // -----------------------------------------------------------------------
398 // Miscellaneous methods
399 // -----------------------------------------------------------------------
400
403
405
406 /***
407 * Support for Serialization/De-serialization
408 ***/
409 DECL_XSERIALIZABLE(XMLElementDecl)
410
411 enum objectType
412 {
413 Schema
414 , DTD
415 , UnKnown
416 };
417
418 virtual XMLElementDecl::objectType getObjectType() const = 0;
419
420 static void storeElementDecl(XSerializeEngine& serEng
421 , XMLElementDecl* const element);
422
423 static XMLElementDecl* loadElementDecl(XSerializeEngine& serEng);
424
425 protected :
426 // -----------------------------------------------------------------------
427 // Hidden constructors
428 // -----------------------------------------------------------------------
429 XMLElementDecl(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
430
431 private :
432 // -----------------------------------------------------------------------
433 // Unimplemented constructors and operators
434 // -----------------------------------------------------------------------
435 XMLElementDecl(const XMLElementDecl&);
436 XMLElementDecl& operator=(const XMLElementDecl&);
437
438
439 // -----------------------------------------------------------------------
440 // Data members
441 //
442 // fElementName
443 // This is the name of the element decl.
444 //
445 // fCreateReason
446 // We sometimes have to put an element decl object into the elem
447 // decl pool before the element's declaration is seen, such as when
448 // its used in another element's content model or an att list is
449 // seen for it. This flag tells us whether its been declared, and
450 // if not why it had to be created.
451 //
452 // fId
453 // The unique id of this element. This is created by the derived
454 // class, or more accurately the grammar that owns the objects
455 // of the derived types. But, since they all have to have them, we
456 // let them all store the id here. It is defaulted to have the
457 // value fgInvalidElem until explicitly set.
458 //
459 // fExternalElement
460 // This flag indicates whether or the element was declared externally.
461 // -----------------------------------------------------------------------
462 MemoryManager* fMemoryManager;
463 QName* fElementName;
464 CreateReasons fCreateReason;
465 XMLSize_t fId;
466 bool fExternalElement;
467 };
468
469
470 // ---------------------------------------------------------------------------
471 // XMLElementDecl: Getter methods
472 // ---------------------------------------------------------------------------
473 inline const XMLCh* XMLElementDecl::getBaseName() const
474 {
475 return fElementName->getLocalPart();
476 }
477
478 inline XMLCh* XMLElementDecl::getBaseName()
479 {
480 return fElementName->getLocalPart();
481 }
482
483 inline unsigned int XMLElementDecl::getURI() const
484 {
485 return fElementName->getURI();
486 }
487
488 inline const QName* XMLElementDecl::getElementName() const
489 {
490 return fElementName;
491 }
492
493 inline QName* XMLElementDecl::getElementName()
494 {
495 return fElementName;
496 }
497
498 inline const XMLCh* XMLElementDecl::getFullName() const
499 {
500 return fElementName->getRawName();
501 }
502
503 inline XMLElementDecl::CreateReasons XMLElementDecl::getCreateReason() const
504 {
505 return fCreateReason;
506 }
507
508 inline XMLSize_t XMLElementDecl::getId() const
509 {
510 return fId;
511 }
512
513 inline bool XMLElementDecl::isDeclared() const
514 {
515 return (fCreateReason == Declared);
516 }
517
518
519 inline bool XMLElementDecl::isExternal() const
520 {
521 return fExternalElement;
522 }
523
524 inline MemoryManager* XMLElementDecl::getMemoryManager() const
525 {
526 return fMemoryManager;
527 }
528
529
530 // ---------------------------------------------------------------------------
531 // XMLElementDecl: Setter methods
532 // ---------------------------------------------------------------------------
533 inline void
534 XMLElementDecl::setCreateReason(const XMLElementDecl::CreateReasons newReason)
535 {
536 fCreateReason = newReason;
537 }
538
539 inline void XMLElementDecl::setId(const XMLSize_t newId)
540 {
541 fId = newId;
542 }
543
544
545 inline void XMLElementDecl::setExternalElemDeclaration(const bool aValue)
546 {
547 fExternalElement = aValue;
548 }
549
550 XERCES_CPP_NAMESPACE_END
551
552 #endif
XMemory
This class makes it possible to override the C++ memory management by adding new/delete operators to ...
Definition: XMemory.hpp:40
XERCES_CPP_NAMESPACE_BEGIN
#define XERCES_CPP_NAMESPACE_BEGIN
Definition: XercesDefs.hpp:112
XMLElementDecl::getCreateReason
CreateReasons getCreateReason() const
Get the create reason for this element type.
Definition: XMLElementDecl.hpp:503
QName::getLocalPart
const XMLCh * getLocalPart() const
Definition: QName.hpp:177
XMLElementDecl::CreateReasons
CreateReasons
Definition: XMLElementDecl.hpp:69
XERCES_CPP_NAMESPACE_END
#define XERCES_CPP_NAMESPACE_END
Definition: XercesDefs.hpp:113
XMLElementDecl
This class defines the core information of an element declaration.
Definition: XMLElementDecl.hpp:51
XMLContentModel
This class defines the abstract interface for all content models.
Definition: XMLContentModel.hpp:46
XMLElementDecl::fgInvalidElemId
static const unsigned int fgInvalidElemId
Definition: XMLElementDecl.hpp:101
PlatformUtils.hpp
XMLElementDecl::getFullName
const XMLCh * getFullName() const
Get the full name of this element type.
Definition: XMLElementDecl.hpp:498
XMLCh
uint16_t XMLCh
Definition: Xerces_autoconf_config.hpp:120
XMLPlatformUtils::fgMemoryManager
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition: PlatformUtils.hpp:121
XMLElementDecl::setExternalElemDeclaration
void setExternalElemDeclaration(const bool aValue)
Set the element decl to indicate external declaration.
Definition: XMLElementDecl.hpp:545
XMLString.hpp
XMLAttr.hpp
XMLSize_t
size_t XMLSize_t
Definition: Xerces_autoconf_config.hpp:112
QName::getURI
unsigned int getURI() const
Definition: QName.hpp:187
XMLElementDecl::objectType
objectType
Definition: XMLElementDecl.hpp:411
XMLElementDecl::getId
XMLSize_t getId() const
Get the element decl pool id for this element type.
Definition: XMLElementDecl.hpp:508
XMLAttDefList.hpp
XMLElementDecl::fgPCDataElemId
static const unsigned int fgPCDataElemId
Definition: XMLElementDecl.hpp:102
XMLElementDecl::setCreateReason
void setCreateReason(const CreateReasons newReason)
Update the create reason for this element type.
Definition: XMLElementDecl.hpp:534
XMLElementDecl::CharDataOpts
CharDataOpts
Definition: XMLElementDecl.hpp:79
XMLElementDecl::setId
void setId(const XMLSize_t newId)
Set the element decl pool id for this element type.
Definition: XMLElementDecl.hpp:539
XMLElementDecl::getMemoryManager
MemoryManager * getMemoryManager() const
Get the memory manager.
Definition: XMLElementDecl.hpp:524
XMLElementDecl::getBaseName
const XMLCh * getBaseName() const
Get the base name of this element type.
Definition: XMLElementDecl.hpp:473
QName::getRawName
const XMLCh * getRawName() const
XMLElementDecl::isDeclared
bool isDeclared() const
Indicate whether this element type has been declared yet.
Definition: XMLElementDecl.hpp:513
MemoryManager
Configurable memory manager.
Definition: MemoryManager.hpp:39
XMLElementDecl::isExternal
bool isExternal() const
Indicate whether this element type has been declared externally.
Definition: XMLElementDecl.hpp:519
XMLPARSER_EXPORT
#define XMLPARSER_EXPORT
Definition: XercesDefs.hpp:163
XMLElementDecl::getElementName
const QName * getElementName() const
Get the QName of this element type.
Definition: XMLElementDecl.hpp:488
QName
Definition: QName.hpp:34
XMLAttDefList
This class defines an abstract interface that all validators must support.
Definition: XMLAttDefList.hpp:50
XMLElementDecl::getURI
unsigned int getURI() const
Get the URI id of this element type.
Definition: XMLElementDecl.hpp:483
XMLElementDecl::Declared
@ Declared
Definition: XMLElementDecl.hpp:72