Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:34:30

0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one or more
0003  * contributor license agreements.  See the NOTICE file distributed with
0004  * this work for additional information regarding copyright ownership.
0005  * The ASF licenses this file to You under the Apache License, Version 2.0
0006  * (the "License"); you may not use this file except in compliance with
0007  * the License.  You may obtain a copy of the License at
0008  *
0009  *      http://www.apache.org/licenses/LICENSE-2.0
0010  *
0011  * Unless required by applicable law or agreed to in writing, software
0012  * distributed under the License is distributed on an "AS IS" BASIS,
0013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014  * See the License for the specific language governing permissions and
0015  * limitations under the License.
0016  */
0017 
0018 /*
0019  * $Id$
0020  */
0021 
0022 #if !defined(XERCESC_INCLUDE_GUARD_ALLCONTENTMODEL_HPP)
0023 #define XERCESC_INCLUDE_GUARD_ALLCONTENTMODEL_HPP
0024 
0025 #include <xercesc/framework/XMLContentModel.hpp>
0026 #include <xercesc/util/ValueVectorOf.hpp>
0027 #include <xercesc/validators/common/ContentLeafNameTypeVector.hpp>
0028 
0029 XERCES_CPP_NAMESPACE_BEGIN
0030 
0031 class ContentSpecNode;
0032 
0033 //
0034 //  AllContentModel is a derivative of the abstract content model base
0035 //  class that handles the special case of <all> feature in schema. If a model
0036 //  is <all>, all non-optional children must appear
0037 //
0038 //  So, all we have to do is to keep an array of the possible children and
0039 //  validate by just looking up each child being validated by looking it up
0040 //  in the list, and make sure all non-optional children appear.
0041 //
0042 class AllContentModel : public XMLContentModel
0043 {
0044 public :
0045     // -----------------------------------------------------------------------
0046     //  Constructors and Destructor
0047     // -----------------------------------------------------------------------
0048     AllContentModel
0049     (
0050           ContentSpecNode* const parentContentSpec
0051         , const bool             isMixed
0052         , MemoryManager* const   manager = XMLPlatformUtils::fgMemoryManager
0053     );
0054 
0055     ~AllContentModel();
0056 
0057     // -----------------------------------------------------------------------
0058     //  Implementation of the ContentModel virtual interface
0059     // -----------------------------------------------------------------------
0060     virtual bool validateContent
0061     (
0062         QName** const         children
0063       , XMLSize_t             childCount
0064       , unsigned int          emptyNamespaceId
0065       , XMLSize_t*            indexFailingChild
0066       , MemoryManager*  const manager = XMLPlatformUtils::fgMemoryManager
0067     )   const;
0068 
0069     virtual bool validateContentSpecial
0070     (
0071         QName** const           children
0072       , XMLSize_t               childCount
0073       , unsigned int            emptyNamespaceId
0074       , GrammarResolver*  const pGrammarResolver
0075       , XMLStringPool*    const pStringPool
0076       , XMLSize_t*              indexFailingChild
0077       , MemoryManager*    const manager = XMLPlatformUtils::fgMemoryManager
0078     ) const;
0079 
0080     virtual ContentLeafNameTypeVector* getContentLeafNameTypeVector() const ;
0081 
0082     virtual unsigned int getNextState(unsigned int currentState,
0083                                       XMLSize_t    elementIndex) const;
0084 
0085     virtual bool handleRepetitions( const QName* const curElem,
0086                                     unsigned int curState,
0087                                     unsigned int currentLoop,
0088                                     unsigned int& nextState,
0089                                     unsigned int& nextLoop,
0090                                     XMLSize_t elementIndex,
0091                                     SubstitutionGroupComparator * comparator) const;
0092 
0093     virtual void checkUniqueParticleAttribution
0094     (
0095         SchemaGrammar*    const pGrammar
0096       , GrammarResolver*  const pGrammarResolver
0097       , XMLStringPool*    const pStringPool
0098       , XMLValidator*     const pValidator
0099       , unsigned int*     const pContentSpecOrgURI
0100       , const XMLCh*            pComplexTypeName = 0
0101     ) ;
0102 
0103 private :
0104     // -----------------------------------------------------------------------
0105     //  Private helper methods
0106     // -----------------------------------------------------------------------
0107     void buildChildList
0108     (
0109         ContentSpecNode* const                     curNode
0110       , ValueVectorOf<QName*>&                     toFill
0111       , ValueVectorOf<bool>&                       toType
0112     );
0113 
0114     // -----------------------------------------------------------------------
0115     //  Unimplemented constructors and operators
0116     // -----------------------------------------------------------------------
0117     AllContentModel();
0118     AllContentModel(const AllContentModel&);
0119     AllContentModel& operator=(const AllContentModel&);
0120 
0121 
0122     // -----------------------------------------------------------------------
0123     //  Private data members
0124     //
0125     //  fCount
0126     //      The count of possible children in the fChildren member.
0127     //
0128     //  fChildren
0129     //      The list of possible children that we have to accept. This array
0130     //      is allocated as large as needed in the constructor.
0131     //
0132     //  fChildOptional
0133     //      The corresponding list of optional state of each child in fChildren
0134     //      True if the child is optional (i.e. minOccurs = 0).
0135     //
0136     //  fNumRequired
0137     //      The number of required children in <all> (i.e. minOccurs = 1)
0138     //
0139     //  fIsMixed
0140     //      AllContentModel with mixed PCDATA.
0141     // -----------------------------------------------------------------------
0142     MemoryManager* fMemoryManager;
0143     XMLSize_t       fCount;
0144     QName**         fChildren;
0145     bool*           fChildOptional;
0146     unsigned int    fNumRequired;
0147     bool            fIsMixed;
0148     bool            fHasOptionalContent;
0149 };
0150 
0151 inline ContentLeafNameTypeVector* AllContentModel::getContentLeafNameTypeVector() const
0152 {
0153     return 0;
0154 }
0155 
0156 inline unsigned int
0157 AllContentModel::getNextState(unsigned int,
0158                               XMLSize_t) const {
0159 
0160     return XMLContentModel::gInvalidTrans;
0161 }
0162 
0163 inline bool
0164 AllContentModel::handleRepetitions( const QName* const /*curElem*/,
0165                                     unsigned int /*curState*/,
0166                                     unsigned int /*currentLoop*/,
0167                                     unsigned int& /*nextState*/,
0168                                     unsigned int& /*nextLoop*/,
0169                                     XMLSize_t /*elementIndex*/,
0170                                     SubstitutionGroupComparator * /*comparator*/) const
0171 {
0172     return true;
0173 }
0174 
0175 XERCES_CPP_NAMESPACE_END
0176 
0177 #endif