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: DOMException.cpp 671894 2008-06-26 13:29:21Z borisk $ 00020 */ 00021 00022 #include <xercesc/dom/DOMImplementation.hpp> 00023 #include <xercesc/framework/MemoryManager.hpp> 00024 #include <xercesc/util/XMLString.hpp> 00025 #include <xercesc/util/XMLMsgLoader.hpp> 00026 #include <xercesc/util/XMLDOMMsg.hpp> 00027 #include "impl/DOMImplementationImpl.hpp" 00028 00029 #include "DOMException.hpp" 00030 00031 XERCES_CPP_NAMESPACE_BEGIN 00032 00033 // --------------------------------------------------------------------------- 00034 // Destructor and Constructor 00035 // --------------------------------------------------------------------------- 00036 DOMException::~DOMException() 00037 { 00038 if (msg && fMsgOwned) 00039 fMemoryManager->deallocate((void*)msg); 00040 } 00041 00042 DOMException::DOMException() 00043 :code(0) 00044 ,msg(0) 00045 ,fMemoryManager(0) 00046 ,fMsgOwned(false) 00047 { 00048 } 00049 00050 DOMException::DOMException(short exCode, 00051 short messageCode, 00052 MemoryManager* const memoryManager) 00053 :code(exCode) 00054 ,fMemoryManager(0) 00055 ,fMsgOwned(true) 00056 { 00057 if (memoryManager) 00058 fMemoryManager = memoryManager->getExceptionMemoryManager(); 00059 00060 const XMLSize_t msgSize = 2047; 00061 XMLCh errText[msgSize + 1]; 00062 00063 // load the text 00064 if(messageCode==0) 00065 messageCode=XMLDOMMsg::DOMEXCEPTION_ERRX+exCode; 00066 00067 msg = XMLString::replicate 00068 ( 00069 DOMImplementationImpl::getMsgLoader4DOM()->loadMsg(messageCode, errText, msgSize) ? errText : XMLUni::fgDefErrMsg 00070 , fMemoryManager 00071 ); 00072 } 00073 00074 DOMException::DOMException(const DOMException &other) 00075 :code(other.code) 00076 ,msg(0) 00077 ,fMemoryManager(other.fMemoryManager) 00078 ,fMsgOwned(other.fMsgOwned) 00079 { 00080 if (other.msg) 00081 msg = other.fMsgOwned? XMLString::replicate(other.msg, other.fMemoryManager) : other.msg; 00082 } 00083 00084 XERCES_CPP_NAMESPACE_END