Xerces-C++: XMLElementDecl.hpp Source File

| API Docs for SAX and DOM |
| Main Page Classes Files Related Pages # XMLElementDecl.hpp Go to the documentation of this file.
    00001 /*
    00002  * Licensed to the Apache Software Foundation (ASF) under one or more
    00003  * contributor license agreements.  See the NOTICE file distributed with
    00004  * this work for additional information regarding copyright ownership.
    00005  * The ASF licenses this file to You under the Apache License, Version 2.0
    00006  * (the "License"); you may not use this file except in compliance with
    00007  * the License.  You may obtain a copy of the License at
    00008  *
    00009  *      http://www.apache.org/licenses/LICENSE-2.0
    00010  *
    00011  * Unless required by applicable law or agreed to in writing, software
    00012  * distributed under the License is distributed on an "AS IS" BASIS,
    00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00014  * See the License for the specific language governing permissions and
    00015  * limitations under the License.
    00016  */
    00017
    00018 /*
    00019  * $Id: XMLElementDecl.hpp 568078 2007-08-21 11:43:25Z amassari $
    00020  */
    00021
    00022 #if !defined(XMLELEMENTDECL_HPP)
    00023 #define XMLELEMENTDECL_HPP
    00024
    00025 #include <xercesc/framework/XMLAttr.hpp>
    00026 #include <xercesc/framework/XMLAttDefList.hpp>
    00027 #include <xercesc/util/XMLString.hpp>
    00028 #include <xercesc/util/PlatformUtils.hpp>
    00029 #include <xercesc/internal/XSerializable.hpp>
    00030
    00031 XERCES_CPP_NAMESPACE_BEGIN
    00032
    00033 class ContentSpecNode;
    00034 class XMLContentModel;
    00035
    00051 class  XMLElementDecl : public XSerializable, public XMemory
    00052 {
    00053  public:
    00054     // -----------------------------------------------------------------------
    00055     //  Class specific types
    00056     //
    00057     //  CreateReasons
    00058     //      This type is used to store how an element declaration got into
    00059     //      the grammar's element pool. They are faulted in for various
    00060     //      reasons.
    00061     //
    00062     //  LookupOpts
    00063     //      These are the values used by the attribute lookup methods.
    00064     //
    00065     //  CharDataOpts
    00066     //      This is used to indicate how this type of element reacts to
    00067     //      character data as content.
    00068     // -----------------------------------------------------------------------
    00069     enum CreateReasons
    00070     {
    00071         NoReason
    00072         , Declared
    00073         , AttList
    00074         , InContentModel
    00075         , AsRootElem
    00076         , JustFaultIn
    00077     };
    00078
    00083     enum LookupOpts
    00084     {
    00085         AddIfNotFound
    00086         , FailIfNotFound
    00087     };
    00088
    00089     enum CharDataOpts
    00090     {
    00091         NoCharData
    00092         , SpacesOk
    00093         , AllCharData
    00094     };
    00095
    00096
    00097     // -----------------------------------------------------------------------
    00098     //  Public static data
    00099     //
    00100     //  fgInvalidElemId
    00101     //      A value to represent an invalid element node id.
    00102     //
    00103     //  fgPCDataElemId
    00104     //      This is the value to use to represent a PCDATA node when an
    00105     //      element id is required.
    00106     //
    00107     //  fgPCDataElemName
    00108     //      This is the value to use to represent a PCDATA node when an
    00109     //      element name is required.
    00110     // -----------------------------------------------------------------------
    00111     static const unsigned int   fgInvalidElemId;
    00112     static const unsigned int   fgPCDataElemId;
    00113     static const XMLCh          fgPCDataElemName[];
    00114
    00115
    00116
    00117     // -----------------------------------------------------------------------
    00118     //  Destructor
    00119     // -----------------------------------------------------------------------
    00122     virtual ~XMLElementDecl();
    00124
    00125
    00126     // -----------------------------------------------------------------------
    00127     //  The virtual element decl interface
    00128     // -----------------------------------------------------------------------
    00129
    00132
    00163     virtual XMLAttDef* findAttr
    00164     (
    00165         const   XMLCh* const    qName
    00166         , const unsigned int    uriId
    00167         , const XMLCh* const    baseName
    00168         , const XMLCh* const    prefix
    00169         , const LookupOpts      options
    00170         ,       bool&           wasAdded
    00171     )   const = 0;
    00172
    00184     virtual XMLAttDefList& getAttDefList() const = 0;
    00185
    00193     virtual CharDataOpts getCharDataOpts() const = 0;
    00194
    00201     virtual bool hasAttDefs() const = 0;
    00202
    00210     virtual bool resetDefs() = 0;
    00211
    00219     virtual const ContentSpecNode* getContentSpec() const = 0;
    00220
    00226     virtual ContentSpecNode* getContentSpec() = 0;
    00227
    00237     virtual void setContentSpec(ContentSpecNode* toAdopt) = 0;
    00238
    00250     virtual XMLContentModel* getContentModel() = 0;
    00251
    00263     virtual void setContentModel(XMLContentModel* const newModelToAdopt) = 0;
    00264
    00277     virtual const XMLCh* getFormattedContentModel ()   const = 0;
    00278
    00280
    00281
    00282     // -----------------------------------------------------------------------
    00283     //  Getter methods
    00284     // -----------------------------------------------------------------------
    00285
    00288
    00296     const XMLCh* getBaseName() const;
    00297     XMLCh* getBaseName();
    00298
    00305     unsigned int getURI() const;
    00306
    00314     const QName* getElementName() const;
    00315     QName* getElementName();
    00316
    00325     const XMLCh* getFullName() const;
    00326
    00338     CreateReasons getCreateReason() const;
    00339
    00349     unsigned int getId() const;
    00350
    00351
    00356     virtual const XMLCh* getDOMTypeInfoUri() const = 0;
    00357
    00362     virtual const XMLCh* getDOMTypeInfoName() const = 0;
    00363
    00364
    00374     bool isDeclared() const;
    00375
    00384     bool isExternal() const;
    00385
    00393     MemoryManager* getMemoryManager() const;
    00394
    00396
    00397
    00398     // -----------------------------------------------------------------------
    00399     //  Setter methods
    00400     // -----------------------------------------------------------------------
    00401
    00404
    00415       void setElementName(const XMLCh* const       prefix
    00416                         , const XMLCh* const       localPart
    00417                         , const int                uriId );
    00418
    00428       void setElementName(const XMLCh* const    rawName
    00429                         , const int             uriId );
    00430
    00439       void setElementName(const QName* const    elementName);
    00440
    00451     void setCreateReason(const CreateReasons newReason);
    00452
    00459     void setId(const unsigned int newId);
    00460
    00461
    00465     void setExternalElemDeclaration(const bool aValue);
    00466
    00468
    00469
    00470     // -----------------------------------------------------------------------
    00471     //  Miscellaneous methods
    00472     // -----------------------------------------------------------------------
    00473
    00476
    00478
    00479     /***
    00480      * Support for Serialization/De-serialization
    00481      ***/
    00482     DECL_XSERIALIZABLE(XMLElementDecl)
    00483
    00484     enum objectType
    00485     {
    00486         Schema
    00487       , DTD
    00488       , UnKnown
    00489     };
    00490
    00491     virtual XMLElementDecl::objectType  getObjectType() const = 0;
    00492
    00493     static void            storeElementDecl(XSerializeEngine&        serEng
    00494                                           , XMLElementDecl*    const element);
    00495
    00496     static XMLElementDecl* loadElementDecl(XSerializeEngine& serEng);
    00497
    00498 protected :
    00499     // -----------------------------------------------------------------------
    00500     //  Hidden constructors
    00501     // -----------------------------------------------------------------------
    00502     XMLElementDecl(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
    00503
    00504 private :
    00505     // -----------------------------------------------------------------------
    00506     //  Unimplemented constructors and operators
    00507     // -----------------------------------------------------------------------
    00508     XMLElementDecl(const XMLElementDecl&);
    00509     XMLElementDecl& operator=(const XMLElementDecl&);
    00510
    00511
    00512     // -----------------------------------------------------------------------
    00513     //  Data members
    00514     //
    00515     //  fElementName
    00516     //      This is the name of the element decl.
    00517     //
    00518     //  fCreateReason
    00519     //      We sometimes have to put an element decl object into the elem
    00520     //      decl pool before the element's declaration is seen, such as when
    00521     //      its used in another element's content model or an att list is
    00522     //      seen for it. This flag tells us whether its been declared, and
    00523     //      if not why it had to be created.
    00524     //
    00525     //  fId
    00526     //      The unique id of this element. This is created by the derived
    00527     //      class, or more accurately the grammar that owns the objects
    00528     //      of the derived types. But, since they all have to have them, we
    00529     //      let them all store the id here. It is defaulted to have the
    00530     //      value fgInvalidElem until explicitly set.
    00531     //
    00532     //  fExternalElement
    00533     //      This flag indicates whether or the element was declared externally.
    00534     // -----------------------------------------------------------------------
    00535     MemoryManager*      fMemoryManager;
    00536     QName*              fElementName;
    00537     CreateReasons       fCreateReason;
    00538     unsigned int        fId;
    00539     bool                fExternalElement;
    00540 };
    00541
    00542
    00543 // ---------------------------------------------------------------------------
    00544 //  XMLElementDecl: Getter methods
    00545 // ---------------------------------------------------------------------------
    00546 inline const XMLCh* XMLElementDecl::getBaseName() const
    00547 {
    00548     return fElementName->getLocalPart();
    00549 }
    00550
    00551 inline XMLCh* XMLElementDecl::getBaseName()
    00552 {
    00553     return fElementName->getLocalPart();
    00554 }
    00555
    00556 inline unsigned int XMLElementDecl::getURI() const
    00557 {
    00558     return fElementName->getURI();
    00559 }
    00560
    00561 inline const QName* XMLElementDecl::getElementName() const
    00562 {
    00563     return fElementName;
    00564 }
    00565
    00566 inline QName* XMLElementDecl::getElementName()
    00567 {
    00568     return fElementName;
    00569 }
    00570
    00571 inline const XMLCh* XMLElementDecl::getFullName() const
    00572 {
    00573     return fElementName->getRawName();
    00574 }
    00575
    00576 inline XMLElementDecl::CreateReasons XMLElementDecl::getCreateReason() const
    00577 {
    00578     return fCreateReason;
    00579 }
    00580
    00581 inline unsigned int XMLElementDecl::getId() const
    00582 {
    00583     return fId;
    00584 }
    00585
    00586 inline bool XMLElementDecl::isDeclared() const
    00587 {
    00588     return (fCreateReason == Declared);
    00589 }
    00590
    00591
    00592 inline bool XMLElementDecl::isExternal() const
    00593 {
    00594     return fExternalElement;
    00595 }
    00596
    00597 inline MemoryManager* XMLElementDecl::getMemoryManager() const
    00598 {
    00599     return fMemoryManager;
    00600 }
    00601
    00602
    00603 // ---------------------------------------------------------------------------
    00604 //  XMLElementDecl: Setter methods
    00605 // ---------------------------------------------------------------------------
    00606 inline void
    00607 XMLElementDecl::setCreateReason(const XMLElementDecl::CreateReasons newReason)
    00608 {
    00609     fCreateReason = newReason;
    00610 }
    00611
    00612 inline void XMLElementDecl::setId(const unsigned int newId)
    00613 {
    00614     fId = newId;
    00615 }
    00616
    00617
    00618 inline void XMLElementDecl::setExternalElemDeclaration(const bool aValue)
    00619 {
    00620     fExternalElement = aValue;
    00621 }
    00622
    00623 XERCES_CPP_NAMESPACE_END
    00624
    00625 #endif

Copyright © 1994-2004 The Apache Software Foundation. All Rights Reserved.