/src/xerces-c/src/xercesc/validators/common/CMAny.cpp
Line | Count | Source |
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: CMAny.cpp 677396 2008-07-16 19:36:20Z amassari $ |
20 | | */ |
21 | | |
22 | | // --------------------------------------------------------------------------- |
23 | | // Includes |
24 | | // --------------------------------------------------------------------------- |
25 | | #include <xercesc/util/XercesDefs.hpp> |
26 | | #include <xercesc/util/RuntimeException.hpp> |
27 | | #include <xercesc/validators/common/CMStateSet.hpp> |
28 | | #include <xercesc/validators/common/CMAny.hpp> |
29 | | |
30 | | XERCES_CPP_NAMESPACE_BEGIN |
31 | | |
32 | | // --------------------------------------------------------------------------- |
33 | | // CMUnaryOp: Constructors and Destructor |
34 | | // --------------------------------------------------------------------------- |
35 | | CMAny::CMAny( ContentSpecNode::NodeTypes type |
36 | | , unsigned int URI |
37 | | , unsigned int position |
38 | | , unsigned int maxStates |
39 | | , MemoryManager* const manager) : |
40 | 0 | CMNode(type, maxStates, manager) |
41 | 0 | , fURI(URI) |
42 | 0 | , fPosition(position) |
43 | 0 | { |
44 | 0 | if ((type & 0x0f) != ContentSpecNode::Any |
45 | 0 | && (type & 0x0f) != ContentSpecNode::Any_Other |
46 | 0 | && (type & 0x0f) != ContentSpecNode::Any_NS) |
47 | 0 | { |
48 | 0 | ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::CM_NotValidSpecTypeForNode, |
49 | 0 | "CMAny", manager); |
50 | 0 | } |
51 | | // Leaf nodes are never nullable unless its an epsilon node |
52 | 0 | fIsNullable=(fPosition == epsilonNode); |
53 | 0 | } |
54 | | |
55 | | CMAny::~CMAny() |
56 | 0 | { |
57 | 0 | } |
58 | | |
59 | | // --------------------------------------------------------------------------- |
60 | | // Getter methods |
61 | | // --------------------------------------------------------------------------- |
62 | | unsigned int CMAny::getURI() const |
63 | 0 | { |
64 | 0 | return fURI; |
65 | 0 | } |
66 | | |
67 | | unsigned int CMAny::getPosition() const |
68 | 0 | { |
69 | 0 | return fPosition; |
70 | 0 | } |
71 | | |
72 | | // --------------------------------------------------------------------------- |
73 | | // Setter methods |
74 | | // --------------------------------------------------------------------------- |
75 | | void CMAny::setPosition(const unsigned int newPosition) |
76 | 0 | { |
77 | 0 | fPosition = newPosition; |
78 | 0 | } |
79 | | |
80 | | // --------------------------------------------------------------------------- |
81 | | // Implementation of public CMNode virtual interface |
82 | | // --------------------------------------------------------------------------- |
83 | | void CMAny::orphanChild() |
84 | 0 | { |
85 | 0 | } |
86 | | |
87 | | // --------------------------------------------------------------------------- |
88 | | // Implementation of protected CMNode virtual interface |
89 | | // --------------------------------------------------------------------------- |
90 | | void CMAny::calcFirstPos(CMStateSet& toSet) const |
91 | 0 | { |
92 | | // If we are an epsilon node, then the first pos is an empty set |
93 | 0 | if (isNullable()) |
94 | 0 | toSet.zeroBits(); |
95 | 0 | else |
96 | | // Otherwise, its just the one bit of our position |
97 | 0 | toSet.setBit(fPosition); |
98 | 0 | } |
99 | | |
100 | | void CMAny::calcLastPos(CMStateSet& toSet) const |
101 | 0 | { |
102 | | // If we are an epsilon node, then the last pos is an empty set |
103 | 0 | if (isNullable()) |
104 | 0 | toSet.zeroBits(); |
105 | | // Otherwise, its just the one bit of our position |
106 | 0 | else |
107 | 0 | toSet.setBit(fPosition); |
108 | 0 | } |
109 | | |
110 | | XERCES_CPP_NAMESPACE_END |