16 #ifndef INCLUDE_NN_NLIB_CONFIG_H_ 17 #define INCLUDE_NN_NLIB_CONFIG_H_ 28 #if defined(n_EXPORTS) 29 #undef NLIB_VIS_PUBLIC 30 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT 31 #elif defined(nx_misc_EXPORTS) 32 #undef NLIB_VIS_PUBLIC 33 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT 37 #ifndef NLIB_NAMESPACE_BEGIN 38 #define NLIB_NAMESPACE_BEGIN \ 43 #ifndef NLIB_NAMESPACE_END 44 #define NLIB_NAMESPACE_END \ 50 #define NLIB_NS ::nn::nlib 58 #include "nn/nlib/Config_cafe.h" 59 #elif defined(NN_PLATFORM_CTR) 60 #include "nn/nlib/Config_ctr.h" 62 #include "nn/nlib/Config_nx.h" 63 #elif defined(_MSC_VER) 64 #include "nn/nlib/Config_win32.h" 65 #elif defined(__CYGWIN__) 66 #include "nn/nlib/Config_cygwin.h" 67 #elif defined(__linux__) 68 #include "nn/nlib/Config_linux.h" 69 #elif defined(__FreeBSD__) 70 #include "nn/nlib/Config_freebsd.h" 71 #elif defined(__APPLE__) && defined(__MACH__) 72 #include "nn/nlib/Config_osx.h" 75 #ifdef NLIB_CXX11_STDLIB_ATOMIC 77 #undef NLIB_MEMORY_ORDER_RELEASE 78 #undef NLIB_MEMORY_ORDER_ACQUIRE 79 #undef NLIB_MEMORY_ORDER_ACQ_REL 81 #define NLIB_MEMORY_ORDER_RELEASE ::std::atomic_thread_fence(::std::memory_order_release) 82 #define NLIB_MEMORY_ORDER_ACQUIRE ::std::atomic_thread_fence(::std::memory_order_acquire) 83 #define NLIB_MEMORY_ORDER_ACQ_REL ::std::atomic_thread_fence(::std::memory_order_acq_rel) 86 #ifdef __cpp_rvalue_references 88 #define NLIB_FWD(T, v) std::forward<T>(v) 89 #define NLIB_MOVE(x) std::move(x) 92 #define NLIB_FWD(T, v) (v) 93 #define NLIB_MOVE(x) (x) 96 #ifdef __cpp_constexpr 97 #define NLIB_CEXPR constexpr 98 #if __cpp_constexpr >= 201304L 99 #define NLIB_CEXPR14 constexpr 109 #define NLIB_NOEXCEPT noexcept 110 #define NLIB_NOEXCEPT_FUNCPTR 111 #define NLIB_CEXPR constexpr 112 #define NLIB_CEXPR14 constexpr 113 #define NLIB_DEPRECATED [[deprecated]] 114 #define NLIB_DEPRECATED_MSG(x) [[deprecated(x)]] 117 #ifndef NLIB_NOEXCEPT 118 #ifdef NLIB_CXX11_NOEXCEPT 119 #define NLIB_NOEXCEPT noexcept 121 #define NLIB_NOEXCEPT throw() 123 #elif defined(__INTELLISENSE__) 125 #define NLIB_NOEXCEPT 128 #ifndef NLIB_NOEXCEPT_FUNCPTR 129 #define NLIB_NOEXCEPT_FUNCPTR 132 struct nlib_unwind_exception {};
133 #ifndef NLIB_RETHROW_UNWIND 134 #define NLIB_RETHROW_UNWIND catch (nlib_unwind_exception&) 137 #ifndef NLIB_ASSERT_NOERR 138 #define NLIB_ASSERT_NOERR(e) NLIB_ASSERT((e) == 0) 141 #ifdef __cpp_exceptions 143 #define NLIB_CATCH(x) catch (x) 144 #define NLIB_THROW throw 146 #define NLIB_TRY if (true) 147 #define NLIB_CATCH(x) if (false) 151 #ifndef NLIB_STATIC_ASSERT 152 #ifndef __cpp_static_assert 156 struct STATIC_ASSERTION_FAILURE;
158 struct STATIC_ASSERTION_FAILURE<true> {};
160 struct static_assert_test {};
164 #define NLIB_ASSERT_H_STRING_JOIN_(X, Y) NLIB_ASSERT_H_STRING_JOIN1_(X, Y) 165 #define NLIB_ASSERT_H_STRING_JOIN1_(X, Y) X##Y 167 #define NLIB_STATIC_ASSERT(exp) \ 168 typedef ::nlib_ns::detail::static_assert_test<sizeof( \ 169 ::nlib_ns::detail::STATIC_ASSERTION_FAILURE<(exp) != 0>)> \ 170 NLIB_ASSERT_H_STRING_JOIN_(nn_static_assert_typedef_, __LINE__) 171 #elif __cpp_static_assert >= 201411L 172 #define NLIB_STATIC_ASSERT(exp) static_assert(exp) 174 #define NLIB_STATIC_ASSERT(exp) static_assert((exp), "NLIB_STATIC_ASSERT error: " #exp) 178 #ifndef NLIB_CXX11_DEFAULTED_AND_DELETED_FUNCTIONS 179 #define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName) \ 180 TypeName(const TypeName&); \ 181 void operator=(const TypeName&) 183 #define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName) \ 184 TypeName(const TypeName&) = delete; \ 185 void operator=(const TypeName&) = delete 188 #ifndef NLIB_CXX11_EXPLICIT_CONVERSION_OPERATORS 189 #define NLIB_SAFE_BOOL(class_name, exp) \ 191 typedef void (class_name::*bool_type)() const; \ 192 void this_type_does_not_support_comparisons() const NLIB_NOEXCEPT {} \ 195 operator bool_type() const NLIB_NOEXCEPT { \ 196 return (exp) ? &class_name::this_type_does_not_support_comparisons : 0; \ 199 #define NLIB_SAFE_BOOL(class_name, exp) \ 201 explicit NLIB_ALWAYS_INLINE operator bool() const NLIB_NOEXCEPT { return (exp); } 205 #if defined(WCHAR_MIN) && defined(WCHAR_MAX) 206 #if WCHAR_MAX <= 0xFFFF 207 #define NLIB_WCHAR_SIZE (2) 210 #define NLIB_WCHAR_SIZE (4) 214 #error WCHAR_MIN, WCHAR_MAX not defined 217 #ifndef NLIB_CXX11_NULL_POINTER_CONSTANT 222 operator T*()
const {
225 template<
class C,
class T>
226 operator T C::*()
const {
231 void operator&()
const;
235 const nullptr_t
nullptr = {};
241 typedef std::nullptr_t nullptr_t;
245 #ifndef NLIB_CXX11_EXPLICIT_VIRTUAL_OVERRIDES 246 #define NLIB_OVERRIDE 249 #define NLIB_OVERRIDE override 250 #define NLIB_FINAL final 253 #ifdef NLIB_CXX11_ALIGNMENT_SUPPORT 260 #define NLIB_ALIGNAS(x) alignas(x) 261 #define NLIB_ALIGNOF(tp) alignof(tp) 264 #ifdef __cpp_rvalue_references 273 #ifdef __cpp_rvalue_references 274 #define NLIB_DEFMOVE_PIMPL(tp) \ 275 NLIB_ALWAYS_INLINE tp(tp&& rhs) NLIB_NOEXCEPT : prv_(rhs.prv_) { rhs.prv_ = nullptr; } \ 276 NLIB_ALWAYS_INLINE tp& operator=(tp&& rhs) NLIB_NOEXCEPT { \ 279 rhs.prv_ = nullptr; \ 283 tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : prv_(rhs.prv_) { rhs.prv_ = nullptr; } \ 285 tp& assign(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT { \ 288 rhs.prv_ = nullptr; \ 292 #define NLIB_DEFMOVE_PIMPL(tp) \ 294 tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : prv_(rhs.prv_) { rhs.prv_ = nullptr; } \ 296 tp& assign(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT { \ 299 rhs.prv_ = nullptr; \ 304 #ifndef NLIB_MEMCHECKER 305 #define NLIB_MEMCHECKER NLIB_STATIC_ASSERT(sizeof(char) == 1) 306 #define NLIB_MEMCHECKER_START NLIB_STATIC_ASSERT(sizeof(char) == 1) 307 #define NLIB_MEMCHECKER_CHECK true 312 #ifndef NLIB_NOEMPTYFILE 313 #define NLIB_NOEMPTYFILE() 316 #ifdef NLIB_SOCKET_ENABLED 320 #define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER + 50) 322 #define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER) 326 #define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER + 75) 328 #define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER + 25) 331 #elif defined(__clang__) 333 #define NLIB_SOCKPORT_SAMPLE (18174) 335 #define NLIB_SOCKPORT_SAMPLE (18074) 339 #define NLIB_SOCKPORT_SAMPLE (17874) 341 #define NLIB_SOCKPORT_SAMPLE (17974) 354 #if !defined(NLIB_CIBUILD) && defined(NDEBUG) 355 #define NLIB_TESTLOOPCOUNT(x) (x) 357 #define NLIB_TESTLOOPCOUNT(x) (1) 360 #ifndef NLIB_OVERRIDE_NEW 361 #define NLIB_OVERRIDE_NEW \ 362 static void* operator new(size_t size); \ 363 static void operator delete(void* ptr); \ 364 static void* operator new(size_t size, void* ptr) NLIB_NOEXCEPT; \ 365 static void operator delete(void* mem, void* ptr)NLIB_NOEXCEPT; \ 366 static void* operator new(size_t size, const std::nothrow_t& nt) NLIB_NOEXCEPT; \ 367 static void operator delete(void* mem, const std::nothrow_t& nt)NLIB_NOEXCEPT 370 #ifndef NLIB_OVERRIDE_NEW_LIBNEW_CPP 371 #define NLIB_OVERRIDE_NEW_LIBNEW_CPP(type) \ 372 void* type::operator new(size_t size) { return ::operator new(size); } \ 373 void type::operator delete(void* ptr) { ::operator delete(ptr); } \ 374 void* type::operator new(size_t size, void* ptr) NLIB_NOEXCEPT { \ 375 return ::operator new(size, ptr); \ 377 void type::operator delete(void* mem, void* ptr)NLIB_NOEXCEPT { ::operator delete(mem, ptr); } \ 378 void* type::operator new(size_t size, const std::nothrow_t& nt) NLIB_NOEXCEPT { \ 379 return ::operator new(size, nt); \ 381 void type::operator delete(void* mem, const std::nothrow_t& nt)NLIB_NOEXCEPT { \ 383 ::operator delete(mem); \ 387 #define NLIB_EQUAL_OPERATOR(TP) \ 388 NLIB_ALWAYS_INLINE bool operator!=(const TP& lhs, const TP& rhs) NLIB_NOEXCEPT { \ 389 return !(lhs == rhs); \ 392 #define NLIB_COMPARE_OPERATOR(TP) \ 393 NLIB_ALWAYS_INLINE bool operator>(const TP& lhs, const TP& rhs) NLIB_NOEXCEPT { \ 396 NLIB_ALWAYS_INLINE bool operator<=(const TP& lhs, const TP& rhs) NLIB_NOEXCEPT { \ 397 return !(rhs < lhs); \ 399 NLIB_ALWAYS_INLINE bool operator>=(const TP& lhs, const TP& rhs) NLIB_NOEXCEPT { \ 400 return !(lhs < rhs); \ 417 bool operator!()
const;
423 return lhs.operator
errno_t() == rhs;
427 return rhs.operator
errno_t() == lhs;
431 return lhs.operator
errno_t() != rhs;
435 return rhs.operator
errno_t() != lhs;
447 const char& operator[](
size_t idx)
const NLIB_NOEXCEPT {
return str_[idx]; }
458 operator const char*()
const NLIB_NOEXCEPT {
return &str_[0]; }
459 const char& operator[](
size_t idx)
const NLIB_NOEXCEPT {
return str_[idx]; }
460 char& operator[](
size_t idx)
NLIB_NOEXCEPT {
return str_[idx]; }
473 _Printf_format_string_
const char* fmt,
480 _Printf_format_string_
const char* fmt,
491 _Printf_format_string_
const wchar_t* fmt,
498 _Printf_format_string_
const wchar_t* fmt,
509 _Printf_format_string_
const char* fmt,
511 return nlib_vsnprintf_fallback(count, buf, N, fmt, args);
516 _Printf_format_string_
const char* fmt,
520 errno_t e = nlib_vsnprintf_fallback(count, buf, N, fmt, args);
527 _Printf_format_string_
const wchar_t* fmt,
529 return nlib_vsnwprintf_fallback(count, buf, N, fmt, args);
534 _Printf_format_string_
const wchar_t* fmt,
538 errno_t e = nlib_vsnwprintf_fallback(count, buf, N, fmt, args);
643 #if !defined(NN_PLATFORM_CTR) && !defined(CAFE) 659 #ifdef NLIB_CXX11_EXPLICIT_CONVERSION_OPERATORS 660 return !obj.operator bool();
665 #ifdef NLIB_CXX11_DEFAULTED_AND_DELETED_FUNCTIONS 673 #endif // __cplusplus 675 #if defined(_MSC_VER) 676 #if defined(n_EXPORTS) 677 #undef NLIB_VIS_PUBLIC 678 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT 679 #elif defined(nx_misc_EXPORTS) 680 #undef NLIB_VIS_PUBLIC 681 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT 685 #endif // INCLUDE_NN_NLIB_CONFIG_H_
Class that wraps the char array storing UTF-8. This class improves visual representations of UTF-8 in...
bool operator==(const HeapHash &rhs, const HeapHash &lhs)
Returns true if the two compared summaries are equal.
bool operator!=(const HeapHash &rhs, const HeapHash &lhs)
Returns true if the two compared summaries are not equal.
An empty structure indicating that an argument to a function needs to be moved.
Class that wraps errno_t. This class improves visual representations in the Visual Studio debugger...
Implements stream-related classes usually commonly used, various containers, and other gadget classes...
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
#define NLIB_CEXPR
Defines constexpr if it is available for use. If not, holds an empty string.
Class that wraps const char* storing UTF-8. This class improves visual representations of UTF-8 in th...
#define NLIB_FINAL
Defines final if it is available for use. If not, holds an empty string.
#define NLIB_STATIC_ASSERT(exp)
Defines a static assertion. Uses static_assert if it is available for use.