Xerces-C++  3.1.2
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: XMLElementDecl.hpp 932887 2010-04-11 13:04:59Z borisk $
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 
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  // -----------------------------------------------------------------------
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  // -----------------------------------------------------------------------
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 
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  // -----------------------------------------------------------------------
430 
431 private :
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 // ---------------------------------------------------------------------------
473 inline const XMLCh* XMLElementDecl::getBaseName() const
474 {
475  return fElementName->getLocalPart();
476 }
477 
479 {
480  return fElementName->getLocalPart();
481 }
482 
483 inline unsigned int XMLElementDecl::getURI() const
484 {
485  return fElementName->getURI();
486 }
487 
489 {
490  return fElementName;
491 }
492 
494 {
495  return fElementName;
496 }
497 
498 inline const XMLCh* XMLElementDecl::getFullName() const
499 {
500  return fElementName->getRawName();
501 }
502 
504 {
505  return fCreateReason;
506 }
507 
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 
525 {
526  return fMemoryManager;
527 }
528 
529 
530 // ---------------------------------------------------------------------------
531 // XMLElementDecl: Setter methods
532 // ---------------------------------------------------------------------------
533 inline void
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 
551 
552 #endif
Definition: XMLElementDecl.hpp:72
This class makes it possible to override the C++ memory management by adding new/delete operators to ...
Definition: XMemory.hpp:40
XMLSize_t getId() const
Get the element decl pool id for this element type.
Definition: XMLElementDecl.hpp:508
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition: PlatformUtils.hpp:121
CreateReasons
Definition: XMLElementDecl.hpp:69
const XMLCh * getLocalPart() const
Definition: QName.hpp:177
This class defines the abstract interface for all content models.
Definition: XMLContentModel.hpp:46
bool isExternal() const
Indicate whether this element type has been declared externally.
Definition: XMLElementDecl.hpp:519
const QName * getElementName() const
Get the QName of this element type.
Definition: XMLElementDecl.hpp:488
unsigned int getURI() const
Definition: QName.hpp:187
This class defines an abstract interface that all validators must support.
Definition: XMLAttDefList.hpp:50
#define XMLPARSER_EXPORT
Definition: XercesDefs.hpp:163
static const unsigned int fgPCDataElemId
Definition: XMLElementDecl.hpp:102
void setCreateReason(const CreateReasons newReason)
Update the create reason for this element type.
Definition: XMLElementDecl.hpp:534
Configurable memory manager.
Definition: MemoryManager.hpp:39
This class defines the core information of an element declaration.
Definition: XMLElementDecl.hpp:51
static const unsigned int fgInvalidElemId
Definition: XMLElementDecl.hpp:101
objectType
Definition: XMLElementDecl.hpp:411
SIZE_T XMLSize_t
Definition: Xerces_autoconf_config.borland.hpp:86
void setId(const XMLSize_t newId)
Set the element decl pool id for this element type.
Definition: XMLElementDecl.hpp:539
Definition: QName.hpp:34
#define XERCES_CPP_NAMESPACE_BEGIN
Definition: XercesDefs.hpp:112
wchar_t XMLCh
Definition: Xerces_autoconf_config.borland.hpp:92
CharDataOpts
Definition: XMLElementDecl.hpp:79
CreateReasons getCreateReason() const
Get the create reason for this element type.
Definition: XMLElementDecl.hpp:503
void setExternalElemDeclaration(const bool aValue)
Set the element decl to indicate external declaration.
Definition: XMLElementDecl.hpp:545
bool isDeclared() const
Indicate whether this element type has been declared yet.
Definition: XMLElementDecl.hpp:513
#define XERCES_CPP_NAMESPACE_END
Definition: XercesDefs.hpp:113
const XMLCh * getFullName() const
Get the full name of this element type.
Definition: XMLElementDecl.hpp:498
const XMLCh * getBaseName() const
Get the base name of this element type.
Definition: XMLElementDecl.hpp:473
unsigned int getURI() const
Get the URI id of this element type.
Definition: XMLElementDecl.hpp:483
const XMLCh * getRawName() const
MemoryManager * getMemoryManager() const
Get the memory manager.
Definition: XMLElementDecl.hpp:524