source: icXML/icXML-devel/src/xercesc/dom/DOMException.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: 2.5 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: DOMException.cpp 671894 2008-06-26 13:29:21Z borisk $
20 */
21
22#include <xercesc/dom/DOMImplementation.hpp>
23#include <xercesc/framework/MemoryManager.hpp>
24#include <icxercesc/util/XMLString.hpp>
25#include <xercesc/util/XMLMsgLoader.hpp>
26#include <xercesc/util/XMLDOMMsg.hpp>
27#include "impl/DOMImplementationImpl.hpp"
28
29#include "DOMException.hpp"
30
31XERCES_CPP_NAMESPACE_BEGIN
32
33// ---------------------------------------------------------------------------
34//  Destructor and Constructor
35// ---------------------------------------------------------------------------
36DOMException::~DOMException()
37{
38    if (msg && fMsgOwned)
39        fMemoryManager->deallocate((void*)msg);
40}
41
42DOMException::DOMException()
43:code(0)
44,msg(0)
45,fMemoryManager(0)
46,fMsgOwned(false)
47{
48}
49
50DOMException::DOMException(short exCode,
51                           short messageCode,
52                           MemoryManager* const  memoryManager)
53:code(exCode)
54,fMemoryManager(0)
55,fMsgOwned(true)
56{
57    if (memoryManager)
58      fMemoryManager = memoryManager->getExceptionMemoryManager();
59
60    const XMLSize_t msgSize = 2047;
61    XMLCh errText[msgSize + 1];
62
63    // load the text
64    if(messageCode==0)
65        messageCode=XMLDOMMsg::DOMEXCEPTION_ERRX+exCode;
66
67    msg = XMLString::replicate
68         (
69          DOMImplementationImpl::getMsgLoader4DOM()->loadMsg(messageCode, errText, msgSize) ? errText : XMLUni::fgDefErrMsg
70        , fMemoryManager
71         );
72}
73
74DOMException::DOMException(const DOMException &other)
75:code(other.code)
76,msg(0)
77,fMemoryManager(other.fMemoryManager)
78,fMsgOwned(other.fMsgOwned)
79{
80    if (other.msg)
81      msg = other.fMsgOwned? XMLString::replicate(other.msg, other.fMemoryManager) : other.msg;
82}
83
84XERCES_CPP_NAMESPACE_END
Note: See TracBrowser for help on using the repository browser.