Xerces-C++ 3.3.0
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
29#include <xercesc/internal/XSerializable.hpp>
30
32
33class ContentSpecNode;
34class XMLContentModel;
35
51class 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 // -----------------------------------------------------------------------
70 {
71 NoReason
72 , Declared
73 , AttList
74 , InContentModel
75 , AsRootElem
76 , JustFaultIn
77 };
78
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 // -----------------------------------------------------------------------
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
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
412 {
413 Schema
414 , DTD
415 , UnKnown
416 };
417
419
420 static void storeElementDecl(XSerializeEngine& serEng
421 , XMLElementDecl* const element);
422
423 static XMLElementDecl* loadElementDecl(XSerializeEngine& serEng);
424
425protected :
426 // -----------------------------------------------------------------------
427 // Hidden constructors
428 // -----------------------------------------------------------------------
430
431private :
432 // -----------------------------------------------------------------------
433 // Unimplemented constructors and operators
434 // -----------------------------------------------------------------------
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// ---------------------------------------------------------------------------
474{
475 return fElementName->getLocalPart();
476}
477
479{
480 return fElementName->getLocalPart();
481}
482
483inline unsigned int XMLElementDecl::getURI() const
484{
485 return fElementName->getURI();
486}
487
489{
490 return fElementName;
491}
492
494{
495 return fElementName;
496}
497
499{
500 return fElementName->getRawName();
501}
502
504{
505 return fCreateReason;
506}
507
509{
510 return fId;
511}
512
513inline bool XMLElementDecl::isDeclared() const
514{
515 return (fCreateReason == Declared);
516}
517
518
519inline bool XMLElementDecl::isExternal() const
520{
521 return fExternalElement;
522}
523
525{
526 return fMemoryManager;
527}
528
529
530// ---------------------------------------------------------------------------
531// XMLElementDecl: Setter methods
532// ---------------------------------------------------------------------------
533inline void
535{
536 fCreateReason = newReason;
537}
538
539inline void XMLElementDecl::setId(const XMLSize_t newId)
540{
541 fId = newId;
542}
543
544
545inline void XMLElementDecl::setExternalElemDeclaration(const bool aValue)
546{
547 fExternalElement = aValue;
548}
549
551
552#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
Definition QName.hpp:35
const XMLCh * getLocalPart() const
Definition QName.hpp:177
const XMLCh * getRawName() const
unsigned int getURI() const
Definition QName.hpp:187
This class defines an abstract interface that all validators must support.
Definition XMLAttDefList.hpp:51
This class defines the abstract interface for all content models.
Definition XMLContentModel.hpp:47
This class defines the core information of an element declaration.
Definition XMLElementDecl.hpp:52
const XMLCh * getFullName() const
Get the full name of this element type.
Definition XMLElementDecl.hpp:498
static XMLElementDecl * loadElementDecl(XSerializeEngine &serEng)
virtual void setContentSpec(ContentSpecNode *toAdopt)=0
Set the content spec node object for this element type.
CreateReasons
Definition XMLElementDecl.hpp:70
@ Declared
Definition XMLElementDecl.hpp:72
virtual const XMLCh * getFormattedContentModel() const =0
Geta formatted string of the content model.
XMLElementDecl(MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
void setCreateReason(const CreateReasons newReason)
Update the create reason for this element type.
Definition XMLElementDecl.hpp:534
virtual bool hasAttDefs() const =0
Indicate whether this element type defined any attributes.
MemoryManager * getMemoryManager() const
Get the memory manager.
Definition XMLElementDecl.hpp:524
objectType
Definition XMLElementDecl.hpp:412
XMLSize_t getId() const
Get the element decl pool id for this element type.
Definition XMLElementDecl.hpp:508
CharDataOpts
Definition XMLElementDecl.hpp:80
virtual XMLAttDefList & getAttDefList() const =0
Get a list of attributes defined for this element.
void setElementName(const XMLCh *const prefix, const XMLCh *const localPart, const int uriId)
Set the element name object for this element type.
const QName * getElementName() const
Get the QName of this element type.
Definition XMLElementDecl.hpp:488
bool isExternal() const
Indicate whether this element type has been declared externally.
Definition XMLElementDecl.hpp:519
const XMLCh * getBaseName() const
Get the base name of this element type.
Definition XMLElementDecl.hpp:473
void setElementName(const QName *const elementName)
Set the element name object for this element type.
bool isDeclared() const
Indicate whether this element type has been declared yet.
Definition XMLElementDecl.hpp:513
static const unsigned int fgPCDataElemId
Definition XMLElementDecl.hpp:102
virtual ContentSpecNode * getContentSpec()=0
Get a pointer to the content spec node.
void setElementName(const XMLCh *const rawName, const int uriId)
Set the element name object for this element type.
static void storeElementDecl(XSerializeEngine &serEng, XMLElementDecl *const element)
virtual void setContentModel(XMLContentModel *const newModelToAdopt)=0
Set the content model object for this element type.
void setId(const XMLSize_t newId)
Set the element decl pool id for this element type.
Definition XMLElementDecl.hpp:539
CreateReasons getCreateReason() const
Get the create reason for this element type.
Definition XMLElementDecl.hpp:503
unsigned int getURI() const
Get the URI id of this element type.
Definition XMLElementDecl.hpp:483
static const unsigned int fgInvalidElemId
Definition XMLElementDecl.hpp:101
virtual XMLElementDecl::objectType getObjectType() const =0
virtual ~XMLElementDecl()
void setExternalElemDeclaration(const bool aValue)
Set the element decl to indicate external declaration.
Definition XMLElementDecl.hpp:545
virtual XMLContentModel * getContentModel()=0
Get a pointer to the abstract content model.
virtual const ContentSpecNode * getContentSpec() const =0
Get a pointer to the content spec node.
virtual CharDataOpts getCharDataOpts() const =0
The character data options for this element type.
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition PlatformUtils.hpp:121
This class makes it possible to override the C++ memory management by adding new/delete operators to ...
Definition XMemory.hpp:41