nlib
Config.h ファイル

開発環境別の設定が書かれるファイルです。 [詳解]

#include "nn/nlib/Platform.h"
#include "nn/nlib/Config_linux.h"
#include <wchar.h>
#include <utility>

[ソースコード]

クラス

struct  nn::nlib::move_tag
 空の構造体で、関数の引数をムーブすべきことを示すために利用されます。 [詳解]
 
class  nn::nlib::ErrnoT
 errno_tをラップするクラスです。Visual Studioのデバッガ上での表示を改善します。 [詳解]
 
class  nn::nlib::Utf8Ptr
 UTF-8を格納するconst char*をラップするクラスです。Visual Studioのデバッガ上でのUTF-8の表示を改善します。 [詳解]
 
class  nn::nlib::Utf8Array< N >
 UTF-8を格納するcharの配列をラップするクラスです。Visual Studioのデバッガ上でのUTF-8の表示を改善します。 [詳解]
 

名前空間

 nn::nlib
 共通して使われることの多いストリーム関連のクラス群や各種コンテナ、及びガシェットクラスが実装されています。nlib_nsはエイリアスです。
 

マクロ定義

#define NLIB_CEXPR   constexpr
 利用可能であればconstexprが定義されます。そうでない場合は空文字列です。
 
#define NLIB_NOEXCEPT   noexcept
 環境に合わせてnoexcept 又は同等の定義がされます。 [詳解]
 
#define NLIB_TRY   if (true)
 例外が有効なときはtry, そうでなければif (true)が定義されます。
 
#define NLIB_CATCH(x)   if (false)
 例外が有効なときはcatch(x), そうでなければif (true)が定義されます。 [詳解]
 
#define NLIB_THROW
 例外が有効なときはthrow, そうでなければ空白が定義されます。
 
#define NLIB_STATIC_ASSERT(exp)   static_assert((exp), "NLIB_STATIC_ASSERT error: " #exp)
 静的アサートが定義されます。利用可能であればstatic_assertを利用します。 [詳解]
 
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
 TypeName で指定されたクラスのコピーコンストラクタと代入演算子を禁止します。 [詳解]
 
#define NLIB_SAFE_BOOL(class_name, exp)
 クラス内に安全なoperator bool()を定義します。 可能であればC++11のexplicit boolを利用します。 [詳解]
 
#define NLIB_OVERRIDE   override
 利用可能であればoverrideが定義されます。そうでない場合は空文字列です。
 
#define NLIB_FINAL   final
 利用可能であればfinalが定義されます。そうでない場合は空文字列です。
 
#define NLIB_ALIGNAS(x)   alignas(x)
 alignas(x)又は同等の定義がされます。 [詳解]
 
#define NLIB_ALIGNOF(tp)   alignof(tp)
 alignof(tp)又は同等の定義がされます。 [詳解]
 
#define NLIB_NOEMPTYFILE()
 何らかの理由で空となるファイルに記述することで、MSVCのLinker warning 4221を抑制することができます。
 

関数

printf

各種標準ライブラリのprintfの違いを吸収するための関数です。

説明
printfのフォーマット文字列の記述には移植性のために気をつける必要がある場合があります。以下の記述を参考にしてください。
参照
https://google.github.io/styleguide/cppguide.html#64-bit_Portability
http://www.textdrop.net/google-styleguide-ja/cppguide.xml#64%E3%83%93%E3%83%83%E3%83%88%E3%81%AE%E7%A7%BB%E6%A4%8D%E6%80%A7
template<size_t N>
errno_t nlib_vsnprintf (size_t *count, char(&buf)[N], const char *fmt, va_list args) noexcept
 nlib_vsnprintf() の関数テンプレート版です。
 
template<size_t N>
errno_t nlib_snprintf (size_t *count, char(&buf)[N], const char *fmt,...) noexcept
 nlib_snprintf() の関数テンプレート版です。
 
template<size_t N>
errno_t nlib_vsnwprintf (size_t *count, wchar_t(&buf)[N], const wchar_t *fmt, va_list args) noexcept
 nlib_vsnwprintf()の関数テンプレート版です。
 
template<size_t N>
errno_t nlib_snwprintf (size_t *count, wchar_t(&buf)[N], const wchar_t *fmt,...) noexcept
 nlib_snwprintf()の関数テンプレート版です。
 
ヌル終端文字列のための関数
template<size_t N>
errno_t nlib_strcpy (char(&s1)[N], const char *s2) noexcept
 nlib_strcpy()の関数テンプレート版です。
 
template<size_t N>
size_t nlib_strlcpy (char(&s1)[N], const char *s2) noexcept
 nlib_strlcpy(s1, s2, N)を呼び出します。
 
template<size_t N>
errno_t nlib_strncpy (char(&s1)[N], const char *s2, size_t n) noexcept
 nlib_strncpy()の関数テンプレート版です。
 
template<size_t N>
errno_t nlib_wcscpy (wchar_t(&s1)[N], const wchar_t *s2) noexcept
 nlib_wcscpy()の関数テンプレート版です。
 
template<size_t N>
errno_t nlib_wcsncpy (wchar_t(&s1)[N], const wchar_t *s2, size_t n) noexcept
 nlib_wcsncpy()の関数テンプレート版です。
 
ユニコード

nn::nlib::unicode名前空間にもユニコード関連の機能が実装されています。

template<size_t N>
errno_t nlib_wide_to_utf8 (size_t *result, nlib_utf8_t(&utf8)[N], const wchar_t *wcstr) noexcept
 nlib_wide_to_utf8()の関数テンプレート版です。
 
template<size_t N>
errno_t nlib_utf8_to_wide (size_t *result, wchar_t(&wcstr)[N], const nlib_utf8_t *utf8) noexcept
 nlib_utf8_to_wide()の関数テンプレート版です。
 
template<size_t N>
errno_t nlib_utf16_to_utf8 (size_t *utf8count, nlib_utf8_t(&utf8)[N], const nlib_utf16_t *utf16) noexcept
 nlib_utf16_to_utf8()の関数テンプレート版です。
 
template<size_t N>
errno_t nlib_utf8_to_utf16 (size_t *utf16count, nlib_utf16_t(&utf16)[N], const nlib_utf8_t *utf8) noexcept
 nlib_utf8_to_utf16()の関数テンプレート版です。
 
template<size_t N>
errno_t nlib_utf32_to_utf8 (size_t *utf8count, nlib_utf8_t(&utf8)[N], const nlib_utf32_t *utf32) noexcept
 nlib_utf32_to_utf8()の関数テンプレート版です。
 
template<size_t N>
errno_t nlib_utf8_to_utf32 (size_t *utf32count, nlib_utf32_t(&utf32)[N], const nlib_utf8_t *utf8) noexcept
 nlib_utf8_to_utf32()の関数テンプレート版です。
 
template<size_t N>
errno_t nlib_memutf16_to_utf8 (size_t *to_count, size_t *from_count, nlib_utf8_t(&to)[N], const nlib_utf16_t *from, size_t from_size) noexcept
 nlib_memutf16_to_utf8()の関数テンプレート版です。
 
template<size_t N>
errno_t nlib_memutf8_to_utf16 (size_t *to_count, size_t *from_count, nlib_utf16_t(&to)[N], const nlib_utf8_t *from, size_t from_size) noexcept
 nlib_memutf8_to_utf16()の関数テンプレート版です。
 
template<size_t N>
errno_t nlib_memutf32_to_utf8 (size_t *to_count, size_t *from_count, nlib_utf8_t(&to)[N], const nlib_utf32_t *from, size_t from_size) noexcept
 nlib_memutf32_to_utf8()の関数テンプレート版です。
 
template<size_t N>
errno_t nlib_memutf8_to_utf32 (size_t *to_count, size_t *from_count, nlib_utf32_t(&to)[N], const nlib_utf8_t *from, size_t from_size) noexcept
 nlib_memutf8_to_utf32()の関数テンプレート版です。
 
template<size_t N>
errno_t nlib_memwide_to_utf8 (size_t *to_count, size_t *from_count, nlib_utf8_t(&to)[N], const wchar_t *from, size_t from_size) noexcept
 nlib_memwide_to_utf8()の関数テンプレート版です。
 
template<size_t N>
errno_t nlib_memutf8_to_wide (size_t *to_count, size_t *from_count, wchar_t(&to)[N], const nlib_utf8_t *from, size_t from_size) noexcept
 nlib_memutf8_to_wide()の関数テンプレート版です。
 
エラー

エラー値に関するユーティリティです。

template<class T >
bool nlib_is_error (const T &obj) noexcept
 処理の結果やオブジェクトの状態がエラーである場合にtrueを返します。 [詳解]
 

詳解

開発環境別の設定が書かれるファイルです。

Config.h に定義があります。