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
環境に合わせてnoexcept 又は同等の定義がされます。
XMLパーサーが内部で利用するアロケータです。ユーザーが利用することもできます。
文字列型のtypedefやユーティリティマクロ等が定義されています。
#define NLIB_FINAL
利用可能であればfinalが定義されます。そうでない場合は空文字列です。
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
TypeName で指定されたクラスのコピーコンストラクタと代入演算子を禁止します。
#define NLIB_SAFE_BOOL(class_name, exp)
クラス内に安全なoperator bool()を定義します。 可能であればC++11のexplicit boolを利用します。 ...
#define NLIB_CEXPR
利用可能であればconstexprが定義されます。そうでない場合は空文字列です。
void swap(ExiAllocatorEx &rhs) noexcept
オブジェクトの内容をスワップします。
constexpr ExiAllocatorEx() noexcept
デフォルトコンストラクタです。
XmlStreamReader, XmlStreamWriter の各インスタンス毎に設定できるアロケータです。
ExiAllocatorEx & operator=(const ExiAllocatorEx &rhs) noexcept
代入演算子です。
~ExiAllocatorEx() noexcept
デストラクタです。
ExiAllocatorEx(const ExiAllocatorEx &rhs) noexcept
コピーコンストラクタです。