GME  13
CMAny.cpp
Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  * 
00009  *      http://www.apache.org/licenses/LICENSE-2.0
00010  * 
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 /*
00019  * $Id: CMAny.cpp 677396 2008-07-16 19:36:20Z amassari $
00020  */
00021 
00022 // ---------------------------------------------------------------------------
00023 //  Includes
00024 // ---------------------------------------------------------------------------
00025 #include <xercesc/util/XercesDefs.hpp>
00026 #include <xercesc/util/RuntimeException.hpp>
00027 #include <xercesc/validators/common/CMStateSet.hpp>
00028 #include <xercesc/validators/common/CMAny.hpp>
00029 
00030 XERCES_CPP_NAMESPACE_BEGIN
00031 
00032 // ---------------------------------------------------------------------------
00033 //  CMUnaryOp: Constructors and Destructor
00034 // ---------------------------------------------------------------------------
00035 CMAny::CMAny( ContentSpecNode::NodeTypes type
00036             , unsigned int               URI
00037             , unsigned int               position
00038             , unsigned int               maxStates
00039             ,       MemoryManager* const manager) :
00040        CMNode(type, maxStates, manager)
00041      , fURI(URI)
00042      , fPosition(position)
00043 {
00044     if ((type & 0x0f) != ContentSpecNode::Any
00045     &&  (type & 0x0f) != ContentSpecNode::Any_Other
00046     &&  (type & 0x0f) != ContentSpecNode::Any_NS)
00047     {
00048         ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::CM_NotValidSpecTypeForNode,
00049                             "CMAny", manager);
00050     }
00051     // Leaf nodes are never nullable unless its an epsilon node
00052     fIsNullable=(fPosition == epsilonNode);
00053 }
00054 
00055 CMAny::~CMAny()
00056 {
00057 }
00058 
00059 // ---------------------------------------------------------------------------
00060 //  Getter methods
00061 // ---------------------------------------------------------------------------
00062 unsigned int CMAny::getURI() const
00063 {
00064     return fURI;
00065 }
00066 
00067 unsigned int CMAny::getPosition() const
00068 {
00069     return fPosition;
00070 }
00071 
00072 // ---------------------------------------------------------------------------
00073 //  Setter methods
00074 // ---------------------------------------------------------------------------
00075 void CMAny::setPosition(const unsigned int newPosition)
00076 {
00077     fPosition = newPosition;
00078 }
00079 
00080 // ---------------------------------------------------------------------------
00081 //  Implementation of public CMNode virtual interface
00082 // ---------------------------------------------------------------------------
00083 void CMAny::orphanChild()
00084 {
00085 }
00086 
00087 // ---------------------------------------------------------------------------
00088 //  Implementation of protected CMNode virtual interface
00089 // ---------------------------------------------------------------------------
00090 void CMAny::calcFirstPos(CMStateSet& toSet) const
00091 {
00092     // If we are an epsilon node, then the first pos is an empty set
00093     if (isNullable())
00094         toSet.zeroBits();
00095     else
00096     // Otherwise, its just the one bit of our position
00097         toSet.setBit(fPosition);
00098 }
00099 
00100 void CMAny::calcLastPos(CMStateSet& toSet) const
00101 {
00102     // If we are an epsilon node, then the last pos is an empty set
00103     if (isNullable())
00104         toSet.zeroBits();
00105     // Otherwise, its just the one bit of our position
00106     else
00107         toSet.setBit(fPosition);
00108 }
00109 
00110 XERCES_CPP_NAMESPACE_END