source: icXML/icXML-devel/src/xercesc/framework/XMLNotationDecl.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: 4.0 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: XMLNotationDecl.cpp 679359 2008-07-24 11:15:19Z borisk $
20 */
21
22
23// ---------------------------------------------------------------------------
24//  Includes
25// ---------------------------------------------------------------------------
26#include <xercesc/framework/XMLNotationDecl.hpp>
27#include <xercesc/util/OutOfMemoryException.hpp>
28
29XERCES_CPP_NAMESPACE_BEGIN
30
31// ---------------------------------------------------------------------------
32//  XMLNotationDecl: Constructors and operators
33// ---------------------------------------------------------------------------
34XMLNotationDecl::XMLNotationDecl(MemoryManager* const manager) :
35
36    fId(0)
37    , fNameSpaceId(0)
38    , fName(0)
39    , fPublicId(0)
40    , fSystemId(0)
41    , fBaseURI(0)
42    , fMemoryManager(manager)
43{
44}
45
46typedef JanitorMemFunCall<XMLNotationDecl>  CleanupType;
47
48XMLNotationDecl::XMLNotationDecl( const XMLCh* const   notName
49                                , const XMLCh* const   pubId
50                                , const XMLCh* const   sysId
51                                , const XMLCh* const   baseURI
52                                , MemoryManager* const manager) :
53    fId(0)
54    , fNameSpaceId(0)
55    , fName(0)
56    , fPublicId(0)
57    , fSystemId(0)
58    , fBaseURI(0)
59    , fMemoryManager(manager)
60{
61    CleanupType cleanup(this, &XMLNotationDecl::cleanUp);
62
63    try
64    {
65        fName = XMLString::replicate(notName, fMemoryManager);
66        fPublicId = XMLString::replicate(pubId, fMemoryManager);
67        fSystemId = XMLString::replicate(sysId, fMemoryManager);
68        fBaseURI  = XMLString::replicate(baseURI, fMemoryManager);
69    }
70    catch(const OutOfMemoryException&)
71    {
72        cleanup.release();
73
74        throw;
75    }
76
77    cleanup.release();
78}
79
80XMLNotationDecl::~XMLNotationDecl()
81{
82    cleanUp();
83}
84
85
86// -----------------------------------------------------------------------
87//  Setter methods
88// -----------------------------------------------------------------------
89void XMLNotationDecl::setName(const XMLCh* const notName)
90{
91    // Clean up the current name stuff and replicate the passed name
92    if (fName)
93        fMemoryManager->deallocate(fName);
94
95    fName = XMLString::replicate(notName, fMemoryManager);
96}
97
98
99
100// ---------------------------------------------------------------------------
101//  XMLNotationDecl: Private helper methods
102// ---------------------------------------------------------------------------
103void XMLNotationDecl::cleanUp()
104{
105    fMemoryManager->deallocate(fName);
106    fMemoryManager->deallocate(fPublicId);
107    fMemoryManager->deallocate(fSystemId);
108    fMemoryManager->deallocate(fBaseURI);
109}
110
111/***
112 * Support for Serialization/De-serialization
113 ***/
114
115IMPL_XSERIALIZABLE_TOCREATE(XMLNotationDecl)
116
117void XMLNotationDecl::serialize(XSerializeEngine& serEng)
118{
119    if (serEng.isStoring())
120    {
121        serEng.writeSize (fId);
122        serEng<<fNameSpaceId;
123        serEng.writeString(fName);
124        serEng.writeString(fPublicId);
125        serEng.writeString(fSystemId);
126        serEng.writeString(fBaseURI);
127    }
128    else
129    {
130        serEng.readSize (fId);
131        serEng>>fNameSpaceId;
132        serEng.readString(fName);
133        serEng.readString(fPublicId);
134        serEng.readString(fSystemId);
135        serEng.readString(fBaseURI);
136    }
137}
138
139
140XERCES_CPP_NAMESPACE_END
Note: See TracBrowser for help on using the repository browser.