source: NonGTP/Xerces/xerces-c_2_8_0/include/xercesc/validators/common/AllContentModel.hpp @ 2674

Revision 2674, 5.3 KB checked in by mattausch, 16 years ago (diff)
Line 
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: AllContentModel.hpp 568078 2007-08-21 11:43:25Z amassari $
20 */
21
22
23#if !defined(ALLCONTENTMODEL_HPP)
24#define ALLCONTENTMODEL_HPP
25
26#include <xercesc/framework/XMLContentModel.hpp>
27#include <xercesc/util/ValueVectorOf.hpp>
28#include <xercesc/validators/common/ContentLeafNameTypeVector.hpp>
29
30XERCES_CPP_NAMESPACE_BEGIN
31
32class ContentSpecNode;
33
34//
35//  AllContentModel is a derivative of the abstract content model base
36//  class that handles the special case of <all> feature in schema. If a model
37//  is <all>, all non-optional children must appear
38//
39//  So, all we have to do is to keep an array of the possible children and
40//  validate by just looking up each child being validated by looking it up
41//  in the list, and make sure all non-optional children appear.
42//
43class AllContentModel : public XMLContentModel
44{
45public :
46    // -----------------------------------------------------------------------
47    //  Constructors and Destructor
48    // -----------------------------------------------------------------------
49    AllContentModel
50    (
51          ContentSpecNode* const parentContentSpec
52                , const bool             isMixed
53        , MemoryManager* const   manager = XMLPlatformUtils::fgMemoryManager
54    );
55
56    ~AllContentModel();
57
58    // -----------------------------------------------------------------------
59    //  Implementation of the ContentModel virtual interface
60    // -----------------------------------------------------------------------
61    virtual int validateContent
62    (
63        QName** const         children
64      , const unsigned int    childCount
65      , const unsigned int    emptyNamespaceId
66    )   const;
67
68        virtual int validateContentSpecial
69    (
70        QName** const         children
71      , const unsigned int    childCount
72      , const unsigned int    emptyNamespaceId
73      , GrammarResolver*  const pGrammarResolver
74      , XMLStringPool*    const pStringPool
75    ) const;
76
77    virtual ContentLeafNameTypeVector* getContentLeafNameTypeVector() const ;
78
79    virtual unsigned int getNextState(const unsigned int currentState,
80                                      const unsigned int elementIndex) const;
81
82    virtual void checkUniqueParticleAttribution
83    (
84        SchemaGrammar*    const pGrammar
85      , GrammarResolver*  const pGrammarResolver
86      , XMLStringPool*    const pStringPool
87      , XMLValidator*     const pValidator
88      , unsigned int*     const pContentSpecOrgURI
89      , const XMLCh*            pComplexTypeName = 0
90    ) ;
91
92private :
93    // -----------------------------------------------------------------------
94    //  Private helper methods
95    // -----------------------------------------------------------------------
96    void buildChildList
97    (
98        ContentSpecNode* const                     curNode
99      , ValueVectorOf<QName*>&                     toFill
100      , ValueVectorOf<bool>&                       toType
101    );
102
103    // -----------------------------------------------------------------------
104    //  Unimplemented constructors and operators
105    // -----------------------------------------------------------------------
106    AllContentModel();
107    AllContentModel(const AllContentModel&);
108    AllContentModel& operator=(const AllContentModel&);
109
110
111    // -----------------------------------------------------------------------
112    //  Private data members
113    //
114    //  fCount
115    //      The count of possible children in the fChildren member.
116    //
117    //  fChildren
118    //      The list of possible children that we have to accept. This array
119    //      is allocated as large as needed in the constructor.
120    //
121    //  fChildOptional
122    //      The corresponding list of optional state of each child in fChildren
123    //      True if the child is optional (i.e. minOccurs = 0).
124    //
125    //  fNumRequired
126    //      The number of required children in <all> (i.e. minOccurs = 1)
127    //
128    //  fIsMixed
129    //      AllContentModel with mixed PCDATA.
130    // -----------------------------------------------------------------------
131    MemoryManager* fMemoryManager;
132    unsigned int    fCount;
133    QName**         fChildren;
134    bool*           fChildOptional;
135    unsigned int    fNumRequired;
136    bool            fIsMixed;
137    bool            fHasOptionalContent;
138};
139
140inline ContentLeafNameTypeVector* AllContentModel::getContentLeafNameTypeVector() const
141{
142        return 0;
143}
144
145inline unsigned int
146AllContentModel::getNextState(const unsigned int,
147                              const unsigned int) const {
148
149    return XMLContentModel::gInvalidTrans;
150}
151
152XERCES_CPP_NAMESPACE_END
153
154#endif
155
Note: See TracBrowser for help on using the repository browser.