3 #ifndef INCLUDE_NN_NLIB_EXI_EXIALLOCATOR_H_
4 #define INCLUDE_NN_NLIB_EXI_EXIALLOCATOR_H_
10 #include "nn/nlib/Swap.h"
12 #if defined(_MSC_VER) && defined(nx_exi_EXPORTS)
13 #undef NLIB_VIS_PUBLIC
14 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT
20 struct ExiAllocatorInfo;
34 swap(rhs.m_Ptr, m_Ptr);
38 void* Finalize() NLIB_NOEXCEPT;
39 void* Alloc(
size_t nbytes) NLIB_NOEXCEPT;
40 void* Realloc(
void* ptr,
size_t from_nbytes,
size_t nbytes) NLIB_NOEXCEPT;
41 void Dealloc(
void* p) NLIB_NOEXCEPT;
42 void Reset() NLIB_NOEXCEPT;
43 bool Test(
size_t nbytes) NLIB_NOEXCEPT;
44 size_t GetPos() NLIB_NOEXCEPT;
45 bool IsOutOfMemory() NLIB_NOEXCEPT;
47 bool IsValid() const NLIB_NOEXCEPT {
return m_Ptr != NULL; }
51 explicit
ExiAllocatorEx(ExiAllocatorInfo* p) NLIB_NOEXCEPT : m_Ptr(p) {}
52 ExiAllocatorInfo* m_Ptr;
53 friend class ExiAllocator;
61 static void* Realloc(
void* ptr,
size_t from_nbytes,
size_t nbytes)
NLIB_NOEXCEPT;
80 if (m_Al) ExiAllocator::Swap(rhs);
82 ~ExiAllocatorSwapper() NLIB_NOEXCEPT {
83 if (m_Swapped) ExiAllocator::Swap(m_Al);
92 #ifdef NN_PLATFORM_CTR
94 #define NEXI_DEF_NEW_DELETE(typeName) \
95 static void* operator new(size_t size) throw() { \
96 NLIB_ASSERT(size == sizeof(typeName)); \
97 return ExiAllocator::Alloc(size); \
99 static void* operator new(size_t size, const std::nothrow_t&) throw() { \
100 NLIB_ASSERT(size == sizeof(typeName)); \
101 return ExiAllocator::Alloc(size); \
103 static void* operator new(size_t size, void* ptr) throw() { \
104 return ::operator new(size, ptr); \
106 static void operator delete(void* p) throw() { ExiAllocator::Dealloc(p); } \
107 static void* operator new[](size_t size, void* p) throw(); \
108 static void operator delete[](void* p) throw()
110 #define NEXI_DISALLOW_NEW_DELETE(typeName) \
112 static void* operator new(size_t size, void* ptr) throw() { \
113 return ::operator new(size, ptr); \
116 static void* operator new(size_t size) throw(); \
117 static void* operator new(size_t size, const std::nothrow_t&) throw(); \
118 static void operator delete(void* p) throw(); \
119 static void* operator new[](size_t size, void* p) throw(); \
120 static void* operator new[](size_t size, const std::nothrow_t&) throw(); \
121 static void operator delete[](void* p) throw()
123 #define NEXI_DEF_NEW_DELETE(typeName) \
125 static void* operator new[](size_t size); \
126 static void* operator new[](size_t size, void* p) NLIB_NOEXCEPT; \
127 static void* operator new[](size_t size, const std::nothrow_t&) NLIB_NOEXCEPT; \
128 static void operator delete[](void* p) NLIB_NOEXCEPT; \
129 static void operator delete[](void* p, void* ptr) NLIB_NOEXCEPT; \
130 static void operator delete[](void* p, const std::nothrow_t&) NLIB_NOEXCEPT; \
132 static void* operator new(size_t size) { \
133 NLIB_ASSERT(size == sizeof(typeName)); \
134 return ExiAllocator::Alloc(size); \
136 static void* operator new(size_t size, const std::nothrow_t&) NLIB_NOEXCEPT { \
137 NLIB_ASSERT(size == sizeof(typeName)); \
138 return ExiAllocator::Alloc(size); \
140 static void* operator new(size_t size, void* ptr) NLIB_NOEXCEPT { \
141 return ::operator new(size, ptr); \
143 static void operator delete(void* p) NLIB_NOEXCEPT { ExiAllocator::Dealloc(p); } \
144 static void operator delete(void* p, const std::nothrow_t&) NLIB_NOEXCEPT { \
145 ExiAllocator::Dealloc(p); \
147 static void operator delete(void* p, void* ptr) NLIB_NOEXCEPT { \
148 return ::operator delete(p, ptr); \
151 #ifndef NLIB_CAFE_PPC
152 #define NEXI_DISALLOW_NEW_DELETE(typeName) \
154 static void* operator new(size_t size, void* ptr) NLIB_NOEXCEPT { \
155 return ::operator new(size, ptr); \
157 static void operator delete(void* p, void* ptr) NLIB_NOEXCEPT { \
158 return ::operator delete(p, ptr); \
160 static void operator delete(void* p) NLIB_NOEXCEPT { \
165 static void* operator new(size_t size); \
166 static void* operator new(size_t size, const std::nothrow_t&) NLIB_NOEXCEPT; \
167 static void operator delete(void* p, const std::nothrow_t&) NLIB_NOEXCEPT; \
168 static void* operator new[](size_t size); \
169 static void* operator new[](size_t size, void* p) NLIB_NOEXCEPT; \
170 static void* operator new[](size_t size, const std::nothrow_t&) NLIB_NOEXCEPT; \
171 static void operator delete[](void* p) NLIB_NOEXCEPT; \
172 static void operator delete[](void* p, void* ptr) NLIB_NOEXCEPT; \
173 static void operator delete[](void* p, const std::nothrow_t&) NLIB_NOEXCEPT
175 #define NEXI_DISALLOW_NEW_DELETE(typeName) NLIB_STATIC_ASSERT(true)
182 #if defined(_MSC_VER) && defined(nx_exi_EXPORTS)
183 #undef NLIB_VIS_PUBLIC
184 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT
187 #endif // INCLUDE_NN_NLIB_EXI_EXIALLOCATOR_H_
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
Allocator used by the XML parser. The user can also use it.
Defines constructs such as string-type typedef statements and utility macros.
#define NLIB_FINAL
Defines final if it is available for use. If not, holds an empty string.
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
Prohibits use of the copy constructor and assignment operator for the class specified by TypeName...
#define NLIB_SAFE_BOOL(class_name, exp)
Defines a safe operator bool function in the class. Uses the C++11 explicit bool if it is available f...
#define NLIB_CEXPR
Defines constexpr if it is available for use. If not, holds an empty string.
void swap(ExiAllocatorEx &rhs) noexcept
Swaps the contents of an object.
constexpr ExiAllocatorEx() noexcept
Instantiates the object with default parameters (default constructor).
Allocator that can be set for each instance of XmlStreamReader and XmlStreamWriter.
ExiAllocatorEx & operator=(const ExiAllocatorEx &rhs) noexcept
Assignment operator.
A file that contains the configuration information for each development environment.
~ExiAllocatorEx() noexcept
Destructor.
ExiAllocatorEx(const ExiAllocatorEx &rhs) noexcept
Copy constructor.