nlib
Config.h
[詳解]
1 
2 /*---------------------------------------------------------------------------*
3 
4  Project: CrossRoad
5  Copyright (C)2012-2016 Nintendo. All rights reserved.
6 
7  These coded instructions, statements, and computer programs contain
8  proprietary information of Nintendo of America Inc. and/or Nintendo
9  Company Ltd., and are protected by Federal copyright law. They may
10  not be disclosed to third parties or copied or duplicated in any form,
11  in whole or in part, without the prior written consent of Nintendo.
12 
13  *---------------------------------------------------------------------------*/
14 
15 #pragma once
16 #ifndef INCLUDE_NN_NLIB_CONFIG_H_
17 #define INCLUDE_NN_NLIB_CONFIG_H_
18 
19 // NOTE:
20 // DO NOT INCLUDE THE STANDARD C/C++ LIBRARY HEADERS
21 // on the line always included in this header.
22 // This would make it difficult to avoid compile errors
23 // on the environment which lacks the standard headers.
24 
25 #include "nn/nlib/Platform.h"
26 
27 #if defined(_MSC_VER)
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
34 #endif
35 #endif
36 
37 #ifndef NLIB_NAMESPACE_BEGIN
38 #define NLIB_NAMESPACE_BEGIN namespace nn { namespace nlib {
39 #endif
40 
41 #ifndef NLIB_NAMESPACE_END
42 #define NLIB_NAMESPACE_END }}
43 #endif
44 
45 #ifndef NLIB_NS
46 #define NLIB_NS ::nn::nlib
47 #endif
48 
49 NLIB_NAMESPACE_BEGIN
50 NLIB_NAMESPACE_END
51 namespace nlib_ns = NLIB_NS;
52 
53 #if defined(CAFE)
54 # include "nn/nlib/Config_cafe.h" // NOLINT
55 #elif defined(NN_PLATFORM_CTR)
56 # include "nn/nlib/Config_ctr.h" // NOLINT
57 #elif defined(__NX__)
58 # include "nn/nlib/Config_nx.h" // NOLINT
59 #elif defined(_MSC_VER)
60 # include "nn/nlib/Config_win32.h" // NOLINT
61 #elif defined(__CYGWIN__)
62 # include "nn/nlib/Config_cygwin.h" // NOLINT
63 #elif defined(__linux__)
64 # include "nn/nlib/Config_linux.h" // NOLINT
65 #elif defined(__FreeBSD__)
66 # include "nn/nlib/Config_freebsd.h" // NOLINT
67 #elif defined(__APPLE__) && defined(__MACH__)
68 # include "nn/nlib/Config_osx.h" // NOLINT
69 #endif
70 
71 #ifdef NLIB_CXX11_STDLIB_ATOMIC
72 // NOTE: redefine them to use std C++ library for memory barrier
73 # undef NLIB_MEMORY_ORDER_RELEASE
74 # undef NLIB_MEMORY_ORDER_ACQUIRE
75 # undef NLIB_MEMORY_ORDER_ACQ_REL
76 # include <atomic> // NOLINT
77 # define NLIB_MEMORY_ORDER_RELEASE ::std::atomic_thread_fence(::std::memory_order_release)
78 # define NLIB_MEMORY_ORDER_ACQUIRE ::std::atomic_thread_fence(::std::memory_order_acquire)
79 # define NLIB_MEMORY_ORDER_ACQ_REL ::std::atomic_thread_fence(::std::memory_order_acq_rel)
80 #endif
81 
82 #ifdef NLIB_CXX11_RVALUE_REFERENCES
83 # define NLIB_RREF &&
84 # define NLIB_FWD(T, v) std::forward<T>(v)
85 # define NLIB_MOVE(x) std::move(x)
86 #else
87 # define NLIB_RREF &
88 # define NLIB_FWD(T, v) (v)
89 # define NLIB_MOVE(x) (x)
90 #endif
91 
92 #ifdef NLIB_CXX11_CONSTEXPR
93 # define NLIB_CEXPR constexpr
94 #else
95 # define NLIB_CEXPR
96 #endif
97 
98 #ifdef NLIB_DOXYGEN
99 #define NLIB_NOEXCEPT noexcept
100 #endif
101 
102 #ifndef NLIB_NOEXCEPT
103 # define NLIB_NOEXCEPT
104 #elif defined(__INTELLISENSE__)
105 # undef NLIB_NOEXCEPT
106 # define NLIB_NOEXCEPT
107 #endif
108 
109 struct nlib_unwind_exception {}; // Do not throw this directly
110 #ifndef NLIB_RETHROW_UNWIND
111 # define NLIB_RETHROW_UNWIND catch (nlib_unwind_exception&)
112 #endif
113 
114 #ifndef NLIB_ASSERT_NOERR
115 # define NLIB_ASSERT_NOERR(e) NLIB_ASSERT((e) == 0)
116 #endif
117 
118 #ifdef NLIB_EXCEPTION_ENABLED
119 # define NLIB_TRY try
120 # define NLIB_CATCH(x) catch(x)
121 # define NLIB_THROW throw
122 #else
123 # define NLIB_TRY if (true)
124 # define NLIB_CATCH(x) if (false)
125 # define NLIB_THROW
126 #endif
127 
128 #ifndef NLIB_STATIC_ASSERT
129 #ifndef NLIB_CXX11_STATIC_ASSERTIONS
130 NLIB_NAMESPACE_BEGIN
131 namespace detail {
132 template <bool>
133 struct STATIC_ASSERTION_FAILURE;
134 template <>
135 struct STATIC_ASSERTION_FAILURE<true> {};
136 template <int x>
137 struct static_assert_test {};
138 } // namespace detail
139 NLIB_NAMESPACE_END
140 
141 #define NLIB_ASSERT_H_STRING_JOIN_(X, Y) NLIB_ASSERT_H_STRING_JOIN1_(X, Y)
142 #define NLIB_ASSERT_H_STRING_JOIN1_(X, Y) X##Y
143 
144 #define NLIB_STATIC_ASSERT(exp) \
145  typedef ::nlib_ns::detail::static_assert_test< \
146  sizeof(::nlib_ns::detail::STATIC_ASSERTION_FAILURE<(exp) != 0>)> \
147  NLIB_ASSERT_H_STRING_JOIN_(nn_static_assert_typedef_, __LINE__)
148 #else
149 # define NLIB_STATIC_ASSERT(exp) static_assert((exp), "NLIB_STATIC_ASSERT error: " #exp)
150 #endif
151 #endif
152 
153 #ifndef NLIB_CXX11_DEFAULTED_AND_DELETED_FUNCTIONS
154 #define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName) \
155 TypeName(const TypeName&); \
156 void operator=(const TypeName&)
157 #else
158 #define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName) \
159 TypeName(const TypeName&) = delete; \
160 void operator=(const TypeName&) = delete
161 #endif
162 
163 #ifndef NLIB_CXX11_EXPLICIT_CONVERSION_OPERATORS
164 #define NLIB_SAFE_BOOL(class_name, exp) \
165 private: \
166  typedef void (class_name::*bool_type)() const; \
167  void this_type_does_not_support_comparisons() const NLIB_NOEXCEPT {} \
168 public: \
169  operator bool_type() const NLIB_NOEXCEPT { \
170  return (exp) ? &class_name::this_type_does_not_support_comparisons : 0; \
171  }
172 #else
173 #define NLIB_SAFE_BOOL(class_name, exp) \
174 public: \
175  explicit NLIB_ALWAYS_INLINE operator bool() const NLIB_NOEXCEPT { return (exp); }
176 #endif
177 
178 #include <wchar.h> // NOLINT
179 #if defined(WCHAR_MIN) && defined(WCHAR_MAX)
180 # if WCHAR_MAX <= 0xFFFF
181 # define NLIB_WCHAR_SIZE (2)
182 NLIB_STATIC_ASSERT(sizeof(wchar_t) == 2);
183 # else
184 # define NLIB_WCHAR_SIZE (4)
185 NLIB_STATIC_ASSERT(sizeof(wchar_t) == 4);
186 # endif
187 #else
188 # error WCHAR_MIN, WCHAR_MAX not defined
189 #endif
190 
191 #ifndef NLIB_CXX11_NULL_POINTER_CONSTANT
192 NLIB_NAMESPACE_BEGIN
193 class nullptr_t {
194  public:
195  template <class T>
196  operator T*() const {
197  return 0;
198  }
199  template <class C, class T>
200  operator T C::*() const {
201  return 0;
202  }
203 
204  private:
205  void operator&() const; // NOLINT
206 };
207 #ifndef nullptr
208 // if nullptr macro is defined, just use it.
209 const nullptr_t nullptr = {};
210 #endif
211 NLIB_NAMESPACE_END
212 #else
213 #include <cstddef> // NOLINT this is because stddef.h does not define std::nullptr_t
214 NLIB_NAMESPACE_BEGIN
215 typedef std::nullptr_t nullptr_t;
216 NLIB_NAMESPACE_END
217 #endif
218 
219 #ifndef NLIB_CXX11_EXPLICIT_VIRTUAL_OVERRIDES
220 # define NLIB_OVERRIDE
221 # define NLIB_FINAL
222 #else
223 # define NLIB_OVERRIDE override
224 # define NLIB_FINAL final
225 #endif
226 
227 #ifdef NLIB_CXX11_ALIGNMENT_SUPPORT
228 # ifdef NLIB_ALIGNAS
229 # undef NLIB_ALIGNAS
230 # endif
231 # ifdef NLIB_ALIGNOF
232 # undef NLIB_ALIGNOF
233 # endif
234 # define NLIB_ALIGNAS(x) alignas(x)
235 # define NLIB_ALIGNOF(tp) alignof(tp)
236 #endif
237 
238 #ifdef NLIB_CXX11_RVALUE_REFERENCES
239 // for std::move
240 # include <utility> // NOLINT
241 #endif
242 
243 NLIB_NAMESPACE_BEGIN
244 struct move_tag {};
245 NLIB_NAMESPACE_END
246 
247 #define NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \
248  NLIB_ALWAYS_INLINE \
249  tp& assign(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT { /* NOLINT */ \
250  tp().swap(*this); \
251  this->swap(rhs); \
252  return *this; \
253  }
254 
255 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_1(tp, mem1) \
256  NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \
257  NLIB_ALWAYS_INLINE \
258  tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : mem1() /* NOLINT */ \
259  { \
260  this->swap(rhs); \
261  }
262 
263 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_2(tp, mem1, mem2) \
264  NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \
265  NLIB_ALWAYS_INLINE \
266  tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : mem1(), /* NOLINT */ \
267  mem2() \
268  { \
269  this->swap(rhs); \
270  }
271 
272 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_3(tp, mem1, mem2, mem3) \
273  NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \
274  NLIB_ALWAYS_INLINE \
275  tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : /* NOLINT */ \
276  mem1(), \
277  mem2(), \
278  mem3() { \
279  this->swap(rhs); \
280  }
281 
282 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_4(tp, mem1, mem2, mem3, mem4) \
283  NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \
284  NLIB_ALWAYS_INLINE \
285  tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : /* NOLINT */ \
286  mem1(), \
287  mem2(), \
288  mem3(), \
289  mem4() { \
290  this->swap(rhs); \
291  }
292 
293 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_5(tp, mem1, mem2, mem3, mem4, mem5) \
294  NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \
295  NLIB_ALWAYS_INLINE \
296  tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : /* NOLINT */ \
297  mem1(), \
298  mem2(), \
299  mem3(), \
300  mem4(), \
301  mem5() { \
302  this->swap(rhs); \
303  }
304 
305 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) \
306  NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \
307  NLIB_ALWAYS_INLINE \
308  tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : /* NOLINT */ \
309  mem1(), \
310  mem2(), \
311  mem3(), \
312  mem4(), \
313  mem5(), \
314  mem6() { \
315  this->swap(rhs); \
316  }
317 
318 #ifdef NLIB_CXX11_RVALUE_REFERENCES
319 #define NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) \
320  NLIB_ALWAYS_INLINE \
321  tp& operator=(tp&& rhs) NLIB_NOEXCEPT { \
322  tp tmp(std::move(rhs)); \
323  this->swap(tmp); \
324  return *this; \
325  }
326 
327 #ifdef NLIB_CXX11_DELEGATING_CONSTRUCTORS
328 #define NLIB_MOVE_MEMBER_HELPER_(tp) \
329  NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \
330  NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) \
331  NLIB_ALWAYS_INLINE \
332  tp(tp&& rhs) NLIB_NOEXCEPT : tp() { this->swap(rhs); } \
333  NLIB_ALWAYS_INLINE \
334  tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : tp() { this->swap(rhs); } // NOLINT
335 
336 #define NLIB_MOVE_MEMBER_HELPER_1(tp, mem1) NLIB_MOVE_MEMBER_HELPER_(tp)
337 #define NLIB_MOVE_MEMBER_HELPER_2(tp, mem1, mem2) NLIB_MOVE_MEMBER_HELPER_(tp)
338 #define NLIB_MOVE_MEMBER_HELPER_3(tp, mem1, mem2, mem3) NLIB_MOVE_MEMBER_HELPER_(tp)
339 #define NLIB_MOVE_MEMBER_HELPER_4(tp, mem1, mem2, mem3, mem4) NLIB_MOVE_MEMBER_HELPER_(tp)
340 #define NLIB_MOVE_MEMBER_HELPER_5(tp, mem1, mem2, mem3, mem4, mem5) NLIB_MOVE_MEMBER_HELPER_(tp)
341 #define NLIB_MOVE_MEMBER_HELPER_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) \
342  NLIB_MOVE_MEMBER_HELPER_(tp)
343 
344 #else
345 #define NLIB_MOVE_MEMBER_HELPER_1(tp, mem1) \
346  NLIB_ALWAYS_INLINE \
347  tp(tp&& rhs) NLIB_NOEXCEPT : mem1() { this->swap(rhs); } \
348  NLIB_MOVE_MEMBER_HELPER_WITHTAG_1(tp, mem1) \
349  NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp)
350 
351 #define NLIB_MOVE_MEMBER_HELPER_2(tp, mem1, mem2) \
352  NLIB_ALWAYS_INLINE \
353  tp(tp&& rhs) : mem1(), mem2() { this->swap(rhs); } \
354  NLIB_MOVE_MEMBER_HELPER_WITHTAG_2(tp, mem1, mem2) \
355  NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp)
356 
357 #define NLIB_MOVE_MEMBER_HELPER_3(tp, mem1, mem2, mem3) \
358  NLIB_ALWAYS_INLINE \
359  tp(tp&& rhs) : mem1(), mem2(), mem3() { this->swap(rhs); } \
360  NLIB_MOVE_MEMBER_HELPER_WITHTAG_3(tp, mem1, mem2, mem3) \
361  NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp)
362 
363 #define NLIB_MOVE_MEMBER_HELPER_4(tp, mem1, mem2, mem3, mem4) \
364  NLIB_ALWAYS_INLINE \
365  tp(tp&& rhs) : mem1(), mem2(), mem3(), mem4() { this->swap(rhs); } \
366  NLIB_MOVE_MEMBER_HELPER_WITHTAG_4(tp, mem1, mem2, mem3, mem4) \
367  NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp)
368 
369 #define NLIB_MOVE_MEMBER_HELPER_5(tp, mem1, mem2, mem3, mem4, mem5) \
370  NLIB_ALWAYS_INLINE \
371  tp(tp&& rhs) : mem1(), mem2(), mem3(), mem4(), mem5() { this->swap(rhs); } \
372  NLIB_MOVE_MEMBER_HELPER_WITHTAG_5(tp, mem1, mem2, mem3, mem4, mem5) \
373  NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp)
374 
375 #define NLIB_MOVE_MEMBER_HELPER_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) \
376  NLIB_ALWAYS_INLINE \
377  tp(tp&& rhs) : mem1(), mem2(), mem3(), mem4(), mem5(), mem6() { this->swap(rhs); } \
378  NLIB_MOVE_MEMBER_HELPER_WITHTAG_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) \
379  NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp)
380 
381 #endif
382 #else
383 #define NLIB_MOVE_MEMBER_HELPER_1(tp, mem1) NLIB_MOVE_MEMBER_HELPER_WITHTAG_1(tp, mem1)
384 
385 #define NLIB_MOVE_MEMBER_HELPER_2(tp, mem1, mem2) NLIB_MOVE_MEMBER_HELPER_WITHTAG_2(tp, mem1, mem2)
386 
387 #define NLIB_MOVE_MEMBER_HELPER_3(tp, mem1, mem2, mem3) \
388  NLIB_MOVE_MEMBER_HELPER_WITHTAG_3(tp, mem1, mem2, mem3)
389 
390 #define NLIB_MOVE_MEMBER_HELPER_4(tp, mem1, mem2, mem3, mem4) \
391  NLIB_MOVE_MEMBER_HELPER_WITHTAG_4(tp, mem1, mem2, mem3, mem4)
392 
393 #define NLIB_MOVE_MEMBER_HELPER_5(tp, mem1, mem2, mem3, mem4, mem5) \
394  NLIB_MOVE_MEMBER_HELPER_WITHTAG_5(tp, mem1, mem2, mem3, mem4, mem5)
395 
396 #define NLIB_MOVE_MEMBER_HELPER_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) \
397  NLIB_MOVE_MEMBER_HELPER_WITHTAG_6(tp, mem1, mem2, mem3, mem4, mem5, mem6)
398 
399 #endif
400 
401 #ifndef NLIB_MEMCHECKER
402 # define NLIB_MEMCHECKER NLIB_STATIC_ASSERT(sizeof(char) == 1) // NOLINT
403 # define NLIB_MEMCHECKER_START NLIB_STATIC_ASSERT(sizeof(char) == 1) // NOLINT
404 # define NLIB_MEMCHECKER_CHECK true
405 #endif
406 
407 // The following macro "NLIB_NOEMPTYFILE()" can be put into a file
408 // in order suppress the MS Visual C++ Linker warning 4221
409 #ifndef NLIB_NOEMPTYFILE
410 # define NLIB_NOEMPTYFILE()
411 #endif
412 
413 #ifdef NLIB_SOCKET_ENABLED
414 # ifdef _MSC_VER
415 # ifndef NLIB_WINDLL
416 # ifdef _DEBUG
417 # define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER + 50)
418 # else
419 # define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER)
420 # endif
421 # else
422 # ifdef _DEBUG
423 # define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER + 75)
424 # else
425 # define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER + 25)
426 # endif
427 # endif
428 # elif defined(__clang__)
429 # ifdef NDEBUG
430 # define NLIB_SOCKPORT_SAMPLE (18174)
431 # else
432 # define NLIB_SOCKPORT_SAMPLE (18074)
433 # endif
434 # else
435 # ifdef NDEBUG
436 # define NLIB_SOCKPORT_SAMPLE (17874)
437 # else
438 # define NLIB_SOCKPORT_SAMPLE (17974)
439 # endif
440 # endif
441 #endif
442 
443 //
444 // You can reduce the loopcount for the performance test
445 // when it runs on on a continuous integration system like Jenkins.
446 //
447 // for (int i = 0; i < NLIB_TESTLOOPCOUNT(10000); ++i) {
448 // .....
449 // }
450 //
451 #if !defined(NLIB_CIBUILD) && defined(NDEBUG)
452 # define NLIB_TESTLOOPCOUNT(x) (x)
453 #else
454 # define NLIB_TESTLOOPCOUNT(x) (1)
455 #endif
456 
457 #ifndef NLIB_OVERRIDE_NEW
458 #define NLIB_OVERRIDE_NEW \
459  static void* operator new(size_t size); \
460  static void operator delete(void* ptr); \
461  static void* operator new(size_t size, void* ptr) NLIB_NOEXCEPT; \
462  static void operator delete(void* mem, void* ptr) NLIB_NOEXCEPT; \
463  static void* operator new(size_t size, const std::nothrow_t& nt) NLIB_NOEXCEPT; \
464  static void operator delete(void* mem, const std::nothrow_t& nt) NLIB_NOEXCEPT
465 #endif
466 
467 #ifndef NLIB_OVERRIDE_NEW_LIBNEW_CPP
468 #define NLIB_OVERRIDE_NEW_LIBNEW_CPP(type) \
469  void* type::operator new(size_t size) { return ::operator new(size); } \
470  void type::operator delete(void* ptr) { ::operator delete(ptr); } \
471  void* type::operator new(size_t size, void* ptr) NLIB_NOEXCEPT { \
472  return ::operator new(size, ptr); \
473  } \
474  void type::operator delete(void* mem, void* ptr) NLIB_NOEXCEPT { \
475  ::operator delete(mem, ptr); \
476  } \
477  void* type::operator new(size_t size, const std::nothrow_t& nt) NLIB_NOEXCEPT { \
478  return ::operator new(size, nt); \
479  } \
480  void type::operator delete(void* mem, const std::nothrow_t& nt) NLIB_NOEXCEPT { \
481  NLIB_UNUSED(nt); \
482  ::operator delete(mem); \
483  }
484 #endif
485 
486 NLIB_NAMESPACE_BEGIN
488  public:
489  ErrnoT() NLIB_NOEXCEPT {}
490  NLIB_CEXPR ErrnoT(errno_t e) NLIB_NOEXCEPT : vs_errno_(e) {} // NOLINT
491  ErrnoT& operator=(errno_t e) NLIB_NOEXCEPT {
492  vs_errno_ = e;
493  return *this;
494  }
495  operator errno_t() const NLIB_NOEXCEPT { return vs_errno_; }
496  // const char* c_str() const NLIB_NOEXCEPT { return nlib_error_string(vs_errno_); }
497 
498  private:
499  // to suppress the mix-up with boolean value
500  bool operator!() const; // FORBIDDEN
501  // operator bool() const; // FORBIDDEN
502  errno_t vs_errno_;
503 };
504 
506  return lhs.operator errno_t() == rhs;
507 }
508 
510  return rhs.operator errno_t() == lhs;
511 }
512 
514  return lhs.operator errno_t() != rhs;
515 }
516 
518  return rhs.operator errno_t() != lhs;
519 }
520 
522  public:
523  Utf8Ptr() NLIB_NOEXCEPT : str_(NULL) {}
524  Utf8Ptr(const char* str) NLIB_NOEXCEPT : str_(str) {} // NOLINT
525  operator const char*() const NLIB_NOEXCEPT { return str_; }
526  Utf8Ptr& operator=(const char* str) NLIB_NOEXCEPT { str_ = str; return *this; }
527  const char& operator[](size_t idx) const NLIB_NOEXCEPT { return str_[idx]; }
528 
529  private:
530  const char* str_;
531 };
532 
533 template<size_t N>
535  public:
537  operator char*() NLIB_NOEXCEPT { return &str_[0]; }
538  operator const char*() const NLIB_NOEXCEPT { return &str_[0]; }
539  const char& operator[](size_t idx) const NLIB_NOEXCEPT { return str_[idx]; }
540  char& operator[](size_t idx) NLIB_NOEXCEPT { return str_[idx]; }
541 
542  private:
543  char str_[N];
544 };
545 NLIB_NAMESPACE_END
546 
547 #ifdef NLIB_CXX11_NEW_CHARACTER_TYPES
548 typedef char16_t nlib_utf16_t;
549 typedef char32_t nlib_utf32_t;
550 #else
551 typedef uint16_t nlib_utf16_t;
552 typedef uint32_t nlib_utf32_t;
553 #endif
554 
555 //
556 // C++ functions in global namespace
557 //
558 #ifdef __cplusplus
559 
560 extern "C" {
561 
562 // 0 if error
564  nlib_utf32_t* utf32,
565  nlib_utf16_t upper,
566  nlib_utf16_t lower) NLIB_NOEXCEPT NLIB_NONNULL;
567 // 0 if error
569  nlib_utf16_t* upper,
570  nlib_utf16_t* lower,
571  nlib_utf32_t utf32) NLIB_NOEXCEPT NLIB_NONNULL;
572 // 0 if error
574  nlib_utf32_t* utf32,
575  const char* utf8) NLIB_NOEXCEPT NLIB_NONNULL;
576 // 0 if error
578  char (&utf8)[4],
579  nlib_utf32_t utf32) NLIB_NOEXCEPT;
580 
582  size_t* utf8count,
583  char* utf8,
584  size_t buflen,
585  const nlib_utf16_t* utf16) NLIB_NOEXCEPT NLIB_NONNULL_4;
587  size_t* utf16count,
588  nlib_utf16_t* utf16,
589  size_t buflen,
590  const char* utf8) NLIB_NOEXCEPT NLIB_NONNULL_4;
592  size_t* utf8count,
593  char* utf8,
594  size_t buflen,
595  const nlib_utf32_t* utf32) NLIB_NOEXCEPT NLIB_NONNULL_4;
597  size_t* utf32count,
598  nlib_utf32_t* utf32,
599  size_t buflen,
600  const char* utf8) NLIB_NOEXCEPT NLIB_NONNULL_4;
601 
603  size_t* __restrict to_count, size_t* __restrict from_count,
604  char* __restrict to, size_t to_size,
605  const nlib_utf16_t* __restrict from, size_t from_size)
608  size_t* __restrict to_count, size_t* __restrict from_count,
609  nlib_utf16_t* __restrict to, size_t to_size,
610  const char* __restrict from, size_t from_size)
613  size_t* __restrict to_count, size_t* __restrict from_count,
614  char* __restrict to, size_t to_size,
615  const nlib_utf32_t* __restrict from, size_t from_size)
618  size_t* __restrict to_count, size_t* __restrict from_count,
619  nlib_utf32_t* __restrict to, size_t to_size,
620  const char* __restrict from, size_t from_size)
622 
623 NLIB_VIS_PUBLIC_ALT size_t nlib_utf16len_(
624  const uint16_t* str) NLIB_NONNULL;
625 NLIB_VIS_PUBLIC_ALT size_t nlib_utf16nlen_(
626  const uint16_t* str,
627  size_t maxsize) NLIB_NONNULL;
628 NLIB_VIS_PUBLIC errno_t nlib_utf16cpy_(
629  uint16_t* s1,
630  size_t s1max,
631  const uint16_t* s2) NLIB_NONNULL;
632 NLIB_VIS_PUBLIC errno_t nlib_utf16ncpy_(
633  uint16_t* s1,
634  size_t s1max,
635  const uint16_t* s2,
636  size_t n) NLIB_NONNULL;
638  const nlib_utf16_t* str) NLIB_NOEXCEPT {
639  return nlib_utf16len_(reinterpret_cast<const uint16_t*>(str));
640 }
642  const nlib_utf16_t* str,
643  size_t maxsize) NLIB_NOEXCEPT {
644  return nlib_utf16nlen_(reinterpret_cast<const uint16_t*>(str), maxsize);
645 }
647  nlib_utf16_t* s1,
648  size_t s1max,
649  const nlib_utf16_t* s2) NLIB_NOEXCEPT {
650  return nlib_utf16cpy_(reinterpret_cast<uint16_t*>(s1), s1max,
651  reinterpret_cast<const uint16_t*>(s2));
652 }
654  nlib_utf16_t* s1,
655  size_t s1max,
656  const nlib_utf16_t* s2,
657  size_t n) NLIB_NOEXCEPT {
658  return nlib_utf16ncpy_(reinterpret_cast<uint16_t*>(s1), s1max,
659  reinterpret_cast<const uint16_t*>(s2), n);
660 }
661 
662 NLIB_VIS_PUBLIC_ALT size_t nlib_utf32len_(
663  const uint32_t* str) NLIB_NONNULL;
664 NLIB_VIS_PUBLIC_ALT size_t nlib_utf32nlen_(
665  const uint32_t* str,
666  size_t maxsize) NLIB_NONNULL;
667 NLIB_VIS_PUBLIC errno_t nlib_utf32cpy_(
668  uint32_t* s1,
669  size_t s1max,
670  const uint32_t* s2) NLIB_NONNULL;
671 NLIB_VIS_PUBLIC errno_t nlib_utf32ncpy_(
672  uint32_t* s1,
673  size_t s1max,
674  const uint32_t* s2,
675  size_t n) NLIB_NONNULL;
677  const nlib_utf32_t* str) NLIB_NOEXCEPT {
678  return nlib_utf32len_(reinterpret_cast<const uint32_t*>(str));
679 }
681  const nlib_utf32_t* str,
682  size_t maxsize) NLIB_NOEXCEPT {
683  return nlib_utf32nlen_(reinterpret_cast<const uint32_t*>(str), maxsize);
684 }
686  nlib_utf32_t* s1,
687  size_t s1max,
688  const nlib_utf32_t* s2) NLIB_NOEXCEPT {
689  return nlib_utf32cpy_(reinterpret_cast<uint32_t*>(s1), s1max,
690  reinterpret_cast<const uint32_t*>(s2));
691 }
693  nlib_utf32_t* s1,
694  size_t s1max,
695  const nlib_utf32_t* s2,
696  size_t n) NLIB_NOEXCEPT {
697  return nlib_utf32ncpy_(reinterpret_cast<uint32_t*>(s1), s1max,
698  reinterpret_cast<const uint32_t*>(s2), n);
699 }
700 
701 NLIB_VIS_PUBLIC_ALT NLIB_CHECK_RESULT errno_t nlib_utf16cplen_ex_(
702  size_t* count,
703  size_t* len,
704  const uint16_t* str) NLIB_NONNULL_3;
705 
707  size_t* count,
708  const nlib_utf16_t* str) NLIB_NOEXCEPT {
709  return nlib_utf16cplen_ex_(count, NULL, reinterpret_cast<const uint16_t*>(str));
710 }
712  size_t* count,
713  size_t* len,
714  const nlib_utf16_t* str) NLIB_NOEXCEPT {
715  return nlib_utf16cplen_ex_(count, len, reinterpret_cast<const uint16_t*>(str));
716 }
718  size_t* count,
719  const nlib_utf32_t* str) NLIB_NOEXCEPT NLIB_NONNULL_2;
720 
721 } // extern "C"
722 
723 template <size_t N>
725  size_t* count,
726  char (&buf)[N],
727  _Printf_format_string_ const char* fmt,
728  va_list args) NLIB_NOEXCEPT {
729  return nlib_vsnprintf(count, buf, N, fmt, args);
730 }
731 
732 template<size_t N>
734  size_t* count,
735  char (&buf)[N],
736  _Printf_format_string_ const char* fmt,
737  ...) NLIB_NOEXCEPT {
738  va_list args;
739  va_start(args, fmt);
740  errno_t e = nlib_vsnprintf(count, buf, N, fmt, args);
741  va_end(args);
742  return e;
743 }
744 
745 template <size_t N>
747  size_t* count,
748  wchar_t (&buf)[N],
749  _Printf_format_string_ const wchar_t* fmt,
750  va_list args) NLIB_NOEXCEPT {
751  return nlib_vsnwprintf(count, buf, N, fmt, args);
752 }
753 
754 template<size_t N>
756  size_t* count,
757  wchar_t(&buf)[N],
758  _Printf_format_string_ const wchar_t* fmt,
759  ...) NLIB_NOEXCEPT {
760  va_list args;
761  va_start(args, fmt);
762  errno_t e = nlib_vsnwprintf(count, buf, N, fmt, args);
763  va_end(args);
764  return e;
765 }
766 
767 template <size_t N>
768 NLIB_ALWAYS_INLINE errno_t nlib_vsnprintf_fallback(
769  size_t* count,
770  char (&buf)[N],
771  _Printf_format_string_ const char* fmt,
772  va_list args) NLIB_NOEXCEPT {
773  return nlib_vsnprintf_fallback(count, buf, N, fmt, args);
774 }
775 
776 template<size_t N>
777 inline NLIB_VIS_HIDDEN errno_t nlib_snprintf_fallback(
778  size_t* count,
779  char (&buf)[N],
780  _Printf_format_string_ const char* fmt,
781  ...) NLIB_NOEXCEPT {
782  va_list args;
783  va_start(args, fmt);
784  errno_t e = nlib_vsnprintf_fallback(count, buf, N, fmt, args);
785  va_end(args);
786  return e;
787 }
788 
789 template <size_t N>
790 NLIB_ALWAYS_INLINE errno_t nlib_vsnwprintf_fallback(
791  size_t* count,
792  wchar_t (&buf)[N],
793  _Printf_format_string_ const wchar_t* fmt,
794  va_list args) NLIB_NOEXCEPT {
795  return nlib_vsnwprintf_fallback(count, buf, N, fmt, args);
796 }
797 
798 template<size_t N>
799 inline NLIB_VIS_HIDDEN errno_t nlib_snwprintf_fallback(
800  size_t* count,
801  wchar_t(&buf)[N],
802  _Printf_format_string_ const wchar_t* fmt,
803  ...) NLIB_NOEXCEPT {
804  va_list args;
805  va_start(args, fmt);
806  errno_t e = nlib_vsnwprintf_fallback(count, buf, N, fmt, args);
807  va_end(args);
808  return e;
809 }
810 
811 template <size_t N>
813  char (&s1)[N],
814  const char* s2) NLIB_NOEXCEPT {
815  return nlib_strcpy(&s1[0], N, s2);
816 }
817 
818 template<size_t N>
819 NLIB_ALWAYS_INLINE size_t nlib_strlcpy(char (&s1)[N], const char* s2) NLIB_NOEXCEPT {
820  // CTR armcc needs cast
821  return nlib_strlcpy((char*)&s1[0], (const char*)s2, N); // NOLINT
822 }
823 
824 template <size_t N>
826  char (&s1)[N],
827  const char* s2,
828  size_t n) NLIB_NOEXCEPT {
829  return nlib_strncpy(&s1[0], N, s2, n);
830 }
831 
832 template <size_t N>
834  wchar_t (&s1)[N],
835  const wchar_t* s2) NLIB_NOEXCEPT {
836  return nlib_wcscpy(&s1[0], N, s2);
837 }
838 
839 template <size_t N>
841  wchar_t (&s1)[N],
842  const wchar_t* s2,
843  size_t n) NLIB_NOEXCEPT {
844  return nlib_wcsncpy(&s1[0], N, s2, n);
845 }
846 
847 template<size_t N>
848 NLIB_ALWAYS_INLINE errno_t nlib_wide_to_utf8(size_t* result, char (&utf8)[N],
849  const wchar_t* wcstr) NLIB_NOEXCEPT {
850  return nlib_wide_to_utf8(result, &utf8[0], N, wcstr);
851 }
852 
853 template<size_t N>
854 NLIB_ALWAYS_INLINE errno_t nlib_utf8_to_wide(size_t* result, wchar_t (&wcstr)[N],
855  const char* utf8) NLIB_NOEXCEPT {
856  return nlib_utf8_to_wide(result, &wcstr[0], N, utf8);
857 }
858 
859 template<size_t N>
860 NLIB_ALWAYS_INLINE errno_t nlib_utf16_to_utf8(size_t* utf8count, char (&utf8)[N],
861  const nlib_utf16_t* utf16) NLIB_NOEXCEPT {
862  return nlib_utf16_to_utf8(utf8count, &utf8[0], N, utf16);
863 }
864 
865 template<size_t N>
866 NLIB_ALWAYS_INLINE errno_t nlib_utf8_to_utf16(size_t* utf16count, nlib_utf16_t (&utf16)[N],
867  const char* utf8) NLIB_NOEXCEPT {
868  return nlib_utf8_to_utf16(utf16count, &utf16[0], N, utf8);
869 }
870 
871 template<size_t N>
872 NLIB_ALWAYS_INLINE errno_t nlib_utf32_to_utf8(size_t* utf8count, char (&utf8)[N],
873  const nlib_utf32_t* utf32) NLIB_NOEXCEPT {
874  return nlib_utf32_to_utf8(utf8count, &utf8[0], N, utf32);
875 }
876 
877 template<size_t N>
879  const char* utf8) NLIB_NOEXCEPT {
880  return nlib_utf8_to_utf32(utf32count, &utf32[0], N, utf8);
881 }
882 
883 template<size_t N>
885  size_t* to_count, size_t* from_count,
886  char (&to)[N],
887  const nlib_utf16_t* from, size_t from_size) NLIB_NOEXCEPT {
888  return nlib_memutf16_to_utf8(to_count, from_count, &to[0], N, from, from_size);
889 }
890 template<size_t N>
892  size_t* to_count, size_t* from_count,
893  nlib_utf16_t (&to)[N],
894  const char* from, size_t from_size) NLIB_NOEXCEPT {
895  return nlib_memutf8_to_utf16(to_count, from_count, &to[0], N, from, from_size);
896 }
897 template<size_t N>
899  size_t* to_count, size_t* from_count,
900  char (&to)[N],
901  const nlib_utf32_t* from, size_t from_size) NLIB_NOEXCEPT {
902  return nlib_memutf32_to_utf8(to_count, from_count, &to[0], N, from, from_size);
903 }
904 template<size_t N>
906  size_t* to_count, size_t* from_count,
907  nlib_utf32_t (&to)[N],
908  const char* from, size_t from_size) NLIB_NOEXCEPT {
909  return nlib_memutf8_to_utf32(to_count, from_count, &to[0], N, from, from_size);
910 }
911 template<size_t N>
913  size_t* to_count, size_t* from_count,
914  char (&to)[N],
915  const wchar_t* from, size_t from_size) NLIB_NOEXCEPT {
916  return nlib_memwide_to_utf8(to_count, from_count, &to[0], N, from, from_size);
917 }
918 template<size_t N>
920  size_t* to_count, size_t* from_count,
921  wchar_t (&to)[N],
922  const char* from, size_t from_size) NLIB_NOEXCEPT {
923  return nlib_memutf8_to_wide(to_count, from_count, &to[0], N, from, from_size);
924 }
925 
926 #if !defined(NN_PLATFORM_CTR) && !defined(CAFE)
927 // This may throw C++ exception defined by nlib, See also nlib_thread_exit()
929 #endif
930 
931 NLIB_ALWAYS_INLINE bool nlib_is_error(bool result) NLIB_NOEXCEPT { return !result; }
932 NLIB_ALWAYS_INLINE bool nlib_is_error(errno_t e) NLIB_NOEXCEPT { return e != 0; }
933 NLIB_ALWAYS_INLINE bool nlib_is_error(const NLIB_NS::ErrnoT& e) NLIB_NOEXCEPT { return e != 0; }
934 template<class T>
936 #ifdef NLIB_CXX11_EXPLICIT_CONVERSION_OPERATORS
937  return !obj.operator bool();
938 #else
939  return !obj;
940 #endif
941 }
942 #ifdef NLIB_CXX11_DEFAULTED_AND_DELETED_FUNCTIONS
943 template<class T>
944 bool nlib_is_error(T*) = delete; // NOLINT
945 #else
946 template<class T>
947 bool nlib_is_error(T*); // NOLINT
948 #endif
949 
950 #endif // __cplusplus
951 
952 // nlib_ns::utf16_t, nlib_ns::utf32_t might be deprecated in the future
953 // use nlib_utf16_t, nlib_utf32_t instead
954 NLIB_NAMESPACE_BEGIN
955 typedef nlib_utf16_t utf16_t;
956 typedef nlib_utf32_t utf32_t;
957 NLIB_NAMESPACE_END
958 
959 #if defined(_MSC_VER)
960 #if defined(n_EXPORTS)
961 #undef NLIB_VIS_PUBLIC
962 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT
963 #elif defined(nx_misc_EXPORTS)
964 #undef NLIB_VIS_PUBLIC
965 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT
966 #endif
967 #endif
968 
969 #endif // INCLUDE_NN_NLIB_CONFIG_H_
#define NLIB_NORETURN
関数がリターンしないことを示します。
errno_t nlib_utf8_to_utf16(size_t *utf16count, nlib_utf16_t *utf16, size_t buflen, const char *utf8) noexcept
UTF-8文字列からUTF-16文字列に変換します。UTF-16文字列はヌル終端されます。
UTF-8を格納するcharの配列をラップするクラスです。Visual Studioのデバッガ上でのUTF-8の表示を改善します...
Definition: Config.h:534
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
ヌル終端しないUTF-8文字列をUTF-16文字列に変換します。
void nlib_thread_exit_cpp() NLIB_NORETURN
呼び出しスレッドを終了します。
#define NLIB_ALWAYS_INLINE
コンパイラに関数をインライン展開するように強く示します。
Definition: Platform_unix.h:95
static errno_t nlib_utf16cplen_ex(size_t *count, size_t *len, const nlib_utf16_t *str) noexcept
文字列中のコードポイントの数を取得します。
Definition: Config.h:711
errno_t nlib_vsnwprintf(size_t *count, wchar_t(&buf)[N], const wchar_t *fmt, va_list args) noexcept
nlib_vsnwprintf()の関数テンプレート版です。
Definition: Config.h:746
nlib_utf16_t utf16_t
UTF16の文字に対する型です。 nlib_utf16_tにtypedefされています。
Definition: Config.h:955
errno_t nlib_utf8_to_wide(size_t *result, wchar_t(&wcstr)[N], const char *utf8) noexcept
nlib_utf8_to_wide()の関数テンプレート版です。
Definition: Config.h:854
NLIB_CHECK_RESULT int nlib_utf32char_to_utf8(char(&utf8)[4], nlib_utf32_t utf32) noexcept
1文字のUTF-32をUTF-8に変換します。
#define NLIB_NONNULL_1
1番目の引数にNULLを指定することができないことを示します。
errno_t nlib_strncpy(char(&s1)[N], const char *s2, size_t n) noexcept
nlib_strncpy()の関数テンプレート版です。
Definition: Config.h:825
#define NLIB_CHECK_RESULT
関数の呼び出し元が戻り値をチェックする必要があることを示します。
bool operator==(const HeapHash &rhs, const HeapHash &lhs)
2つのサマリを比較して等価ならば、trueを返します。
Definition: NMalloc.h:123
bool operator!=(const HeapHash &rhs, const HeapHash &lhs)
2つのサマリを比較して等価でなければ、trueを返します。
Definition: NMalloc.h:128
errno_t nlib_snwprintf(size_t *count, wchar_t(&buf)[N], const wchar_t *fmt,...) noexcept
nlib_snwprintf()の関数テンプレート版です。
Definition: Config.h:755
#define NLIB_VIS_HIDDEN
関数やクラス等のシンボルをライブラリの外部に公開しません。
Definition: Platform_unix.h:86
static NLIB_CHECK_RESULT size_t nlib_utf16nlen(const nlib_utf16_t *str, size_t maxsize) noexcept
nlib_strnlen()のUTF-16版です。
Definition: Config.h:641
基本的なAPIがCリンケージで宣言されています。
#define NLIB_VIS_PUBLIC
関数やクラス等のシンボルをライブラリの外部に公開します。
Definition: Platform_unix.h:87
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
nlib_memutf8_to_wide()の関数テンプレート版です。
Definition: Config.h:919
errno_t nlib_snprintf(size_t *count, char(&buf)[N], const char *fmt,...) noexcept
nlib_snprintf() の関数テンプレート版です。
Definition: Config.h:733
#define NLIB_NONNULL_2
2番目の引数にNULLを指定することができないことを示します。
uint32_t nlib_utf32_t
char32_tが利用できる場合はchar32_tに、そうでない場合はuint32_tにtypedefされます。 ...
Definition: Config.h:552
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
ヌル終端しないUTF-16文字列をUTF-8文字列に変換します。
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
nlib_memwide_to_utf8()の関数テンプレート版です。
Definition: Config.h:912
static errno_t nlib_utf16ncpy(nlib_utf16_t *s1, size_t s1max, const nlib_utf16_t *s2, size_t n) noexcept
nlib_strcpy()のUTF-16版です。
Definition: Config.h:653
空の構造体で、関数の引数をムーブすべきことを示すために利用されます。
Definition: Config.h:244
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
ヌル終端しないUTF-8文字列をUTF-32文字列に変換します。
uint16_t nlib_utf16_t
char16_tが利用できる場合はchar16_tに、そうでない場合はuint16_tにtypedefされます。 ...
Definition: Config.h:551
errno_t nlib_wide_to_utf8(size_t *result, char(&utf8)[N], const wchar_t *wcstr) noexcept
nlib_wide_to_utf8()の関数テンプレート版です。
Definition: Config.h:848
NLIB_CHECK_RESULT int nlib_utf8_to_utf32char(nlib_utf32_t *utf32, const char *utf8) noexcept
UTF-8を1文字分のUTF-32に変換します。
static errno_t nlib_utf16cplen(size_t *count, const nlib_utf16_t *str) noexcept
文字列中のコードポイントの数を取得します。
Definition: Config.h:706
errno_t nlib_utf32_to_utf8(size_t *utf8count, char *utf8, size_t buflen, const nlib_utf32_t *utf32) noexcept
UTF-32文字列からUTF-8文字列に変換します。
errno_tをラップするクラスです。Visual Studioのデバッガ上での表示を改善します。
Definition: Config.h:487
共通して使われることの多いストリーム関連のクラス群や各種コンテナ、及びガシェットクラスが実装されてい...
Definition: Base64.h:21
static NLIB_CHECK_RESULT size_t nlib_utf32nlen(const nlib_utf32_t *str, size_t maxsize) noexcept
nlib_strnlen()のUTF-32版です。
Definition: Config.h:680
#define NLIB_NOEXCEPT
環境に合わせてnoexcept 又は同等の定義がされます。
Definition: Config.h:99
#define NLIB_CEXPR
利用可能であればconstexprが定義されます。そうでない場合は空文字列です。
Definition: Config.h:93
static errno_t nlib_utf32ncpy(nlib_utf32_t *s1, size_t s1max, const nlib_utf32_t *s2, size_t n) noexcept
nlib_strcpy()のUTF-32版です。
Definition: Config.h:692
UTF-8を格納するconst char*をラップするクラスです。Visual Studioのデバッガ上でのUTF-8の表示を改善しま...
Definition: Config.h:521
nlib_utf32_t utf32_t
UTF32の文字に対する型です。 nlib_utf32_tにtypedefされています。
Definition: Config.h:956
NLIB_CHECK_RESULT int nlib_utf16_to_utf32char(nlib_utf32_t *utf32, nlib_utf16_t upper, nlib_utf16_t lower) noexcept
1つのコードポイントをUTF-16からUTF-32に変換します。
#define NLIB_NONNULL_4
4番目の引数にNULLを指定することができないことを示します。
errno_t nlib_vsnprintf(size_t *count, char(&buf)[N], const char *fmt, va_list args) noexcept
nlib_vsnprintf() の関数テンプレート版です。
Definition: Config.h:724
static errno_t nlib_utf16cpy(nlib_utf16_t *s1, size_t s1max, const nlib_utf16_t *s2) noexcept
nlib_strcpy()のUTF-16版です。
Definition: Config.h:646
errno_t nlib_wcscpy(wchar_t(&s1)[N], const wchar_t *s2) noexcept
nlib_wcscpy()の関数テンプレート版です。
Definition: Config.h:833
static NLIB_CHECK_RESULT size_t nlib_utf16len(const nlib_utf16_t *str) noexcept
ヌル文字を含まないnlib_utf16_tの数を数えます。
Definition: Config.h:637
#define NLIB_NONNULL_5
5番目の引数にNULLを指定することができないことを示します。
#define NLIB_FINAL
利用可能であればfinalが定義されます。そうでない場合は空文字列です。
Definition: Config.h:224
errno_t nlib_utf16_to_utf8(size_t *utf8count, char *utf8, size_t buflen, const nlib_utf16_t *utf16) noexcept
UTF-16文字列からUTF-8文字列に変換します。
#define NLIB_NONNULL_3
3番目の引数にNULLを指定することができないことを示します。
#define NLIB_STATIC_ASSERT(exp)
静的アサートが定義されます。利用可能であればstatic_assertを利用します。
Definition: Config.h:149
size_t nlib_strlcpy(char(&s1)[N], const char *s2) noexcept
nlib_strlcpy(s1, s2, N)を呼び出します。
Definition: Config.h:819
static NLIB_CHECK_RESULT size_t nlib_utf32len(const nlib_utf32_t *str) noexcept
ヌル文字を含まないnlib_utf32_tの数を数えます。
Definition: Config.h:676
static errno_t nlib_utf32cpy(nlib_utf32_t *s1, size_t s1max, const nlib_utf32_t *s2) noexcept
nlib_strcpy()のUTF-32版です。
Definition: Config.h:685
errno_t nlib_utf8_to_utf32(size_t *utf32count, nlib_utf32_t *utf32, size_t buflen, const char *utf8) noexcept
UTF-8文字列からUTF-32文字列に変換します。
errno_t nlib_wcsncpy(wchar_t(&s1)[N], const wchar_t *s2, size_t n) noexcept
nlib_wcsncpy()の関数テンプレート版です。
Definition: Config.h:840
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
ヌル終端しないUTF-32文字列をUTF-8文字列に変換します。
errno_t nlib_strcpy(char(&s1)[N], const char *s2) noexcept
nlib_strcpy()の関数テンプレート版です。
Definition: Config.h:812
#define NLIB_NONNULL
全ての引数にNULLを指定することができないことを示します。
NLIB_CHECK_RESULT int nlib_utf32char_to_utf16(nlib_utf16_t *upper, nlib_utf16_t *lower, nlib_utf32_t utf32) noexcept
1つのUTF-32文字をUTF-16に変換します。
bool nlib_is_error(const T &obj) noexcept
処理の結果やオブジェクトの状態がエラーである場合にtrueを返します。
Definition: Config.h:935
NLIB_CHECK_RESULT errno_t nlib_utf32cplen(size_t *count, const nlib_utf32_t *str) noexcept
文字列中のコードポイントの数を取得します。
int errno_t
intのtypedefで、戻り値としてPOSIXのエラー値を返すことを示します。
Definition: NMalloc.h:37