GME  13
XMLNotationDecl.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 
00023 // ---------------------------------------------------------------------------
00024 //  Includes
00025 // ---------------------------------------------------------------------------
00026 #include <xercesc/framework/XMLNotationDecl.hpp>
00027 #include <xercesc/util/OutOfMemoryException.hpp>
00028 
00029 XERCES_CPP_NAMESPACE_BEGIN
00030 
00031 // ---------------------------------------------------------------------------
00032 //  XMLNotationDecl: Constructors and operators
00033 // ---------------------------------------------------------------------------
00034 XMLNotationDecl::XMLNotationDecl(MemoryManager* const manager) :
00035 
00036     fId(0)
00037     , fNameSpaceId(0)
00038     , fName(0)
00039     , fPublicId(0)
00040     , fSystemId(0)
00041     , fBaseURI(0)
00042     , fMemoryManager(manager)
00043 {
00044 }
00045 
00046 typedef JanitorMemFunCall<XMLNotationDecl>  CleanupType;
00047 
00048 XMLNotationDecl::XMLNotationDecl( const XMLCh* const   notName
00049                                 , const XMLCh* const   pubId
00050                                 , const XMLCh* const   sysId
00051                                 , const XMLCh* const   baseURI
00052                                 , MemoryManager* const manager) :
00053     fId(0)
00054     , fNameSpaceId(0)
00055     , fName(0)
00056     , fPublicId(0)
00057     , fSystemId(0)
00058     , fBaseURI(0)
00059     , fMemoryManager(manager)
00060 {
00061     CleanupType cleanup(this, &XMLNotationDecl::cleanUp);
00062 
00063     try
00064     {
00065         fName = XMLString::replicate(notName, fMemoryManager);
00066         fPublicId = XMLString::replicate(pubId, fMemoryManager);
00067         fSystemId = XMLString::replicate(sysId, fMemoryManager);
00068         fBaseURI  = XMLString::replicate(baseURI, fMemoryManager);
00069     }
00070     catch(const OutOfMemoryException&)
00071     {
00072         cleanup.release();
00073 
00074         throw;
00075     }
00076 
00077     cleanup.release();
00078 }
00079 
00080 XMLNotationDecl::~XMLNotationDecl()
00081 {
00082     cleanUp();
00083 }
00084 
00085 
00086 // -----------------------------------------------------------------------
00087 //  Setter methods
00088 // -----------------------------------------------------------------------
00089 void XMLNotationDecl::setName(const XMLCh* const notName)
00090 {
00091     // Clean up the current name stuff and replicate the passed name
00092     if (fName)
00093         fMemoryManager->deallocate(fName);
00094 
00095     fName = XMLString::replicate(notName, fMemoryManager);
00096 }
00097 
00098 
00099 
00100 // ---------------------------------------------------------------------------
00101 //  XMLNotationDecl: Private helper methods
00102 // ---------------------------------------------------------------------------
00103 void XMLNotationDecl::cleanUp()
00104 {
00105     fMemoryManager->deallocate(fName);
00106     fMemoryManager->deallocate(fPublicId);
00107     fMemoryManager->deallocate(fSystemId);
00108     fMemoryManager->deallocate(fBaseURI);
00109 }
00110 
00111 /***
00112  * Support for Serialization/De-serialization
00113  ***/
00114 
00115 IMPL_XSERIALIZABLE_TOCREATE(XMLNotationDecl)
00116 
00117 void XMLNotationDecl::serialize(XSerializeEngine& serEng)
00118 {
00119     if (serEng.isStoring())
00120     {
00121         serEng.writeSize (fId);
00122         serEng<<fNameSpaceId;
00123         serEng.writeString(fName);
00124         serEng.writeString(fPublicId);
00125         serEng.writeString(fSystemId);
00126         serEng.writeString(fBaseURI);
00127     }
00128     else
00129     {
00130         serEng.readSize (fId);
00131         serEng>>fNameSpaceId;
00132         serEng.readString(fName);
00133         serEng.readString(fPublicId);
00134         serEng.readString(fSystemId);
00135         serEng.readString(fBaseURI);
00136     }
00137 }
00138 
00139 
00140 XERCES_CPP_NAMESPACE_END