nlib
misc Library Macros

Macros defined in the misc library. More...

Macros

#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
 Prohibits use of the copy constructor and assignment operator for the class specified by TypeName. More...
 
#define NLIB_NOEMPTYFILE()
 Writing this macro in a file that should be empty for some reasons can prevent the Linker warning 4221 in MSVC from occurring.
 
#define NLIB_FINAL   final
 Defines final if it is available for use. If not, holds an empty string.
 
#define NLIB_OVERRIDE   override
 Defines override if it is available for use. If not, holds an empty string.
 
#define NLIB_STATIC_ASSERT(exp)   static_assert((exp), "NLIB_STATIC_ASSERT error: " #exp)
 Defines a static assertion. Uses static_assert if it is available for use. More...
 
#define NLIB_ALIGNAS(x)   alignas(x)
 Defines alignas(x) or the equivalent. More...
 
#define NLIB_ALIGNOF(tp)   alignof(tp)
 Defines alignof(tp) or the equivalent. More...
 
#define NLIB_CEXPR   constexpr
 Defines constexpr if it is available for use. If not, holds an empty string.
 
#define NLIB_TRY   if (true)
 Defines try if exceptions are enabled. If not, defines if (true).
 
#define NLIB_CATCH(x)   if (false)
 Defines catch(x) if exceptions are enabled. If not, defines if (true). More...
 
#define NLIB_THROW
 Defines throw if exceptions are enabled. If not, defines a space.
 
#define NLIB_SAFE_BOOL(class_name, exp)
 Defines a safe operator bool function in the class. Uses the C++11 explicit bool if it is available for use. More...
 
#define NLIB_NOEXCEPT   noexcept
 Defines noexcept geared to the environment, or the equivalent. More...
 

Macros Used by Nflags

For information about using these macros, see nn::nlib::Nflags.

#define NLIB_FLAGS_DEFINE_bool(opt_name, def_value, desc)
 Defines a command-line option with a bool value. More...
 
#define NLIB_FLAGS_DEFINE_int32(opt_name, def_value, desc)
 Defines a command-line option with a bool value. More...
 
#define NLIB_FLAGS_DEFINE_double(opt_name, def_value, desc)
 Defines a command-line option with a bool value. More...
 
#define NLIB_FLAGS_DEFINE_string(opt_name, def_value, desc)
 Defines a command-line option with a bool value. More...
 
#define NLIB_FLAGS_DECLARE_bool(opt_name)   extern bool NLIB_FLAGS_##opt_name
 Enables the use of an NLIB_FLAGS_option name that was defined in a different place. More...
 
#define NLIB_FLAGS_DECLARE_int32(opt_name)   extern int32_t NLIB_FLAGS_##opt_name
 Enables the use of an NLIB_FLAGS_option name that was defined in a different place. More...
 
#define NLIB_FLAGS_DECLARE_double(opt_name)   extern double NLIB_FLAGS_##opt_name
 Enables the use of an NLIB_FLAGS_option name that was defined in a different place. More...
 
#define NLIB_FLAGS_DECLARE_string(opt_name)   extern const char* NLIB_FLAGS_##opt_name
 Enables the use of an NLIB_FLAGS_option name that was defined in a different place. More...
 

Detailed Description

Macros defined in the misc library.

Description
Mainly defines the macros used when Nflags.h is used.

Macro Definition Documentation

◆ NLIB_ALIGNAS

NLIB_ALIGNAS (   x)    alignas(x)

Defines alignas(x) or the equivalent.

Parameters
[in]xThe number of bytes.
Description
Platform Definition
Win32 __declspec(align(x))
Linux alignas(x) or __attribute__((aligned(x)))
FreeBSD alignas(x)
OS X alignas(x)
CAFE __attribute__((aligned(x)))
CTR __align(x)
Examples:
heap/cachedheap/cachedheap.cpp, heap/nmalloc_leakcheck/nmalloc_leakcheck.cpp, heap/nmalloc_simple/nmalloc_simple.cpp, heap/nmalloc_withstl/nmalloc_withstl.cpp, heap/replace_malloc/replace_malloc.cpp, oss/binarypatch/binarypatch.cpp, oss/readsqldb/readsqldb.cpp, and oss/sqlfromc/sqlfromc.cpp.

Definition at line 239 of file Config.h.

◆ NLIB_ALIGNOF

NLIB_ALIGNOF (   tp)    alignof(tp)

Defines alignof(tp) or the equivalent.

Parameters
[in]tpThe type.
Description
Platform Definition
Win32 __alignof(tp)
Linux alignof(tp) or __alignof__(tp)
FreeBSD alignof(tp)
OS X alignof(tp)
CAFE __alignof__(tp)
CTR __alignof__(tp)
Examples:
heap/gameheap/gameheap_appcode.cpp.

Definition at line 240 of file Config.h.

◆ NLIB_CATCH

NLIB_CATCH (   x)    if (false)

Defines catch(x) if exceptions are enabled. If not, defines if (true).

Parameters
[in]xThe catch parameter.

Definition at line 129 of file Config.h.

◆ NLIB_DISALLOW_COPY_AND_ASSIGN

NLIB_DISALLOW_COPY_AND_ASSIGN (   TypeName)
Value:
TypeName(const TypeName&) = delete; \
void operator=(const TypeName&) = delete

Prohibits use of the copy constructor and assignment operator for the class specified by TypeName.

Parameters
[in]TypeNameThe class name.
Examples:
heap/gameheap/gameheap_appcode.cpp, heap/nmalloc_simple/nmalloc_simple.cpp, misc/threading/simpleringbuffer/simpleringbuffer.cpp, and misc/threading/threadpool/threadpool.cpp.

Definition at line 163 of file Config.h.

◆ NLIB_FLAGS_DECLARE_bool

NLIB_FLAGS_DECLARE_bool (   opt_name)    extern bool NLIB_FLAGS_##opt_name

Enables the use of an NLIB_FLAGS_option name that was defined in a different place.

Parameters
[in]opt_nameAn option name.

Definition at line 163 of file Nflags.h.

◆ NLIB_FLAGS_DECLARE_double

NLIB_FLAGS_DECLARE_double (   opt_name)    extern double NLIB_FLAGS_##opt_name

Enables the use of an NLIB_FLAGS_option name that was defined in a different place.

Parameters
[in]opt_nameAn option name v.

Definition at line 165 of file Nflags.h.

◆ NLIB_FLAGS_DECLARE_int32

NLIB_FLAGS_DECLARE_int32 (   opt_name)    extern int32_t NLIB_FLAGS_##opt_name

Enables the use of an NLIB_FLAGS_option name that was defined in a different place.

Parameters
[in]opt_nameAn option name.

Definition at line 164 of file Nflags.h.

◆ NLIB_FLAGS_DECLARE_string

NLIB_FLAGS_DECLARE_string (   opt_name)    extern const char* NLIB_FLAGS_##opt_name

Enables the use of an NLIB_FLAGS_option name that was defined in a different place.

Parameters
[in]opt_nameAn option name.

Definition at line 166 of file Nflags.h.

◆ NLIB_FLAGS_DEFINE_bool

NLIB_FLAGS_DEFINE_bool (   opt_name,
  def_value,
  desc 
)
Value:
bool NLIB_FLAGS_##opt_name; \
class NLIB_FLAGS_CL_##opt_name { \
public: /* NOLINT */ \
NLIB_FLAGS_CL_##opt_name() { \
::nlib_ns::nflags::AddDefOptBool(#opt_name, def_value, desc, &NLIB_FLAGS_##opt_name); \
} \
} NLIB_FLAGS_CL_##opt_name##_

Defines a command-line option with a bool value.

Parameters
[in]opt_nameAn option name.
[in]def_valueThe default value of the command-line option ( a bool-type value).
[in]descA string literal that serves as the description of the option.
Description
Use this macro to define a variable named NLIB_FLAGS_option name. Specify bool values as follows: --opt_value and --opt_value=[true/false].
Examples:
misc/nflags/nflags.cpp.

Definition at line 124 of file Nflags.h.

◆ NLIB_FLAGS_DEFINE_double

NLIB_FLAGS_DEFINE_double (   opt_name,
  def_value,
  desc 
)
Value:
double NLIB_FLAGS_##opt_name; \
class NLIB_FLAGS_CL_##opt_name { \
public: /* NOLINT */ \
NLIB_FLAGS_CL_##opt_name() { \
::nlib_ns::nflags::AddDefOptDouble(#opt_name, def_value, desc, \
&NLIB_FLAGS_##opt_name); \
} \
} NLIB_FLAGS_CL_##opt_name##_

Defines a command-line option with a bool value.

Parameters
[in]opt_nameAn option name.
[in]def_valueThe default value of the command line option (a double-type value).
[in]descA string literal that serves as the description of the option.
Description
Use this macro to define a variable named NLIB_FLAGS_option name. Specify double-precision floating point type values as follows: --opt_value=1.1.

Definition at line 143 of file Nflags.h.

◆ NLIB_FLAGS_DEFINE_int32

NLIB_FLAGS_DEFINE_int32 (   opt_name,
  def_value,
  desc 
)
Value:
int32_t NLIB_FLAGS_##opt_name; \
class NLIB_FLAGS_CL_##opt_name { \
public: /* NOLINT */ \
NLIB_FLAGS_CL_##opt_name() { \
::nlib_ns::nflags::AddDefOptInt32(#opt_name, def_value, desc, \
&NLIB_FLAGS_##opt_name); \
} \
} NLIB_FLAGS_CL_##opt_name##_

Defines a command-line option with a bool value.

Parameters
[in]opt_nameAn option name.
[in]def_valueThe default value of the command line option (an int32_t-type value).
[in]descA string literal that serves as the description of the option.
Description
Use this macro to define a variable named NLIB_FLAGS_option name. Specify integer values as follows: --opt_value=1.
Examples:
misc/nflags/nflags.cpp.

Definition at line 133 of file Nflags.h.

◆ NLIB_FLAGS_DEFINE_string

NLIB_FLAGS_DEFINE_string (   opt_name,
  def_value,
  desc 
)
Value:
const char* NLIB_FLAGS_##opt_name; \
class NLIB_FLAGS_CL_##opt_name { \
public: /* NOLINT */ \
NLIB_FLAGS_CL_##opt_name() { \
::nlib_ns::nflags::AddDefOptString(#opt_name, def_value, desc, \
&NLIB_FLAGS_##opt_name); \
} \
} NLIB_FLAGS_CL_##opt_name##_

Defines a command-line option with a bool value.

Parameters
[in]opt_nameAn option name.
[in]def_valueThe default value of the command-line option (a string literal).
[in]descA string literal that serves as the description of the option.

Use this macro to define a variable named NLIB_FLAGS_option name. Specify strings as follows: --opt_value=A,B,C.

Examples:
misc/nflags/nflags.cpp.

Definition at line 153 of file Nflags.h.

◆ NLIB_NOEXCEPT

NLIB_NOEXCEPT   noexcept

Defines noexcept geared to the environment, or the equivalent.

Description
It is written as follows.
Platform Definition
Win32 throw()
Linux noexcept or throw()
FreeBSD noexcept
OS X noexcept
CAFE Empty string.
CTR Empty string.
Examples:
heap/gameheap/gameheap.cpp, heap/gameheap/gameheap.h, heap/gameheap/gameheap_appcode.cpp, heap/replace_malloc/replace_malloc.cpp, and misc/threading/threadpool/threadpool.cpp.

Definition at line 99 of file Config.h.

◆ NLIB_SAFE_BOOL

NLIB_SAFE_BOOL (   class_name,
  exp 
)
Value:
public: \
explicit NLIB_ALWAYS_INLINE operator bool() const NLIB_NOEXCEPT { return (exp); }
#define NLIB_ALWAYS_INLINE
Indicates that the compiler is forced to perform inline expansion of functions.
Definition: Platform_unix.h:97
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
Definition: Config.h:99

Defines a safe operator bool function in the class. Uses the C++11 explicit bool if it is available for use.

Parameters
[in]class_nameThe class name.
[in]expEvaluation expression.

Definition at line 178 of file Config.h.

◆ NLIB_STATIC_ASSERT

NLIB_STATIC_ASSERT (   exp)    static_assert((exp), "NLIB_STATIC_ASSERT error: " #exp)

Defines a static assertion. Uses static_assert if it is available for use.

Parameters
[in]expEvaluation expression.
Examples:
heap/gameheap/gameheap.cpp, and misc/threading/simpleringbuffer/simpleringbuffer.cpp.

Definition at line 154 of file Config.h.