source: icXML/icXML-devel/src/xercesc/util/XMemory.hpp @ 2732

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

Original Xerces files with import mods for icxercesc

File size: 4.3 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: XMemory.hpp 932887 2010-04-11 13:04:59Z borisk $
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_XMEMORY_HPP)
23#define XERCESC_INCLUDE_GUARD_XMEMORY_HPP
24
25#include <xercesc/util/XercesDefs.hpp>
26#include <stdlib.h>
27
28XERCES_CPP_NAMESPACE_BEGIN
29
30class MemoryManager;
31
32/**
33 *  This class makes it possible to override the C++ memory management by
34 *  adding new/delete operators to this base class.
35 *
36 *  This class is used in conjunction with the pluggable memory manager. It
37 *  allows applications to control Xerces memory management.
38 */
39
40class XMLUTIL_EXPORT XMemory
41{
42public :
43    // -----------------------------------------------------------------------
44    //  The C++ memory management
45    // -----------------------------------------------------------------------
46    /** @name The C++ memory management */
47    //@{
48
49    /**
50      * This method overrides operator new
51      *
52      * @param size The requested memory size
53      */
54    void* operator new(size_t size);
55
56#if defined(XERCES_MFC_SUPPORT)
57    /**
58      * This method overrides the MFC debug version of the operator new
59      *
60      * @param size   The requested memory size
61      * @param file   The file where the allocation was requested
62      * @param line   The line where the allocation was requested
63      */ 
64    void* operator new(size_t size, const char* file, int line);
65    /**
66      * This method provides a matching delete for the MFC debug new
67      *
68      * @param p      The pointer to the allocated memory
69      * @param file   The file where the allocation was requested
70      * @param line   The line where the allocation was requested
71      */ 
72    void operator delete(void* p, const char* file, int line);
73#endif
74
75    /**
76      * This method defines a custom operator new, that will use the provided
77      * memory manager to perform the allocation
78      *
79      * @param size   The requested memory size
80      * @param memMgr An application's memory manager
81      */
82    void* operator new(size_t size, MemoryManager* memMgr);
83
84    /**
85      * This method overrides placement operator new
86      *
87      * @param size   The requested memory size
88      * @param ptr    The memory location where the object should be allocated
89      */
90    void* operator new(size_t size, void* ptr);
91
92    /**
93      * This method overrides operator delete
94      *
95      * @param p The pointer to the allocated memory
96      */
97    void operator delete(void* p);
98
99     //The Borland compiler is complaining about duplicate overloading of delete
100#if !defined(XERCES_NO_MATCHING_DELETE_OPERATOR)
101    /**
102      * This method provides a matching delete for the custom operator new
103      *
104      * @param p      The pointer to the allocated memory
105      * @param memMgr An application's memory manager
106      */
107    void operator delete(void* p, MemoryManager* memMgr);
108
109    /**
110      * This method provides a matching delete for the placement new
111      *
112      * @param p      The pointer to the allocated memory
113      * @param ptr    The memory location where the object had to be allocated
114      */
115    void operator delete(void* p, void* ptr);
116#endif
117
118    //@}
119
120protected :
121    // -----------------------------------------------------------------------
122    //  Hidden Constructors
123    // -----------------------------------------------------------------------
124    /** @name Constructor */
125    //@{
126
127    /**
128      * Protected default constructor
129      */
130    XMemory()
131    {
132    }
133    //@}
134
135#if defined(XERCES_NEED_XMEMORY_VIRTUAL_DESTRUCTOR)
136    virtual ~XMemory()
137    {
138    }
139#endif
140};
141
142XERCES_CPP_NAMESPACE_END
143
144#endif
Note: See TracBrowser for help on using the repository browser.