GME
13
|
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: XMLDTDDescriptionImpl.cpp 471747 2006-11-06 14:31:56Z amassari $ 00020 */ 00021 00022 00023 // --------------------------------------------------------------------------- 00024 // Includes 00025 // --------------------------------------------------------------------------- 00026 #include <xercesc/validators/DTD/XMLDTDDescriptionImpl.hpp> 00027 00028 XERCES_CPP_NAMESPACE_BEGIN 00029 00030 // --------------------------------------------------------------------------- 00031 // XMLDTDDescriptionImpl: constructor and destructor 00032 // --------------------------------------------------------------------------- 00033 XMLDTDDescriptionImpl::XMLDTDDescriptionImpl(const XMLCh* const systemId 00034 , MemoryManager* const memMgr ) 00035 :XMLDTDDescription(memMgr) 00036 ,fSystemId(0) 00037 ,fRootName(0) 00038 { 00039 if (systemId) 00040 fSystemId = XMLString::replicate(systemId, memMgr); 00041 } 00042 00043 XMLDTDDescriptionImpl::~XMLDTDDescriptionImpl() 00044 { 00045 if (fSystemId) 00046 XMLGrammarDescription::getMemoryManager()->deallocate((void*)fSystemId); 00047 00048 if (fRootName) 00049 XMLGrammarDescription::getMemoryManager()->deallocate((void*)fRootName); 00050 } 00051 00052 const XMLCh* XMLDTDDescriptionImpl::getGrammarKey() const 00053 { 00054 return getSystemId(); 00055 } 00056 00057 const XMLCh* XMLDTDDescriptionImpl::getRootName() const 00058 { 00059 return fRootName; 00060 } 00061 00062 const XMLCh* XMLDTDDescriptionImpl::getSystemId() const 00063 { 00064 return fSystemId; 00065 } 00066 00067 void XMLDTDDescriptionImpl::setRootName(const XMLCh* const rootName) 00068 { 00069 if (fRootName) 00070 { 00071 XMLGrammarDescription::getMemoryManager()->deallocate((void*)fRootName); 00072 fRootName = 0; 00073 } 00074 00075 if (rootName) 00076 fRootName = XMLString::replicate(rootName, XMLGrammarDescription::getMemoryManager()); 00077 } 00078 00079 void XMLDTDDescriptionImpl::setSystemId(const XMLCh* const systemId) 00080 { 00081 if (fSystemId) 00082 { 00083 XMLGrammarDescription::getMemoryManager()->deallocate((void*)fSystemId); 00084 fSystemId = 0; 00085 } 00086 00087 if (systemId) 00088 fSystemId = XMLString::replicate(systemId, XMLGrammarDescription::getMemoryManager()); 00089 } 00090 00091 /*** 00092 * Support for Serialization/De-serialization 00093 ***/ 00094 00095 IMPL_XSERIALIZABLE_TOCREATE(XMLDTDDescriptionImpl) 00096 00097 void XMLDTDDescriptionImpl::serialize(XSerializeEngine& serEng) 00098 { 00099 XMLDTDDescription::serialize(serEng); 00100 00101 if (serEng.isStoring()) 00102 { 00103 serEng.writeString(fSystemId); 00104 serEng.writeString(fRootName); 00105 } 00106 else 00107 { 00108 if (fSystemId) 00109 { 00110 XMLGrammarDescription::getMemoryManager()->deallocate((void*)fSystemId); 00111 } 00112 00113 serEng.readString((XMLCh*&)fSystemId); 00114 00115 //the original root name which came from the ctor needs deallocated 00116 if (fRootName) 00117 { 00118 XMLGrammarDescription::getMemoryManager()->deallocate((void*)fRootName); 00119 } 00120 00121 serEng.readString((XMLCh*&)fRootName); 00122 } 00123 00124 } 00125 00126 XMLDTDDescriptionImpl::XMLDTDDescriptionImpl(MemoryManager* const memMgr) 00127 :XMLDTDDescription(memMgr) 00128 ,fSystemId(0) 00129 ,fRootName(0) 00130 { 00131 } 00132 00133 XERCES_CPP_NAMESPACE_END