GME  13
DTDAttDef.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: DTDAttDef.cpp 679359 2008-07-24 11:15:19Z borisk $
00020  */
00021 
00022 
00023 // ---------------------------------------------------------------------------
00024 //  Includes
00025 // ---------------------------------------------------------------------------
00026 #include <xercesc/framework/XMLElementDecl.hpp>
00027 #include <xercesc/validators/DTD/DTDAttDef.hpp>
00028 
00029 XERCES_CPP_NAMESPACE_BEGIN
00030 
00031 // ---------------------------------------------------------------------------
00032 //  DTDAttDef: Constructors and Destructor
00033 // ---------------------------------------------------------------------------
00034 DTDAttDef::DTDAttDef(MemoryManager* const manager) :
00035 
00036     XMLAttDef(XMLAttDef::CData, XMLAttDef::Implied, manager)
00037    , fElemId(XMLElementDecl::fgInvalidElemId)
00038     , fName(0)
00039 {
00040 }
00041 
00042 DTDAttDef::DTDAttDef(const  XMLCh* const           attName
00043                     , const XMLAttDef::AttTypes    type
00044                     , const XMLAttDef::DefAttTypes defType
00045                     , MemoryManager* const         manager) :
00046     XMLAttDef(type, defType, manager)
00047     , fElemId(XMLElementDecl::fgInvalidElemId)
00048     , fName(0)
00049 {
00050     fName = XMLString::replicate(attName, getMemoryManager());
00051 }
00052 
00053 DTDAttDef::DTDAttDef( const   XMLCh* const         attName
00054                     , const XMLCh* const           attValue
00055                     , const XMLAttDef::AttTypes    type
00056                     , const XMLAttDef::DefAttTypes defType
00057                     , const XMLCh* const           enumValues
00058                     , MemoryManager* const         manager) :
00059 
00060     XMLAttDef(attValue, type, defType, enumValues, manager)
00061     , fElemId(XMLElementDecl::fgInvalidElemId)
00062     , fName(0)
00063 {
00064     fName = XMLString::replicate(attName, getMemoryManager());
00065 }
00066 
00067 DTDAttDef::~DTDAttDef()
00068 {
00069     getMemoryManager()->deallocate(fName); //delete [] fName;
00070 }
00071 
00072 
00073 // ---------------------------------------------------------------------------
00074 //  DTDAttDef: Setter methods
00075 // ---------------------------------------------------------------------------
00076 void DTDAttDef::setName(const XMLCh* const newName)
00077 {
00078     getMemoryManager()->deallocate(fName); //delete [] fName;
00079     fName = XMLString::replicate(newName, getMemoryManager());
00080 }
00081 
00082 /***
00083  * Support for Serialization/De-serialization
00084  ***/
00085 
00086 IMPL_XSERIALIZABLE_TOCREATE(DTDAttDef)
00087 
00088 void DTDAttDef::serialize(XSerializeEngine& serEng)
00089 {
00090 
00091     XMLAttDef::serialize(serEng);
00092 
00093     if (serEng.isStoring())
00094     {
00095         serEng.writeSize (fElemId);
00096         serEng.writeString(fName);
00097     }
00098     else
00099     {
00100         serEng.readSize (fElemId);
00101         serEng.readString(fName);
00102     }
00103 }
00104 
00105 
00106 XERCES_CPP_NAMESPACE_END