source: NonGTP/Xerces/xercesc/validators/common/AllContentModel.hpp @ 188

Revision 188, 7.9 KB checked in by mattausch, 19 years ago (diff)

added xercesc to support

Line 
1/*
2 * The Apache Software License, Version 1.1
3 *
4 * Copyright (c) 2001 The Apache Software Foundation.  All rights
5 * reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 *
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in
16 *    the documentation and/or other materials provided with the
17 *    distribution.
18 *
19 * 3. The end-user documentation included with the redistribution,
20 *    if any, must include the following acknowledgment:
21 *       "This product includes software developed by the
22 *        Apache Software Foundation (http://www.apache.org/)."
23 *    Alternately, this acknowledgment may appear in the software itself,
24 *    if and wherever such third-party acknowledgments normally appear.
25 *
26 * 4. The names "Xerces" and "Apache Software Foundation" must
27 *    not be used to endorse or promote products derived from this
28 *    software without prior written permission. For written
29 *    permission, please contact apache\@apache.org.
30 *
31 * 5. Products derived from this software may not be called "Apache",
32 *    nor may "Apache" appear in their name, without prior written
33 *    permission of the Apache Software Foundation.
34 *
35 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46 * SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This software consists of voluntary contributions made by many
50 * individuals on behalf of the Apache Software Foundation, and was
51 * originally based on software copyright (c) 2001, International
52 * Business Machines, Inc., http://www.ibm.com .  For more information
53 * on the Apache Software Foundation, please see
54 * <http://www.apache.org/>.
55 */
56
57/*
58 * $Log: AllContentModel.hpp,v $
59 * Revision 1.6  2004/01/29 11:51:21  cargilld
60 * Code cleanup changes to get rid of various compiler diagnostic messages.
61 *
62 * Revision 1.5  2003/05/16 21:43:20  knoaman
63 * Memory manager implementation: Modify constructors to pass in the memory manager.
64 *
65 * Revision 1.4  2003/05/15 18:48:27  knoaman
66 * Partial implementation of the configurable memory manager.
67 *
68 * Revision 1.3  2003/03/07 18:16:57  tng
69 * Return a reference instead of void for operator=
70 *
71 * Revision 1.2  2002/11/04 14:54:58  tng
72 * C++ Namespace Support.
73 *
74 * Revision 1.1.1.1  2002/02/01 22:22:37  peiyongz
75 * sane_include
76 *
77 * Revision 1.2  2001/11/21 14:30:13  knoaman
78 * Fix for UPA checking.
79 *
80 * Revision 1.1  2001/08/24 12:48:48  tng
81 * Schema: AllContentModel
82 *
83 */
84
85
86#if !defined(ALLCONTENTMODEL_HPP)
87#define ALLCONTENTMODEL_HPP
88
89#include <xercesc/framework/XMLContentModel.hpp>
90#include <xercesc/util/ValueVectorOf.hpp>
91#include <xercesc/validators/common/ContentLeafNameTypeVector.hpp>
92
93XERCES_CPP_NAMESPACE_BEGIN
94
95class ContentSpecNode;
96
97//
98//  AllContentModel is a derivative of the abstract content model base
99//  class that handles the special case of <all> feature in schema. If a model
100//  is <all>, all non-optional children must appear
101//
102//  So, all we have to do is to keep an array of the possible children and
103//  validate by just looking up each child being validated by looking it up
104//  in the list, and make sure all non-optional children appear.
105//
106class AllContentModel : public XMLContentModel
107{
108public :
109    // -----------------------------------------------------------------------
110    //  Constructors and Destructor
111    // -----------------------------------------------------------------------
112    AllContentModel
113    (
114          ContentSpecNode* const parentContentSpec
115                , const bool             isMixed
116        , MemoryManager* const   manager = XMLPlatformUtils::fgMemoryManager
117    );
118
119    ~AllContentModel();
120
121    // -----------------------------------------------------------------------
122    //  Implementation of the ContentModel virtual interface
123    // -----------------------------------------------------------------------
124    virtual int validateContent
125    (
126        QName** const         children
127      , const unsigned int    childCount
128      , const unsigned int    emptyNamespaceId
129    )   const;
130
131        virtual int validateContentSpecial
132    (
133        QName** const         children
134      , const unsigned int    childCount
135      , const unsigned int    emptyNamespaceId
136      , GrammarResolver*  const pGrammarResolver
137      , XMLStringPool*    const pStringPool
138    ) const;
139
140    virtual ContentLeafNameTypeVector* getContentLeafNameTypeVector() const ;
141
142    virtual unsigned int getNextState(const unsigned int currentState,
143                                      const unsigned int elementIndex) const;
144
145    virtual void checkUniqueParticleAttribution
146    (
147        SchemaGrammar*    const pGrammar
148      , GrammarResolver*  const pGrammarResolver
149      , XMLStringPool*    const pStringPool
150      , XMLValidator*     const pValidator
151      , unsigned int*     const pContentSpecOrgURI
152    ) ;
153
154private :
155    // -----------------------------------------------------------------------
156    //  Private helper methods
157    // -----------------------------------------------------------------------
158    void buildChildList
159    (
160        ContentSpecNode* const                     curNode
161      , ValueVectorOf<QName*>&                     toFill
162      , ValueVectorOf<bool>&                       toType
163    );
164
165    // -----------------------------------------------------------------------
166    //  Unimplemented constructors and operators
167    // -----------------------------------------------------------------------
168    AllContentModel();
169    AllContentModel(const AllContentModel&);
170    AllContentModel& operator=(const AllContentModel&);
171
172
173    // -----------------------------------------------------------------------
174    //  Private data members
175    //
176    //  fCount
177    //      The count of possible children in the fChildren member.
178    //
179    //  fChildren
180    //      The list of possible children that we have to accept. This array
181    //      is allocated as large as needed in the constructor.
182    //
183    //  fChildOptional
184    //      The corresponding list of optional state of each child in fChildren
185    //      True if the child is optional (i.e. minOccurs = 0).
186    //
187    //  fNumRequired
188    //      The number of required children in <all> (i.e. minOccurs = 1)
189    //
190    //  fIsMixed
191    //      AllContentModel with mixed PCDATA.
192    // -----------------------------------------------------------------------
193    MemoryManager* fMemoryManager;
194    unsigned int    fCount;
195    QName**         fChildren;
196    bool*           fChildOptional;
197    unsigned int    fNumRequired;
198    bool            fIsMixed;
199
200};
201
202inline ContentLeafNameTypeVector* AllContentModel::getContentLeafNameTypeVector() const
203{
204        return 0;
205}
206
207inline unsigned int
208AllContentModel::getNextState(const unsigned int,
209                              const unsigned int) const {
210
211    return XMLContentModel::gInvalidTrans;
212}
213
214XERCES_CPP_NAMESPACE_END
215
216#endif
217
Note: See TracBrowser for help on using the repository browser.