source: trunk/VUT/GtpVisibilityPreprocessor/support/xercesc/validators/common/SimpleContentModel.hpp @ 188

Revision 188, 11.2 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) 1999-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) 1999, 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: SimpleContentModel.hpp,v $
59 * Revision 1.9  2004/01/29 11:51:21  cargilld
60 * Code cleanup changes to get rid of various compiler diagnostic messages.
61 *
62 * Revision 1.8  2003/12/17 00:18:38  cargilld
63 * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
64 *
65 * Revision 1.7  2003/06/03 18:12:29  knoaman
66 * Add default value for memory manager argument.
67 *
68 * Revision 1.6  2003/05/18 14:02:06  knoaman
69 * Memory manager implementation: pass per instance manager.
70 *
71 * Revision 1.5  2003/05/15 18:48:27  knoaman
72 * Partial implementation of the configurable memory manager.
73 *
74 * Revision 1.4  2003/03/07 18:16:57  tng
75 * Return a reference instead of void for operator=
76 *
77 * Revision 1.3  2002/11/04 14:54:58  tng
78 * C++ Namespace Support.
79 *
80 * Revision 1.2  2002/10/30 21:52:00  tng
81 * [Bug 13641] compiler-generated copy-constructor for QName doesn't do the right thing.
82 *
83 * Revision 1.1.1.1  2002/02/01 22:22:39  peiyongz
84 * sane_include
85 *
86 * Revision 1.12  2001/11/21 14:30:13  knoaman
87 * Fix for UPA checking.
88 *
89 * Revision 1.11  2001/10/03 15:08:45  tng
90 * typo fix: remove the extra space which may confuse some compilers while constructing the qname.
91 *
92 * Revision 1.10  2001/08/21 16:06:11  tng
93 * Schema: Unique Particle Attribution Constraint Checking.
94 *
95 * Revision 1.9  2001/08/13 15:06:39  knoaman
96 * update <any> validation.
97 *
98 * Revision 1.8  2001/05/11 13:27:20  tng
99 * Copyright update.
100 *
101 * Revision 1.7  2001/05/03 21:02:33  tng
102 * Schema: Add SubstitutionGroupComparator and update exception messages.  By Pei Yong Zhang.
103 *
104 * Revision 1.6  2001/04/19 18:17:34  tng
105 * Schema: SchemaValidator update, and use QName in Content Model
106 *
107 * Revision 1.5  2001/03/21 21:56:29  tng
108 * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
109 *
110 * Revision 1.4  2001/03/21 19:30:02  tng
111 * Schema: Content Model Updates, by Pei Yong Zhang.
112 *
113 * Revision 1.3  2001/02/27 14:48:57  tng
114 * Schema: Add CMAny and ContentLeafNameTypeVector, by Pei Yong Zhang
115 *
116 * Revision 1.2  2001/02/16 14:58:57  tng
117 * Schema: Update Makefile, configure files, project files, and include path in
118 * certain cpp files because of the move of the common Content Model files.  By Pei Yong Zhang.
119 *
120 * Revision 1.1  2001/02/16 14:17:29  tng
121 * Schema: Move the common Content Model files that are shared by DTD
122 * and schema from 'DTD' folder to 'common' folder.  By Pei Yong Zhang.
123 *
124 * Revision 1.3  2000/02/24 20:16:49  abagchi
125 * Swat for removing Log from API docs
126 *
127 * Revision 1.2  2000/02/09 21:42:39  abagchi
128 * Copyright swat
129 *
130 * Revision 1.1.1.1  1999/11/09 01:03:48  twl
131 * Initial checkin
132 *
133 * Revision 1.2  1999/11/08 20:45:44  rahul
134 * Swat for adding in Product name and CVS comment log variable.
135 *
136 */
137
138
139#if !defined(SIMPLECONTENTMODEL_HPP)
140#define SIMPLECONTENTMODEL_HPP
141
142#include <xercesc/framework/XMLContentModel.hpp>
143#include <xercesc/validators/common/ContentSpecNode.hpp>
144
145XERCES_CPP_NAMESPACE_BEGIN
146
147//
148//  SimpleContentModel is a derivative of the abstract content model base
149//  class that handles a small set of simple content models that are just
150//  way overkill to give the DFA treatment.
151//
152//  DESCRIPTION:
153//
154//  This guy handles the following scenarios:
155//
156//      a
157//      a?
158//      a*
159//      a+
160//      a,b
161//      a|b
162//
163//  These all involve a unary operation with one element type, or a binary
164//  operation with two elements. These are very simple and can be checked
165//  in a simple way without a DFA and without the overhead of setting up a
166//  DFA for such a simple check.
167//
168//  NOTE:   Pass the XMLElementDecl::fgPCDataElemId value to represent a
169//          PCData node. Pass XMLElementDecl::fgInvalidElemId for unused element
170//
171class SimpleContentModel : public XMLContentModel
172{
173public :
174    // -----------------------------------------------------------------------
175    //  Constructors and Destructor
176    // -----------------------------------------------------------------------
177    SimpleContentModel
178    (
179        const bool                        dtd
180      , QName* const                      firstChild
181      , QName* const                      secondChild
182      , const ContentSpecNode::NodeTypes  cmOp
183      , MemoryManager* const              manager = XMLPlatformUtils::fgMemoryManager
184    );
185
186    ~SimpleContentModel();
187
188
189    // -----------------------------------------------------------------------
190    //  Implementation of the ContentModel virtual interface
191    // -----------------------------------------------------------------------
192        virtual int validateContent
193    (
194        QName** const         children
195      , const unsigned int    childCount
196      , const unsigned int    emptyNamespaceId
197    ) const;
198
199        virtual int validateContentSpecial
200    (
201        QName** const           children
202      , const unsigned int      childCount
203      , const unsigned int      emptyNamespaceId
204      , GrammarResolver*  const pGrammarResolver
205      , XMLStringPool*    const pStringPool
206    ) const;
207
208    virtual ContentLeafNameTypeVector *getContentLeafNameTypeVector() const;
209
210    virtual unsigned int getNextState(const unsigned int currentState,
211                                      const unsigned int elementIndex) const;
212
213    virtual void checkUniqueParticleAttribution
214    (
215        SchemaGrammar*    const pGrammar
216      , GrammarResolver*  const pGrammarResolver
217      , XMLStringPool*    const pStringPool
218      , XMLValidator*     const pValidator
219      , unsigned int*     const pContentSpecOrgURI
220    ) ;
221
222 private :
223    // -----------------------------------------------------------------------
224    //  Unimplemented constructors and operators
225    // -----------------------------------------------------------------------
226    SimpleContentModel();
227    SimpleContentModel(const SimpleContentModel&);
228    SimpleContentModel& operator=(const SimpleContentModel&);
229
230
231    // -----------------------------------------------------------------------
232    //  Private data members
233    //
234    //  fFirstChild
235    //  fSecondChild
236    //      The first (and optional second) child node. The
237    //      operation code tells us whether the second child is used or not.
238    //
239    //  fOp
240    //      The operation that this object represents. Since this class only
241    //      does simple contents, there is only ever a single operation
242    //      involved (i.e. the children of the operation are always one or
243    //      two leafs.)
244    //
245    //  fDTD
246    //      Boolean to allow DTDs to validate even with namespace support. */
247    //
248    // -----------------------------------------------------------------------
249    QName*                     fFirstChild;
250    QName*                     fSecondChild;
251    ContentSpecNode::NodeTypes fOp;
252    bool                       fDTD;
253    MemoryManager* const       fMemoryManager;
254};
255
256
257// ---------------------------------------------------------------------------
258//  SimpleContentModel: Constructors and Destructor
259// ---------------------------------------------------------------------------
260inline SimpleContentModel::SimpleContentModel
261(
262      const bool                       dtd
263    , QName* const                     firstChild
264    , QName* const                     secondChild
265    , const ContentSpecNode::NodeTypes cmOp
266     , MemoryManager* const            manager
267)
268    : fFirstChild(0)
269    , fSecondChild(0)
270    , fOp(cmOp)
271        , fDTD(dtd)
272    , fMemoryManager(manager)
273{
274    if (firstChild)
275        fFirstChild = new (manager) QName(*firstChild);
276    else
277        fFirstChild = new (manager) QName(XMLUni::fgZeroLenString, XMLUni::fgZeroLenString, XMLElementDecl::fgInvalidElemId, manager);
278
279    if (secondChild)
280        fSecondChild = new (manager) QName(*secondChild);
281    else
282        fSecondChild = new (manager) QName(XMLUni::fgZeroLenString, XMLUni::fgZeroLenString, XMLElementDecl::fgInvalidElemId, manager);
283}
284
285inline SimpleContentModel::~SimpleContentModel()
286{
287    delete fFirstChild;
288    delete fSecondChild;
289}
290
291
292// ---------------------------------------------------------------------------
293//  SimpleContentModel: Virtual methods
294// ---------------------------------------------------------------------------
295inline unsigned int
296SimpleContentModel::getNextState(const unsigned int,
297                                 const unsigned int) const {
298
299    return XMLContentModel::gInvalidTrans;
300}
301
302XERCES_CPP_NAMESPACE_END
303
304#endif
Note: See TracBrowser for help on using the repository browser.