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

Revision 2674, 6.4 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: SimpleContentModel.hpp 568078 2007-08-21 11:43:25Z amassari $
20 */
21
22
23#if !defined(SIMPLECONTENTMODEL_HPP)
24#define SIMPLECONTENTMODEL_HPP
25
26#include <xercesc/framework/XMLContentModel.hpp>
27#include <xercesc/validators/common/ContentSpecNode.hpp>
28
29XERCES_CPP_NAMESPACE_BEGIN
30
31//
32//  SimpleContentModel is a derivative of the abstract content model base
33//  class that handles a small set of simple content models that are just
34//  way overkill to give the DFA treatment.
35//
36//  DESCRIPTION:
37//
38//  This guy handles the following scenarios:
39//
40//      a
41//      a?
42//      a*
43//      a+
44//      a,b
45//      a|b
46//
47//  These all involve a unary operation with one element type, or a binary
48//  operation with two elements. These are very simple and can be checked
49//  in a simple way without a DFA and without the overhead of setting up a
50//  DFA for such a simple check.
51//
52//  NOTE:   Pass the XMLElementDecl::fgPCDataElemId value to represent a
53//          PCData node. Pass XMLElementDecl::fgInvalidElemId for unused element
54//
55class SimpleContentModel : public XMLContentModel
56{
57public :
58    // -----------------------------------------------------------------------
59    //  Constructors and Destructor
60    // -----------------------------------------------------------------------
61    SimpleContentModel
62    (
63        const bool                        dtd
64      , QName* const                      firstChild
65      , QName* const                      secondChild
66      , const ContentSpecNode::NodeTypes  cmOp
67      , MemoryManager* const              manager = XMLPlatformUtils::fgMemoryManager
68    );
69
70    ~SimpleContentModel();
71
72
73    // -----------------------------------------------------------------------
74    //  Implementation of the ContentModel virtual interface
75    // -----------------------------------------------------------------------
76        virtual int validateContent
77    (
78        QName** const         children
79      , const unsigned int    childCount
80      , const unsigned int    emptyNamespaceId
81    ) const;
82
83        virtual int validateContentSpecial
84    (
85        QName** const           children
86      , const unsigned int      childCount
87      , const unsigned int      emptyNamespaceId
88      , GrammarResolver*  const pGrammarResolver
89      , XMLStringPool*    const pStringPool
90    ) const;
91
92    virtual ContentLeafNameTypeVector *getContentLeafNameTypeVector() const;
93
94    virtual unsigned int getNextState(const unsigned int currentState,
95                                      const unsigned int elementIndex) const;
96
97    virtual void checkUniqueParticleAttribution
98    (
99        SchemaGrammar*    const pGrammar
100      , GrammarResolver*  const pGrammarResolver
101      , XMLStringPool*    const pStringPool
102      , XMLValidator*     const pValidator
103      , unsigned int*     const pContentSpecOrgURI
104      , const XMLCh*            pComplexTypeName = 0
105    ) ;
106
107 private :
108    // -----------------------------------------------------------------------
109    //  Unimplemented constructors and operators
110    // -----------------------------------------------------------------------
111    SimpleContentModel();
112    SimpleContentModel(const SimpleContentModel&);
113    SimpleContentModel& operator=(const SimpleContentModel&);
114
115
116    // -----------------------------------------------------------------------
117    //  Private data members
118    //
119    //  fFirstChild
120    //  fSecondChild
121    //      The first (and optional second) child node. The
122    //      operation code tells us whether the second child is used or not.
123    //
124    //  fOp
125    //      The operation that this object represents. Since this class only
126    //      does simple contents, there is only ever a single operation
127    //      involved (i.e. the children of the operation are always one or
128    //      two leafs.)
129    //
130    //  fDTD
131    //      Boolean to allow DTDs to validate even with namespace support. */
132    //
133    // -----------------------------------------------------------------------
134    QName*                     fFirstChild;
135    QName*                     fSecondChild;
136    ContentSpecNode::NodeTypes fOp;
137    bool                       fDTD;
138    MemoryManager* const       fMemoryManager;
139};
140
141
142// ---------------------------------------------------------------------------
143//  SimpleContentModel: Constructors and Destructor
144// ---------------------------------------------------------------------------
145inline SimpleContentModel::SimpleContentModel
146(
147      const bool                       dtd
148    , QName* const                     firstChild
149    , QName* const                     secondChild
150    , const ContentSpecNode::NodeTypes cmOp
151     , MemoryManager* const            manager
152)
153    : fFirstChild(0)
154    , fSecondChild(0)
155    , fOp(cmOp)
156        , fDTD(dtd)
157    , fMemoryManager(manager)
158{
159    if (firstChild)
160        fFirstChild = new (manager) QName(*firstChild);
161    else
162        fFirstChild = new (manager) QName(XMLUni::fgZeroLenString, XMLUni::fgZeroLenString, XMLElementDecl::fgInvalidElemId, manager);
163
164    if (secondChild)
165        fSecondChild = new (manager) QName(*secondChild);
166    else
167        fSecondChild = new (manager) QName(XMLUni::fgZeroLenString, XMLUni::fgZeroLenString, XMLElementDecl::fgInvalidElemId, manager);
168}
169
170inline SimpleContentModel::~SimpleContentModel()
171{
172    delete fFirstChild;
173    delete fSecondChild;
174}
175
176
177// ---------------------------------------------------------------------------
178//  SimpleContentModel: Virtual methods
179// ---------------------------------------------------------------------------
180inline unsigned int
181SimpleContentModel::getNextState(const unsigned int,
182                                 const unsigned int) const {
183
184    return XMLContentModel::gInvalidTrans;
185}
186
187XERCES_CPP_NAMESPACE_END
188
189#endif
Note: See TracBrowser for help on using the repository browser.