source: icXML/icXML-devel/src/xercesc/validators/DTD/XMLDTDDescriptionImpl.cpp @ 2722

Last change on this file since 2722 was 2722, checked in by cameron, 6 years ago

Original Xerces files with import mods for icxercesc

File size: 3.7 KB
Line 
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: XMLDTDDescriptionImpl.cpp 471747 2006-11-06 14:31:56Z amassari $
20 */
21
22
23// ---------------------------------------------------------------------------
24//  Includes
25// ---------------------------------------------------------------------------
26#include <xercesc/validators/DTD/XMLDTDDescriptionImpl.hpp>
27
28XERCES_CPP_NAMESPACE_BEGIN
29
30// ---------------------------------------------------------------------------
31//  XMLDTDDescriptionImpl: constructor and destructor
32// ---------------------------------------------------------------------------
33XMLDTDDescriptionImpl::XMLDTDDescriptionImpl(const XMLCh*          const  systemId
34                                           ,       MemoryManager*  const  memMgr  )
35:XMLDTDDescription(memMgr)
36,fSystemId(0)
37,fRootName(0)
38{
39    if (systemId)
40        fSystemId = XMLString::replicate(systemId, memMgr);
41}
42
43XMLDTDDescriptionImpl::~XMLDTDDescriptionImpl()
44{
45    if (fSystemId)
46        XMLGrammarDescription::getMemoryManager()->deallocate((void*)fSystemId);
47
48    if (fRootName)
49        XMLGrammarDescription::getMemoryManager()->deallocate((void*)fRootName);
50}
51             
52const XMLCh* XMLDTDDescriptionImpl::getGrammarKey() const
53{
54    return getSystemId();
55}
56             
57const XMLCh* XMLDTDDescriptionImpl::getRootName() const
58{ 
59    return fRootName; 
60}
61
62const XMLCh* XMLDTDDescriptionImpl::getSystemId() const
63{ 
64    return fSystemId; 
65}
66
67void XMLDTDDescriptionImpl::setRootName(const XMLCh* const rootName)
68{
69    if (fRootName)
70    {
71        XMLGrammarDescription::getMemoryManager()->deallocate((void*)fRootName);
72        fRootName = 0;
73    }
74
75    if (rootName)
76        fRootName = XMLString::replicate(rootName, XMLGrammarDescription::getMemoryManager()); 
77}       
78
79void XMLDTDDescriptionImpl::setSystemId(const XMLCh* const systemId)
80{
81    if (fSystemId)
82    {
83        XMLGrammarDescription::getMemoryManager()->deallocate((void*)fSystemId);
84        fSystemId = 0;
85    }
86
87    if (systemId)
88        fSystemId = XMLString::replicate(systemId, XMLGrammarDescription::getMemoryManager()); 
89}       
90
91/***
92 * Support for Serialization/De-serialization
93 ***/
94
95IMPL_XSERIALIZABLE_TOCREATE(XMLDTDDescriptionImpl)
96
97void XMLDTDDescriptionImpl::serialize(XSerializeEngine& serEng)
98{
99    XMLDTDDescription::serialize(serEng);
100
101    if (serEng.isStoring())
102    {
103        serEng.writeString(fSystemId);
104        serEng.writeString(fRootName);
105    }
106    else
107    {
108        if (fSystemId)
109        {
110            XMLGrammarDescription::getMemoryManager()->deallocate((void*)fSystemId);
111        }
112
113        serEng.readString((XMLCh*&)fSystemId);
114
115        //the original root name which came from the ctor needs deallocated
116        if (fRootName)
117        {
118            XMLGrammarDescription::getMemoryManager()->deallocate((void*)fRootName);
119        }
120
121        serEng.readString((XMLCh*&)fRootName);
122    }
123
124}
125
126XMLDTDDescriptionImpl::XMLDTDDescriptionImpl(MemoryManager* const memMgr)
127:XMLDTDDescription(memMgr)
128,fSystemId(0)
129,fRootName(0)
130{
131}
132
133XERCES_CPP_NAMESPACE_END
Note: See TracBrowser for help on using the repository browser.