nlib
Config.h
Go to the documentation of this file.
1 
2 #pragma once
3 #ifndef INCLUDE_NN_NLIB_CONFIG_H_
4 #define INCLUDE_NN_NLIB_CONFIG_H_
5 
6 // NOTE:
7 // DO NOT INCLUDE THE STANDARD C/C++ LIBRARY HEADERS
8 // on the line always included in this header.
9 // This would make it difficult to avoid compile errors
10 // on the environment which lacks the standard headers.
11 
12 #include "nn/nlib/Platform.h"
13 
14 #if defined(_MSC_VER)
15 #if defined(n_EXPORTS)
16 #undef NLIB_VIS_PUBLIC
17 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT
18 #elif defined(nx_misc_EXPORTS)
19 #undef NLIB_VIS_PUBLIC
20 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT
21 #endif
22 #endif
23 
24 #ifndef NLIB_NAMESPACE_BEGIN
25 #define NLIB_NAMESPACE_BEGIN namespace nn { namespace nlib {
26 #endif
27 
28 #ifndef NLIB_NAMESPACE_END
29 #define NLIB_NAMESPACE_END }}
30 #endif
31 
32 #ifndef NLIB_NS
33 #define NLIB_NS ::nn::nlib
34 #endif
35 
36 NLIB_NAMESPACE_BEGIN
37 NLIB_NAMESPACE_END
38 namespace nlib_ns = NLIB_NS;
39 
40 #if defined(CAFE)
41 # include "nn/nlib/Config_cafe.h" // NOLINT
42 #elif defined(NN_PLATFORM_CTR)
43 # include "nn/nlib/Config_ctr.h" // NOLINT
44 #elif defined(__NX__)
45 # include "nn/nlib/Config_nx.h" // NOLINT
46 #elif defined(_MSC_VER)
47 # include "nn/nlib/Config_win32.h" // NOLINT
48 #elif defined(__CYGWIN__)
49 # include "nn/nlib/Config_cygwin.h" // NOLINT
50 #elif defined(__linux__)
51 # include "nn/nlib/Config_linux.h" // NOLINT
52 #elif defined(__FreeBSD__)
53 # include "nn/nlib/Config_freebsd.h" // NOLINT
54 #elif defined(__APPLE__) && defined(__MACH__)
55 # include "nn/nlib/Config_osx.h" // NOLINT
56 #endif
57 
58 #ifdef NLIB_CXX11_STDLIB_ATOMIC
59 // NOTE: redefine them to use std C++ library for memory barrier
60 # undef NLIB_MEMORY_ORDER_RELEASE
61 # undef NLIB_MEMORY_ORDER_ACQUIRE
62 # undef NLIB_MEMORY_ORDER_ACQ_REL
63 # include <atomic> // NOLINT
64 # define NLIB_MEMORY_ORDER_RELEASE ::std::atomic_thread_fence(::std::memory_order_release)
65 # define NLIB_MEMORY_ORDER_ACQUIRE ::std::atomic_thread_fence(::std::memory_order_acquire)
66 # define NLIB_MEMORY_ORDER_ACQ_REL ::std::atomic_thread_fence(::std::memory_order_acq_rel)
67 #endif
68 
69 #ifdef NLIB_CXX11_RVALUE_REFERENCES
70 # define NLIB_RREF &&
71 # define NLIB_FWD(T, v) std::forward<T>(v)
72 # define NLIB_MOVE(x) std::move(x)
73 #else
74 # define NLIB_RREF &
75 # define NLIB_FWD(T, v) (v)
76 # define NLIB_MOVE(x) (x)
77 #endif
78 
79 #ifdef NLIB_CXX11_CONSTEXPR
80 # define NLIB_CEXPR constexpr
81 #else
82 # define NLIB_CEXPR
83 #endif
84 
85 #ifdef NLIB_DOXYGEN
86 #define NLIB_NOEXCEPT noexcept
87 #endif
88 
89 #ifndef NLIB_NOEXCEPT
90 # define NLIB_NOEXCEPT
91 #elif defined(__INTELLISENSE__)
92 # undef NLIB_NOEXCEPT
93 # define NLIB_NOEXCEPT
94 #endif
95 
96 struct nlib_unwind_exception {}; // Do not throw this directly
97 #ifndef NLIB_RETHROW_UNWIND
98 # define NLIB_RETHROW_UNWIND catch (nlib_unwind_exception&)
99 #endif
100 
101 #ifndef NLIB_ASSERT_NOERR
102 # define NLIB_ASSERT_NOERR(e) NLIB_ASSERT((e) == 0)
103 #endif
104 
105 #ifdef NLIB_EXCEPTION_ENABLED
106 # define NLIB_TRY try
107 # define NLIB_CATCH(x) catch(x)
108 # define NLIB_THROW throw
109 #else
110 # define NLIB_TRY if (true)
111 # define NLIB_CATCH(x) if (false)
112 # define NLIB_THROW
113 #endif
114 
115 #ifndef NLIB_STATIC_ASSERT
116 #ifndef NLIB_CXX11_STATIC_ASSERTIONS
117 NLIB_NAMESPACE_BEGIN
118 namespace detail {
119 template <bool>
120 struct STATIC_ASSERTION_FAILURE;
121 template <>
122 struct STATIC_ASSERTION_FAILURE<true> {};
123 template <int x>
124 struct static_assert_test {};
125 } // namespace detail
126 NLIB_NAMESPACE_END
127 
128 #define NLIB_ASSERT_H_STRING_JOIN_(X, Y) NLIB_ASSERT_H_STRING_JOIN1_(X, Y)
129 #define NLIB_ASSERT_H_STRING_JOIN1_(X, Y) X##Y
130 
131 #define NLIB_STATIC_ASSERT(exp) \
132  typedef ::nlib_ns::detail::static_assert_test< \
133  sizeof(::nlib_ns::detail::STATIC_ASSERTION_FAILURE<(exp) != 0>)> \
134  NLIB_ASSERT_H_STRING_JOIN_(nn_static_assert_typedef_, __LINE__)
135 #else
136 # define NLIB_STATIC_ASSERT(exp) static_assert((exp), "NLIB_STATIC_ASSERT error: " #exp)
137 #endif
138 #endif
139 
140 #ifndef NLIB_CXX11_DEFAULTED_AND_DELETED_FUNCTIONS
141 #define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName) \
142 TypeName(const TypeName&); \
143 void operator=(const TypeName&)
144 #else
145 #define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName) \
146 TypeName(const TypeName&) = delete; \
147 void operator=(const TypeName&) = delete
148 #endif
149 
150 #ifndef NLIB_CXX11_EXPLICIT_CONVERSION_OPERATORS
151 #define NLIB_SAFE_BOOL(class_name, exp) \
152 private: \
153  typedef void (class_name::*bool_type)() const; \
154  void this_type_does_not_support_comparisons() const NLIB_NOEXCEPT {} \
155 public: \
156  operator bool_type() const NLIB_NOEXCEPT { \
157  return (exp) ? &class_name::this_type_does_not_support_comparisons : 0; \
158  }
159 #else
160 #define NLIB_SAFE_BOOL(class_name, exp) \
161 public: \
162  explicit NLIB_ALWAYS_INLINE operator bool() const NLIB_NOEXCEPT { return (exp); }
163 #endif
164 
165 #include <wchar.h> // NOLINT
166 #if defined(WCHAR_MIN) && defined(WCHAR_MAX)
167 # if WCHAR_MAX <= 0xFFFF
168 # define NLIB_WCHAR_SIZE (2)
169 NLIB_STATIC_ASSERT(sizeof(wchar_t) == 2);
170 # else
171 # define NLIB_WCHAR_SIZE (4)
172 NLIB_STATIC_ASSERT(sizeof(wchar_t) == 4);
173 # endif
174 #else
175 # error WCHAR_MIN, WCHAR_MAX not defined
176 #endif
177 
178 #ifndef NLIB_CXX11_NULL_POINTER_CONSTANT
179 NLIB_NAMESPACE_BEGIN
180 class nullptr_t {
181  public:
182  template <class T>
183  operator T*() const {
184  return 0;
185  }
186  template <class C, class T>
187  operator T C::*() const {
188  return 0;
189  }
190 
191  private:
192  void operator&() const; // NOLINT
193 };
194 #ifndef nullptr
195 // if nullptr macro is defined, just use it.
196 const nullptr_t nullptr = {};
197 #endif
198 NLIB_NAMESPACE_END
199 #else
200 #include <cstddef> // NOLINT this is because stddef.h does not define std::nullptr_t
201 NLIB_NAMESPACE_BEGIN
202 typedef std::nullptr_t nullptr_t;
203 NLIB_NAMESPACE_END
204 #endif
205 
206 #ifndef NLIB_CXX11_EXPLICIT_VIRTUAL_OVERRIDES
207 # define NLIB_OVERRIDE
208 # define NLIB_FINAL
209 #else
210 # define NLIB_OVERRIDE override
211 # define NLIB_FINAL final
212 #endif
213 
214 #ifdef NLIB_CXX11_ALIGNMENT_SUPPORT
215 # ifdef NLIB_ALIGNAS
216 # undef NLIB_ALIGNAS
217 # endif
218 # ifdef NLIB_ALIGNOF
219 # undef NLIB_ALIGNOF
220 # endif
221 # define NLIB_ALIGNAS(x) alignas(x)
222 # define NLIB_ALIGNOF(tp) alignof(tp)
223 #endif
224 
225 #ifdef NLIB_CXX11_RVALUE_REFERENCES
226 // for std::move
227 # include <utility> // NOLINT
228 #endif
229 
230 NLIB_NAMESPACE_BEGIN
231 struct move_tag {};
232 NLIB_NAMESPACE_END
233 
234 #define NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \
235  NLIB_ALWAYS_INLINE \
236  tp& assign(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT { /* NOLINT */ \
237  tp().swap(*this); \
238  this->swap(rhs); \
239  return *this; \
240  }
241 
242 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_1(tp, mem1) \
243  NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \
244  NLIB_ALWAYS_INLINE \
245  tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : mem1() /* NOLINT */ \
246  { \
247  this->swap(rhs); \
248  }
249 
250 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_2(tp, mem1, mem2) \
251  NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \
252  NLIB_ALWAYS_INLINE \
253  tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : mem1(), /* NOLINT */ \
254  mem2() \
255  { \
256  this->swap(rhs); \
257  }
258 
259 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_3(tp, mem1, mem2, mem3) \
260  NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \
261  NLIB_ALWAYS_INLINE \
262  tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : /* NOLINT */ \
263  mem1(), \
264  mem2(), \
265  mem3() { \
266  this->swap(rhs); \
267  }
268 
269 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_4(tp, mem1, mem2, mem3, mem4) \
270  NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \
271  NLIB_ALWAYS_INLINE \
272  tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : /* NOLINT */ \
273  mem1(), \
274  mem2(), \
275  mem3(), \
276  mem4() { \
277  this->swap(rhs); \
278  }
279 
280 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_5(tp, mem1, mem2, mem3, mem4, mem5) \
281  NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \
282  NLIB_ALWAYS_INLINE \
283  tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : /* NOLINT */ \
284  mem1(), \
285  mem2(), \
286  mem3(), \
287  mem4(), \
288  mem5() { \
289  this->swap(rhs); \
290  }
291 
292 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) \
293  NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \
294  NLIB_ALWAYS_INLINE \
295  tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : /* NOLINT */ \
296  mem1(), \
297  mem2(), \
298  mem3(), \
299  mem4(), \
300  mem5(), \
301  mem6() { \
302  this->swap(rhs); \
303  }
304 
305 #ifdef NLIB_CXX11_RVALUE_REFERENCES
306 #define NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) \
307  NLIB_ALWAYS_INLINE \
308  tp& operator=(tp&& rhs) NLIB_NOEXCEPT { \
309  tp tmp(std::move(rhs)); \
310  this->swap(tmp); \
311  return *this; \
312  }
313 
314 #ifdef NLIB_CXX11_DELEGATING_CONSTRUCTORS
315 #define NLIB_MOVE_MEMBER_HELPER_(tp) \
316  NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \
317  NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) \
318  NLIB_ALWAYS_INLINE \
319  tp(tp&& rhs) NLIB_NOEXCEPT : tp() { this->swap(rhs); } \
320  NLIB_ALWAYS_INLINE \
321  tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : tp() { this->swap(rhs); } // NOLINT
322 
323 #define NLIB_MOVE_MEMBER_HELPER_1(tp, mem1) NLIB_MOVE_MEMBER_HELPER_(tp)
324 #define NLIB_MOVE_MEMBER_HELPER_2(tp, mem1, mem2) NLIB_MOVE_MEMBER_HELPER_(tp)
325 #define NLIB_MOVE_MEMBER_HELPER_3(tp, mem1, mem2, mem3) NLIB_MOVE_MEMBER_HELPER_(tp)
326 #define NLIB_MOVE_MEMBER_HELPER_4(tp, mem1, mem2, mem3, mem4) NLIB_MOVE_MEMBER_HELPER_(tp)
327 #define NLIB_MOVE_MEMBER_HELPER_5(tp, mem1, mem2, mem3, mem4, mem5) NLIB_MOVE_MEMBER_HELPER_(tp)
328 #define NLIB_MOVE_MEMBER_HELPER_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) \
329  NLIB_MOVE_MEMBER_HELPER_(tp)
330 
331 #else
332 #define NLIB_MOVE_MEMBER_HELPER_1(tp, mem1) \
333  NLIB_ALWAYS_INLINE \
334  tp(tp&& rhs) NLIB_NOEXCEPT : mem1() { this->swap(rhs); } \
335  NLIB_MOVE_MEMBER_HELPER_WITHTAG_1(tp, mem1) \
336  NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp)
337 
338 #define NLIB_MOVE_MEMBER_HELPER_2(tp, mem1, mem2) \
339  NLIB_ALWAYS_INLINE \
340  tp(tp&& rhs) : mem1(), mem2() { this->swap(rhs); } \
341  NLIB_MOVE_MEMBER_HELPER_WITHTAG_2(tp, mem1, mem2) \
342  NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp)
343 
344 #define NLIB_MOVE_MEMBER_HELPER_3(tp, mem1, mem2, mem3) \
345  NLIB_ALWAYS_INLINE \
346  tp(tp&& rhs) : mem1(), mem2(), mem3() { this->swap(rhs); } \
347  NLIB_MOVE_MEMBER_HELPER_WITHTAG_3(tp, mem1, mem2, mem3) \
348  NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp)
349 
350 #define NLIB_MOVE_MEMBER_HELPER_4(tp, mem1, mem2, mem3, mem4) \
351  NLIB_ALWAYS_INLINE \
352  tp(tp&& rhs) : mem1(), mem2(), mem3(), mem4() { this->swap(rhs); } \
353  NLIB_MOVE_MEMBER_HELPER_WITHTAG_4(tp, mem1, mem2, mem3, mem4) \
354  NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp)
355 
356 #define NLIB_MOVE_MEMBER_HELPER_5(tp, mem1, mem2, mem3, mem4, mem5) \
357  NLIB_ALWAYS_INLINE \
358  tp(tp&& rhs) : mem1(), mem2(), mem3(), mem4(), mem5() { this->swap(rhs); } \
359  NLIB_MOVE_MEMBER_HELPER_WITHTAG_5(tp, mem1, mem2, mem3, mem4, mem5) \
360  NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp)
361 
362 #define NLIB_MOVE_MEMBER_HELPER_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) \
363  NLIB_ALWAYS_INLINE \
364  tp(tp&& rhs) : mem1(), mem2(), mem3(), mem4(), mem5(), mem6() { this->swap(rhs); } \
365  NLIB_MOVE_MEMBER_HELPER_WITHTAG_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) \
366  NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp)
367 
368 #endif
369 #else
370 #define NLIB_MOVE_MEMBER_HELPER_1(tp, mem1) NLIB_MOVE_MEMBER_HELPER_WITHTAG_1(tp, mem1)
371 
372 #define NLIB_MOVE_MEMBER_HELPER_2(tp, mem1, mem2) NLIB_MOVE_MEMBER_HELPER_WITHTAG_2(tp, mem1, mem2)
373 
374 #define NLIB_MOVE_MEMBER_HELPER_3(tp, mem1, mem2, mem3) \
375  NLIB_MOVE_MEMBER_HELPER_WITHTAG_3(tp, mem1, mem2, mem3)
376 
377 #define NLIB_MOVE_MEMBER_HELPER_4(tp, mem1, mem2, mem3, mem4) \
378  NLIB_MOVE_MEMBER_HELPER_WITHTAG_4(tp, mem1, mem2, mem3, mem4)
379 
380 #define NLIB_MOVE_MEMBER_HELPER_5(tp, mem1, mem2, mem3, mem4, mem5) \
381  NLIB_MOVE_MEMBER_HELPER_WITHTAG_5(tp, mem1, mem2, mem3, mem4, mem5)
382 
383 #define NLIB_MOVE_MEMBER_HELPER_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) \
384  NLIB_MOVE_MEMBER_HELPER_WITHTAG_6(tp, mem1, mem2, mem3, mem4, mem5, mem6)
385 
386 #endif
387 
388 #ifndef NLIB_MEMCHECKER
389 # define NLIB_MEMCHECKER NLIB_STATIC_ASSERT(sizeof(char) == 1) // NOLINT
390 # define NLIB_MEMCHECKER_START NLIB_STATIC_ASSERT(sizeof(char) == 1) // NOLINT
391 # define NLIB_MEMCHECKER_CHECK true
392 #endif
393 
394 // The following macro "NLIB_NOEMPTYFILE()" can be put into a file
395 // in order suppress the MS Visual C++ Linker warning 4221
396 #ifndef NLIB_NOEMPTYFILE
397 # define NLIB_NOEMPTYFILE()
398 #endif
399 
400 #ifdef NLIB_SOCKET_ENABLED
401 # ifdef _MSC_VER
402 # ifndef NLIB_WINDLL
403 # ifdef _DEBUG
404 # define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER + 50)
405 # else
406 # define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER)
407 # endif
408 # else
409 # ifdef _DEBUG
410 # define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER + 75)
411 # else
412 # define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER + 25)
413 # endif
414 # endif
415 # elif defined(__clang__)
416 # ifdef NDEBUG
417 # define NLIB_SOCKPORT_SAMPLE (18174)
418 # else
419 # define NLIB_SOCKPORT_SAMPLE (18074)
420 # endif
421 # else
422 # ifdef NDEBUG
423 # define NLIB_SOCKPORT_SAMPLE (17874)
424 # else
425 # define NLIB_SOCKPORT_SAMPLE (17974)
426 # endif
427 # endif
428 #endif
429 
430 //
431 // You can reduce the loopcount for the performance test
432 // when it runs on on a continuous integration system like Jenkins.
433 //
434 // for (int i = 0; i < NLIB_TESTLOOPCOUNT(10000); ++i) {
435 // .....
436 // }
437 //
438 #if !defined(NLIB_CIBUILD) && defined(NDEBUG)
439 # define NLIB_TESTLOOPCOUNT(x) (x)
440 #else
441 # define NLIB_TESTLOOPCOUNT(x) (1)
442 #endif
443 
444 #ifndef NLIB_OVERRIDE_NEW
445 #define NLIB_OVERRIDE_NEW \
446  static void* operator new(size_t size); \
447  static void operator delete(void* ptr); \
448  static void* operator new(size_t size, void* ptr) NLIB_NOEXCEPT; \
449  static void operator delete(void* mem, void* ptr) NLIB_NOEXCEPT; \
450  static void* operator new(size_t size, const std::nothrow_t& nt) NLIB_NOEXCEPT; \
451  static void operator delete(void* mem, const std::nothrow_t& nt) NLIB_NOEXCEPT
452 #endif
453 
454 #ifndef NLIB_OVERRIDE_NEW_LIBNEW_CPP
455 #define NLIB_OVERRIDE_NEW_LIBNEW_CPP(type) \
456  void* type::operator new(size_t size) { return ::operator new(size); } \
457  void type::operator delete(void* ptr) { ::operator delete(ptr); } \
458  void* type::operator new(size_t size, void* ptr) NLIB_NOEXCEPT { \
459  return ::operator new(size, ptr); \
460  } \
461  void type::operator delete(void* mem, void* ptr) NLIB_NOEXCEPT { \
462  ::operator delete(mem, ptr); \
463  } \
464  void* type::operator new(size_t size, const std::nothrow_t& nt) NLIB_NOEXCEPT { \
465  return ::operator new(size, nt); \
466  } \
467  void type::operator delete(void* mem, const std::nothrow_t& nt) NLIB_NOEXCEPT { \
468  NLIB_UNUSED(nt); \
469  ::operator delete(mem); \
470  }
471 #endif
472 
473 NLIB_NAMESPACE_BEGIN
475  public:
476  ErrnoT() NLIB_NOEXCEPT {}
477  NLIB_CEXPR ErrnoT(errno_t e) NLIB_NOEXCEPT : vs_errno_(e) {} // NOLINT
478  ErrnoT& operator=(errno_t e) NLIB_NOEXCEPT {
479  vs_errno_ = e;
480  return *this;
481  }
482  operator errno_t() const NLIB_NOEXCEPT { return vs_errno_; }
483  // const char* c_str() const NLIB_NOEXCEPT { return nlib_error_string(vs_errno_); }
484 
485  private:
486  // to suppress the mix-up with boolean value
487  bool operator!() const; // FORBIDDEN
488  // operator bool() const; // FORBIDDEN
489  errno_t vs_errno_;
490 };
491 
493  return lhs.operator errno_t() == rhs;
494 }
495 
497  return rhs.operator errno_t() == lhs;
498 }
499 
501  return lhs.operator errno_t() != rhs;
502 }
503 
505  return rhs.operator errno_t() != lhs;
506 }
507 
509  public:
510  Utf8Ptr() NLIB_NOEXCEPT : str_(NULL) {}
511  Utf8Ptr(const char* str) NLIB_NOEXCEPT : str_(str) {} // NOLINT
512  operator const char*() const NLIB_NOEXCEPT { return str_; }
513  Utf8Ptr& operator=(const char* str) NLIB_NOEXCEPT { str_ = str; return *this; }
514  const char& operator[](size_t idx) const NLIB_NOEXCEPT { return str_[idx]; }
515 
516  private:
517  const char* str_;
518 };
519 
520 template<size_t N>
522  public:
524  operator char*() NLIB_NOEXCEPT { return &str_[0]; }
525  operator const char*() const NLIB_NOEXCEPT { return &str_[0]; }
526  const char& operator[](size_t idx) const NLIB_NOEXCEPT { return str_[idx]; }
527  char& operator[](size_t idx) NLIB_NOEXCEPT { return str_[idx]; }
528 
529  private:
530  char str_[N];
531 };
532 NLIB_NAMESPACE_END
533 
534 #ifdef NLIB_CXX11_NEW_CHARACTER_TYPES
535 typedef char16_t nlib_utf16_t;
536 typedef char32_t nlib_utf32_t;
537 #else
538 typedef uint16_t nlib_utf16_t;
539 typedef uint32_t nlib_utf32_t;
540 #endif
541 
542 //
543 // C++ functions in global namespace
544 //
545 #ifdef __cplusplus
546 
547 extern "C" {
548 
549 // 0 if error
551  nlib_utf32_t* utf32,
552  nlib_utf16_t upper,
553  nlib_utf16_t lower) NLIB_NOEXCEPT NLIB_NONNULL;
554 // 0 if error
556  nlib_utf16_t* upper,
557  nlib_utf16_t* lower,
558  nlib_utf32_t utf32) NLIB_NOEXCEPT NLIB_NONNULL;
559 // 0 if error
561  nlib_utf32_t* utf32,
562  const char* utf8) NLIB_NOEXCEPT NLIB_NONNULL;
563 // 0 if error
565  char (&utf8)[4],
566  nlib_utf32_t utf32) NLIB_NOEXCEPT;
567 
569  size_t* utf8count,
570  char* utf8,
571  size_t buflen,
572  const nlib_utf16_t* utf16) NLIB_NOEXCEPT NLIB_NONNULL_4;
574  size_t* utf16count,
575  nlib_utf16_t* utf16,
576  size_t buflen,
577  const char* utf8) NLIB_NOEXCEPT NLIB_NONNULL_4;
579  size_t* utf8count,
580  char* utf8,
581  size_t buflen,
582  const nlib_utf32_t* utf32) NLIB_NOEXCEPT NLIB_NONNULL_4;
584  size_t* utf32count,
585  nlib_utf32_t* utf32,
586  size_t buflen,
587  const char* utf8) NLIB_NOEXCEPT NLIB_NONNULL_4;
588 
590  size_t* __restrict to_count, size_t* __restrict from_count,
591  char* __restrict to, size_t to_size,
592  const nlib_utf16_t* __restrict from, size_t from_size)
595  size_t* __restrict to_count, size_t* __restrict from_count,
596  nlib_utf16_t* __restrict to, size_t to_size,
597  const char* __restrict from, size_t from_size)
600  size_t* __restrict to_count, size_t* __restrict from_count,
601  char* __restrict to, size_t to_size,
602  const nlib_utf32_t* __restrict from, size_t from_size)
605  size_t* __restrict to_count, size_t* __restrict from_count,
606  nlib_utf32_t* __restrict to, size_t to_size,
607  const char* __restrict from, size_t from_size)
609 
610 NLIB_VIS_PUBLIC_ALT size_t nlib_utf16len_(
611  const uint16_t* str) NLIB_NONNULL;
612 NLIB_VIS_PUBLIC_ALT size_t nlib_utf16nlen_(
613  const uint16_t* str,
614  size_t maxsize) NLIB_NONNULL;
615 NLIB_VIS_PUBLIC errno_t nlib_utf16cpy_(
616  uint16_t* s1,
617  size_t s1max,
618  const uint16_t* s2) NLIB_NONNULL;
619 NLIB_VIS_PUBLIC errno_t nlib_utf16ncpy_(
620  uint16_t* s1,
621  size_t s1max,
622  const uint16_t* s2,
623  size_t n) NLIB_NONNULL;
625  const nlib_utf16_t* str) NLIB_NOEXCEPT {
626  return nlib_utf16len_(reinterpret_cast<const uint16_t*>(str));
627 }
629  const nlib_utf16_t* str,
630  size_t maxsize) NLIB_NOEXCEPT {
631  return nlib_utf16nlen_(reinterpret_cast<const uint16_t*>(str), maxsize);
632 }
634  nlib_utf16_t* s1,
635  size_t s1max,
636  const nlib_utf16_t* s2) NLIB_NOEXCEPT {
637  return nlib_utf16cpy_(reinterpret_cast<uint16_t*>(s1), s1max,
638  reinterpret_cast<const uint16_t*>(s2));
639 }
641  nlib_utf16_t* s1,
642  size_t s1max,
643  const nlib_utf16_t* s2,
644  size_t n) NLIB_NOEXCEPT {
645  return nlib_utf16ncpy_(reinterpret_cast<uint16_t*>(s1), s1max,
646  reinterpret_cast<const uint16_t*>(s2), n);
647 }
648 
649 NLIB_VIS_PUBLIC_ALT size_t nlib_utf32len_(
650  const uint32_t* str) NLIB_NONNULL;
651 NLIB_VIS_PUBLIC_ALT size_t nlib_utf32nlen_(
652  const uint32_t* str,
653  size_t maxsize) NLIB_NONNULL;
654 NLIB_VIS_PUBLIC errno_t nlib_utf32cpy_(
655  uint32_t* s1,
656  size_t s1max,
657  const uint32_t* s2) NLIB_NONNULL;
658 NLIB_VIS_PUBLIC errno_t nlib_utf32ncpy_(
659  uint32_t* s1,
660  size_t s1max,
661  const uint32_t* s2,
662  size_t n) NLIB_NONNULL;
664  const nlib_utf32_t* str) NLIB_NOEXCEPT {
665  return nlib_utf32len_(reinterpret_cast<const uint32_t*>(str));
666 }
668  const nlib_utf32_t* str,
669  size_t maxsize) NLIB_NOEXCEPT {
670  return nlib_utf32nlen_(reinterpret_cast<const uint32_t*>(str), maxsize);
671 }
673  nlib_utf32_t* s1,
674  size_t s1max,
675  const nlib_utf32_t* s2) NLIB_NOEXCEPT {
676  return nlib_utf32cpy_(reinterpret_cast<uint32_t*>(s1), s1max,
677  reinterpret_cast<const uint32_t*>(s2));
678 }
680  nlib_utf32_t* s1,
681  size_t s1max,
682  const nlib_utf32_t* s2,
683  size_t n) NLIB_NOEXCEPT {
684  return nlib_utf32ncpy_(reinterpret_cast<uint32_t*>(s1), s1max,
685  reinterpret_cast<const uint32_t*>(s2), n);
686 }
687 
688 NLIB_VIS_PUBLIC_ALT NLIB_CHECK_RESULT errno_t nlib_utf16cplen_ex_(
689  size_t* count,
690  size_t* len,
691  const uint16_t* str) NLIB_NONNULL_3;
692 
694  size_t* count,
695  const nlib_utf16_t* str) NLIB_NOEXCEPT {
696  return nlib_utf16cplen_ex_(count, NULL, reinterpret_cast<const uint16_t*>(str));
697 }
699  size_t* count,
700  size_t* len,
701  const nlib_utf16_t* str) NLIB_NOEXCEPT {
702  return nlib_utf16cplen_ex_(count, len, reinterpret_cast<const uint16_t*>(str));
703 }
705  size_t* count,
706  const nlib_utf32_t* str) NLIB_NOEXCEPT NLIB_NONNULL_2;
707 
708 } // extern "C"
709 
710 template <size_t N>
712  size_t* count,
713  char (&buf)[N],
714  _Printf_format_string_ const char* fmt,
715  va_list args) NLIB_NOEXCEPT {
716  return nlib_vsnprintf(count, buf, N, fmt, args);
717 }
718 
719 template<size_t N>
721  size_t* count,
722  char (&buf)[N],
723  _Printf_format_string_ const char* fmt,
724  ...) NLIB_NOEXCEPT {
725  va_list args;
726  va_start(args, fmt);
727  errno_t e = nlib_vsnprintf(count, buf, N, fmt, args);
728  va_end(args);
729  return e;
730 }
731 
732 template <size_t N>
734  size_t* count,
735  wchar_t (&buf)[N],
736  _Printf_format_string_ const wchar_t* fmt,
737  va_list args) NLIB_NOEXCEPT {
738  return nlib_vsnwprintf(count, buf, N, fmt, args);
739 }
740 
741 template<size_t N>
743  size_t* count,
744  wchar_t(&buf)[N],
745  _Printf_format_string_ const wchar_t* fmt,
746  ...) NLIB_NOEXCEPT {
747  va_list args;
748  va_start(args, fmt);
749  errno_t e = nlib_vsnwprintf(count, buf, N, fmt, args);
750  va_end(args);
751  return e;
752 }
753 
754 template <size_t N>
755 NLIB_ALWAYS_INLINE errno_t nlib_vsnprintf_fallback(
756  size_t* count,
757  char (&buf)[N],
758  _Printf_format_string_ const char* fmt,
759  va_list args) NLIB_NOEXCEPT {
760  return nlib_vsnprintf_fallback(count, buf, N, fmt, args);
761 }
762 
763 template<size_t N>
764 inline NLIB_VIS_HIDDEN errno_t nlib_snprintf_fallback(
765  size_t* count,
766  char (&buf)[N],
767  _Printf_format_string_ const char* fmt,
768  ...) NLIB_NOEXCEPT {
769  va_list args;
770  va_start(args, fmt);
771  errno_t e = nlib_vsnprintf_fallback(count, buf, N, fmt, args);
772  va_end(args);
773  return e;
774 }
775 
776 template <size_t N>
777 NLIB_ALWAYS_INLINE errno_t nlib_vsnwprintf_fallback(
778  size_t* count,
779  wchar_t (&buf)[N],
780  _Printf_format_string_ const wchar_t* fmt,
781  va_list args) NLIB_NOEXCEPT {
782  return nlib_vsnwprintf_fallback(count, buf, N, fmt, args);
783 }
784 
785 template<size_t N>
786 inline NLIB_VIS_HIDDEN errno_t nlib_snwprintf_fallback(
787  size_t* count,
788  wchar_t(&buf)[N],
789  _Printf_format_string_ const wchar_t* fmt,
790  ...) NLIB_NOEXCEPT {
791  va_list args;
792  va_start(args, fmt);
793  errno_t e = nlib_vsnwprintf_fallback(count, buf, N, fmt, args);
794  va_end(args);
795  return e;
796 }
797 
798 template <size_t N>
800  char (&s1)[N],
801  const char* s2) NLIB_NOEXCEPT {
802  return nlib_strcpy(&s1[0], N, s2);
803 }
804 
805 template<size_t N>
806 NLIB_ALWAYS_INLINE size_t nlib_strlcpy(char (&s1)[N], const char* s2) NLIB_NOEXCEPT {
807  // CTR armcc needs cast
808  return nlib_strlcpy((char*)&s1[0], (const char*)s2, N); // NOLINT
809 }
810 
811 template <size_t N>
813  char (&s1)[N],
814  const char* s2,
815  size_t n) NLIB_NOEXCEPT {
816  return nlib_strncpy(&s1[0], N, s2, n);
817 }
818 
819 template <size_t N>
821  wchar_t (&s1)[N],
822  const wchar_t* s2) NLIB_NOEXCEPT {
823  return nlib_wcscpy(&s1[0], N, s2);
824 }
825 
826 template <size_t N>
828  wchar_t (&s1)[N],
829  const wchar_t* s2,
830  size_t n) NLIB_NOEXCEPT {
831  return nlib_wcsncpy(&s1[0], N, s2, n);
832 }
833 
834 template<size_t N>
835 NLIB_ALWAYS_INLINE errno_t nlib_wide_to_utf8(size_t* result, char (&utf8)[N],
836  const wchar_t* wcstr) NLIB_NOEXCEPT {
837  return nlib_wide_to_utf8(result, &utf8[0], N, wcstr);
838 }
839 
840 template<size_t N>
841 NLIB_ALWAYS_INLINE errno_t nlib_utf8_to_wide(size_t* result, wchar_t (&wcstr)[N],
842  const char* utf8) NLIB_NOEXCEPT {
843  return nlib_utf8_to_wide(result, &wcstr[0], N, utf8);
844 }
845 
846 template<size_t N>
847 NLIB_ALWAYS_INLINE errno_t nlib_utf16_to_utf8(size_t* utf8count, char (&utf8)[N],
848  const nlib_utf16_t* utf16) NLIB_NOEXCEPT {
849  return nlib_utf16_to_utf8(utf8count, &utf8[0], N, utf16);
850 }
851 
852 template<size_t N>
853 NLIB_ALWAYS_INLINE errno_t nlib_utf8_to_utf16(size_t* utf16count, nlib_utf16_t (&utf16)[N],
854  const char* utf8) NLIB_NOEXCEPT {
855  return nlib_utf8_to_utf16(utf16count, &utf16[0], N, utf8);
856 }
857 
858 template<size_t N>
859 NLIB_ALWAYS_INLINE errno_t nlib_utf32_to_utf8(size_t* utf8count, char (&utf8)[N],
860  const nlib_utf32_t* utf32) NLIB_NOEXCEPT {
861  return nlib_utf32_to_utf8(utf8count, &utf8[0], N, utf32);
862 }
863 
864 template<size_t N>
866  const char* utf8) NLIB_NOEXCEPT {
867  return nlib_utf8_to_utf32(utf32count, &utf32[0], N, utf8);
868 }
869 
870 template<size_t N>
872  size_t* to_count, size_t* from_count,
873  char (&to)[N],
874  const nlib_utf16_t* from, size_t from_size) NLIB_NOEXCEPT {
875  return nlib_memutf16_to_utf8(to_count, from_count, &to[0], N, from, from_size);
876 }
877 template<size_t N>
879  size_t* to_count, size_t* from_count,
880  nlib_utf16_t (&to)[N],
881  const char* from, size_t from_size) NLIB_NOEXCEPT {
882  return nlib_memutf8_to_utf16(to_count, from_count, &to[0], N, from, from_size);
883 }
884 template<size_t N>
886  size_t* to_count, size_t* from_count,
887  char (&to)[N],
888  const nlib_utf32_t* from, size_t from_size) NLIB_NOEXCEPT {
889  return nlib_memutf32_to_utf8(to_count, from_count, &to[0], N, from, from_size);
890 }
891 template<size_t N>
893  size_t* to_count, size_t* from_count,
894  nlib_utf32_t (&to)[N],
895  const char* from, size_t from_size) NLIB_NOEXCEPT {
896  return nlib_memutf8_to_utf32(to_count, from_count, &to[0], N, from, from_size);
897 }
898 template<size_t N>
900  size_t* to_count, size_t* from_count,
901  char (&to)[N],
902  const wchar_t* from, size_t from_size) NLIB_NOEXCEPT {
903  return nlib_memwide_to_utf8(to_count, from_count, &to[0], N, from, from_size);
904 }
905 template<size_t N>
907  size_t* to_count, size_t* from_count,
908  wchar_t (&to)[N],
909  const char* from, size_t from_size) NLIB_NOEXCEPT {
910  return nlib_memutf8_to_wide(to_count, from_count, &to[0], N, from, from_size);
911 }
912 
913 #if !defined(NN_PLATFORM_CTR) && !defined(CAFE)
914 // This may throw C++ exception defined by nlib, See also nlib_thread_exit()
916 #endif
917 
918 NLIB_ALWAYS_INLINE bool nlib_is_error(bool result) NLIB_NOEXCEPT { return !result; }
919 NLIB_ALWAYS_INLINE bool nlib_is_error(errno_t e) NLIB_NOEXCEPT { return e != 0; }
920 NLIB_ALWAYS_INLINE bool nlib_is_error(const NLIB_NS::ErrnoT& e) NLIB_NOEXCEPT { return e != 0; }
921 template<class T>
923 #ifdef NLIB_CXX11_EXPLICIT_CONVERSION_OPERATORS
924  return !obj.operator bool();
925 #else
926  return !obj;
927 #endif
928 }
929 #ifdef NLIB_CXX11_DEFAULTED_AND_DELETED_FUNCTIONS
930 template<class T>
931 bool nlib_is_error(T*) = delete; // NOLINT
932 #else
933 template<class T>
934 bool nlib_is_error(T*); // NOLINT
935 #endif
936 
937 #endif // __cplusplus
938 
939 // nlib_ns::utf16_t, nlib_ns::utf32_t might be deprecated in the future
940 // use nlib_utf16_t, nlib_utf32_t instead
941 NLIB_NAMESPACE_BEGIN
942 typedef nlib_utf16_t utf16_t;
943 typedef nlib_utf32_t utf32_t;
944 NLIB_NAMESPACE_END
945 
946 #if defined(_MSC_VER)
947 #if defined(n_EXPORTS)
948 #undef NLIB_VIS_PUBLIC
949 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT
950 #elif defined(nx_misc_EXPORTS)
951 #undef NLIB_VIS_PUBLIC
952 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT
953 #endif
954 #endif
955 
956 #endif // INCLUDE_NN_NLIB_CONFIG_H_
#define NLIB_NORETURN
Indicates that the process will not return from functions.
Definition: Platform_unix.h:75
errno_t nlib_utf8_to_utf16(size_t *utf16count, nlib_utf16_t *utf16, size_t buflen, const char *utf8) noexcept
Converts a UTF-8 string into a UTF-16 string. The UTF-16 string is null-terminated.
Class that wraps the char array storing UTF-8. This class improves visual representations of UTF-8 in...
Definition: Config.h:521
errno_t nlib_memutf8_to_utf16(size_t *to_count, size_t *from_count, nlib_utf16_t *to, size_t to_size, const char *from, size_t from_size) NLIB_NONNULL_5
Converts a UTF-8 string that is not null terminated to a UTF-16 string.
void nlib_thread_exit_cpp() NLIB_NORETURN
Ends the called thread.
#define NLIB_ALWAYS_INLINE
Indicates that the compiler is forced to perform inline expansion of functions.
Definition: Platform_unix.h:69
errno_t nlib_utf16cplen_ex(size_t *count, size_t *len, const nlib_utf16_t *str) noexcept
Gets the number of code points in the string.
Definition: Config.h:698
errno_t nlib_vsnwprintf(size_t *count, wchar_t(&buf)[N], const wchar_t *fmt, va_list args) noexcept
The function template version of nlib_vsnwprintf.
Definition: Config.h:733
nlib_utf16_t utf16_t
Type for UTF-16 characters. Defined as nlib_utf16_t using typedef.
Definition: Config.h:942
errno_t nlib_utf8_to_wide(size_t *result, wchar_t(&wcstr)[N], const char *utf8) noexcept
The function template version of nlib_utf8_to_wide.
Definition: Config.h:841
NLIB_CHECK_RESULT int nlib_utf32char_to_utf8(char(&utf8)[4], nlib_utf32_t utf32) noexcept
Converts the UTF-32 for one character into UTF-8.
#define NLIB_NONNULL_1
Indicates that you cannot specify NULL for the first argument.
Definition: Platform_unix.h:77
errno_t nlib_strncpy(char(&s1)[N], const char *s2, size_t n) noexcept
The function template version of nlib_strncpy.
Definition: Config.h:812
#define NLIB_CHECK_RESULT
Indicates that the caller of the function must check the returned value.
Definition: Platform_unix.h:74
bool operator==(const HeapHash &rhs, const HeapHash &lhs)
Returns true if the two compared summaries are equal.
Definition: NMalloc.h:110
bool operator!=(const HeapHash &rhs, const HeapHash &lhs)
Returns true if the two compared summaries are not equal.
Definition: NMalloc.h:115
errno_t nlib_snwprintf(size_t *count, wchar_t(&buf)[N], const wchar_t *fmt,...) noexcept
The function template version of nlib_snwprintf.
Definition: Config.h:742
#define NLIB_VIS_HIDDEN
Symbols for functions and classes are not made available outside of the library.
Definition: Platform_unix.h:60
NLIB_CHECK_RESULT size_t nlib_utf16nlen(const nlib_utf16_t *str, size_t maxsize) noexcept
The UTF-16 version of the nlib_strnlen function.
Definition: Config.h:628
C-based declaration of the basic API.
#define NLIB_VIS_PUBLIC
Symbols for functions and classes are made available outside of the library.
Definition: Platform_unix.h:61
errno_t nlib_memutf8_to_wide(size_t *to_count, size_t *from_count, wchar_t(&to)[N], const char *from, size_t from_size) noexcept
The function template version of nlib_memutf8_to_wide().
Definition: Config.h:906
errno_t nlib_snprintf(size_t *count, char(&buf)[N], const char *fmt,...) noexcept
The function template version of nlib_snprintf.
Definition: Config.h:720
#define NLIB_NONNULL_2
Indicates that you cannot specify NULL for the second argument.
Definition: Platform_unix.h:78
uint32_t nlib_utf32_t
Uses typedef to define as char32_t if that can be used. If not, it uses typedef to define as uint32_t...
Definition: Config.h:539
errno_t nlib_memutf16_to_utf8(size_t *to_count, size_t *from_count, char *to, size_t to_size, const nlib_utf16_t *from, size_t from_size) NLIB_NONNULL_5
Converts a UTF-16 string that is not null terminated to a UTF-8 string.
errno_t nlib_memwide_to_utf8(size_t *to_count, size_t *from_count, char(&to)[N], const wchar_t *from, size_t from_size) noexcept
The function template version of nlib_memwide_to_utf8().
Definition: Config.h:899
errno_t nlib_utf16ncpy(nlib_utf16_t *s1, size_t s1max, const nlib_utf16_t *s2, size_t n) noexcept
The UTF-16 version of the nlib_strcpy function.
Definition: Config.h:640
An empty structure indicating that an argument to a function needs to be moved.
Definition: Config.h:231
errno_t nlib_memutf8_to_utf32(size_t *to_count, size_t *from_count, nlib_utf32_t *to, size_t to_size, const char *from, size_t from_size) NLIB_NONNULL_5
Converts a UTF-8 string that is not null terminated to a UTF-32 string.
uint16_t nlib_utf16_t
Uses typedef to define as char16_t if that can be used. If not, it uses typedef to define as uint16_t...
Definition: Config.h:538
errno_t nlib_wide_to_utf8(size_t *result, char(&utf8)[N], const wchar_t *wcstr) noexcept
The function template version of nlib_wide_to_utf8.
Definition: Config.h:835
NLIB_CHECK_RESULT int nlib_utf8_to_utf32char(nlib_utf32_t *utf32, const char *utf8) noexcept
Converts UTF-8 into one character&#39;s worth of UTF-32.
errno_t nlib_utf16cplen(size_t *count, const nlib_utf16_t *str) noexcept
Gets the number of code points in the string.
Definition: Config.h:693
errno_t nlib_utf32_to_utf8(size_t *utf8count, char *utf8, size_t buflen, const nlib_utf32_t *utf32) noexcept
Converts a UTF-32 string into a UTF-8 string.
Class that wraps errno_t. This class improves visual representations in the Visual Studio debugger...
Definition: Config.h:474
Implements stream-related classes usually commonly used, various containers, and other gadget classes...
Definition: Base64.h:8
NLIB_CHECK_RESULT size_t nlib_utf32nlen(const nlib_utf32_t *str, size_t maxsize) noexcept
The UTF-32 version of the nlib_strnlen function.
Definition: Config.h:667
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
Definition: Config.h:86
#define NLIB_CEXPR
Defines constexpr if it is available for use. If not, holds an empty string.
Definition: Config.h:80
errno_t nlib_utf32ncpy(nlib_utf32_t *s1, size_t s1max, const nlib_utf32_t *s2, size_t n) noexcept
The UTF-32 version of the nlib_strcpy function.
Definition: Config.h:679
Class that wraps const char* storing UTF-8. This class improves visual representations of UTF-8 in th...
Definition: Config.h:508
nlib_utf32_t utf32_t
Type for UTF-32 characters. Defined as nlib_utf32_t using typedef.
Definition: Config.h:943
NLIB_CHECK_RESULT int nlib_utf16_to_utf32char(nlib_utf32_t *utf32, nlib_utf16_t upper, nlib_utf16_t lower) noexcept
Converts a single code point from UTF-16 into UTF-32.
#define NLIB_NONNULL_4
Indicates that you cannot specify NULL for the fourth argument.
Definition: Platform_unix.h:80
errno_t nlib_vsnprintf(size_t *count, char(&buf)[N], const char *fmt, va_list args) noexcept
The function template version of nlib_vsnprintf.
Definition: Config.h:711
errno_t nlib_utf16cpy(nlib_utf16_t *s1, size_t s1max, const nlib_utf16_t *s2) noexcept
The UTF-16 version of the nlib_strcpy function.
Definition: Config.h:633
errno_t nlib_wcscpy(wchar_t(&s1)[N], const wchar_t *s2) noexcept
The function template version of nlib_wcscpy.
Definition: Config.h:820
NLIB_CHECK_RESULT size_t nlib_utf16len(const nlib_utf16_t *str) noexcept
Counts the number of nlib_utf16_t-type characters, not including the null character.
Definition: Config.h:624
#define NLIB_NONNULL_5
Indicates that you cannot specify NULL for the fifth argument.
Definition: Platform_unix.h:81
#define NLIB_FINAL
Defines final if it is available for use. If not, holds an empty string.
Definition: Config.h:211
errno_t nlib_utf16_to_utf8(size_t *utf8count, char *utf8, size_t buflen, const nlib_utf16_t *utf16) noexcept
Converts a UTF-16 string into a UTF-8 string.
#define NLIB_NONNULL_3
Indicates that you cannot specify NULL for the third argument.
Definition: Platform_unix.h:79
#define NLIB_STATIC_ASSERT(exp)
Defines a static assertion. Uses static_assert if it is available for use.
Definition: Config.h:136
size_t nlib_strlcpy(char(&s1)[N], const char *s2) noexcept
Calls the nlib_strlcpy(s1, s2, N) function.
Definition: Config.h:806
NLIB_CHECK_RESULT size_t nlib_utf32len(const nlib_utf32_t *str) noexcept
Counts the number of nlib_utf32_t-type characters, not including the null character.
Definition: Config.h:663
errno_t nlib_utf32cpy(nlib_utf32_t *s1, size_t s1max, const nlib_utf32_t *s2) noexcept
The UTF-32 version of the nlib_strcpy function.
Definition: Config.h:672
errno_t nlib_utf8_to_utf32(size_t *utf32count, nlib_utf32_t *utf32, size_t buflen, const char *utf8) noexcept
Converts a UTF-8 string into a UTF-32 string.
errno_t nlib_wcsncpy(wchar_t(&s1)[N], const wchar_t *s2, size_t n) noexcept
The function template version of nlib_wcsncpy.
Definition: Config.h:827
errno_t nlib_memutf32_to_utf8(size_t *to_count, size_t *from_count, char *to, size_t to_size, const nlib_utf32_t *from, size_t from_size) NLIB_NONNULL_5
Converts a UTF-32 string that is not null terminated to a UTF-8 string.
errno_t nlib_strcpy(char(&s1)[N], const char *s2) noexcept
The function template version of nlib_strcpy.
Definition: Config.h:799
#define NLIB_NONNULL
Indicates that you cannot specify NULL for all arguments.
Definition: Platform_unix.h:76
NLIB_CHECK_RESULT int nlib_utf32char_to_utf16(nlib_utf16_t *upper, nlib_utf16_t *lower, nlib_utf32_t utf32) noexcept
Converts a single UTF-32 character into UTF-16.
bool nlib_is_error(const T &obj) noexcept
Returns true when the process result or object status is in an erroneous condition.
Definition: Config.h:922
NLIB_CHECK_RESULT errno_t nlib_utf32cplen(size_t *count, const nlib_utf32_t *str) noexcept
Gets the number of code points in the string.
int errno_t
Indicates with an int-type typedef that a POSIX error value is returned as the return value...
Definition: NMalloc.h:24