GME  13
CMUnaryOp.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: CMUnaryOp.cpp 677396 2008-07-16 19:36:20Z amassari $
00020  */
00021 
00022 
00023 // ---------------------------------------------------------------------------
00024 //  Includes
00025 // ---------------------------------------------------------------------------
00026 #include <xercesc/util/RuntimeException.hpp>
00027 #include <xercesc/validators/common/CMStateSet.hpp>
00028 #include <xercesc/validators/common/CMUnaryOp.hpp>
00029 
00030 XERCES_CPP_NAMESPACE_BEGIN
00031 
00032 // ---------------------------------------------------------------------------
00033 //  CMUnaryOp: Constructors and Destructor
00034 // ---------------------------------------------------------------------------
00035 CMUnaryOp::CMUnaryOp( ContentSpecNode::NodeTypes type
00036                     , CMNode* const              nodeToAdopt
00037                     , unsigned int               maxStates
00038                     , MemoryManager* const       manager) :
00039     CMNode(type, maxStates, manager)
00040     , fChild(nodeToAdopt)
00041 {
00042     // Insure that its one of the types we require
00043     if ((type != ContentSpecNode::ZeroOrOne)
00044     &&  (type != ContentSpecNode::ZeroOrMore)
00045     &&  (type != ContentSpecNode::OneOrMore))
00046     {
00047         ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::CM_UnaryOpHadBinType, manager);
00048     }
00049     if (type == ContentSpecNode::OneOrMore)
00050         fIsNullable=fChild->isNullable();
00051     else
00052         fIsNullable=true;
00053 }
00054 
00055 CMUnaryOp::~CMUnaryOp()
00056 {
00057     delete fChild;
00058 }
00059 
00060 
00061 // ---------------------------------------------------------------------------
00062 //  CMUnaryOp: Getter methods
00063 // ---------------------------------------------------------------------------
00064 const CMNode* CMUnaryOp::getChild() const
00065 {
00066     return fChild;
00067 }
00068 
00069 CMNode* CMUnaryOp::getChild()
00070 {
00071     return fChild;
00072 }
00073 
00074 
00075 // ---------------------------------------------------------------------------
00076 //  CMUnaryOp: Implementation of the public CMNode virtual interface
00077 // ---------------------------------------------------------------------------
00078 void CMUnaryOp::orphanChild()
00079 {
00080     delete fChild;
00081     fChild=0;
00082 }
00083 
00084 // ---------------------------------------------------------------------------
00085 //  CMUnaryOp: Implementation of the protected CMNode virtual interface
00086 // ---------------------------------------------------------------------------
00087 void CMUnaryOp::calcFirstPos(CMStateSet& toSet) const
00088 {
00089     // Its just based on our child node's first pos
00090     toSet = fChild->getFirstPos();
00091 }
00092 
00093 void CMUnaryOp::calcLastPos(CMStateSet& toSet) const
00094 {
00095     // Its just based on our child node's last pos
00096     toSet = fChild->getLastPos();
00097 }
00098 
00099 XERCES_CPP_NAMESPACE_END