source: NonGTP/Xerces/xerces/include/xercesc/util/XMemory.hpp @ 358

Revision 358, 3.9 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
1/*
2 * Copyright 2003,2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 * $Id: XMemory.hpp,v 1.7 2004/09/08 13:56:25 peiyongz Exp $
19 */
20
21
22#if !defined(XMEMORY_HPP)
23#define 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 conjuction 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(XML_VISUALCPP)
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 overrides placement operator new
77      *
78      * @param size   The requested memory size
79      * @param memMgr An application's memory manager
80      */
81    void* operator new(size_t size, MemoryManager* memMgr);
82
83    /**
84      * This method overrides operator delete
85      *
86      * @param p The pointer to the allocated memory
87      */
88    void operator delete(void* p);
89
90     //The Borland compiler is complaining about duplicate overloading of delete
91#if !defined(XML_BORLAND)
92    /**
93      * This method provides a matching delete for the placement new
94      *
95      * @param p      The pointer to the allocated memory
96      * @param memMgr An application's memory manager
97      */
98    void operator delete(void* p, MemoryManager* memMgr);
99#endif
100
101    //@}
102
103protected :
104    // -----------------------------------------------------------------------
105    //  Hidden Constructors
106    // -----------------------------------------------------------------------
107    /** @name Constructor */
108    //@{
109
110    /**
111      * Protected default constructor and copy constructor
112      */
113    XMemory()
114    {
115    }
116
117    XMemory(const XMemory&)
118    {
119    }
120    //@}
121
122#if defined(XML_BORLAND)
123    virtual ~XMemory()
124    {
125    }
126#endif
127
128private:
129    // -----------------------------------------------------------------------
130    //  Unimplemented operators
131    // -----------------------------------------------------------------------
132    XMemory& operator=(const XMemory&);
133};
134
135XERCES_CPP_NAMESPACE_END
136
137#endif
Note: See TracBrowser for help on using the repository browser.