Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
ENUMERATIONS: quick and clean enum macro set

Macros

#define __N_ENUM_DECLARE_ENUM(MACRO_DEFINITION, enum_name)
 macro for ENUM declaration
#define __N_ENUM_DECLARE_FUNCTION(__N_ENUM_FUNCTION, enum_name)
 create a getter function
#define __N_ENUM_DEFINE_FUNCTION_FROMSTRING(MACRO_DEFINITION, enum_name)
 create getter functions fromString
#define __N_ENUM_DEFINE_FUNCTION_FROMSTRING_EX(MACRO_DEFINITION, enum_name)
 create getter functions fromStringEx
#define __N_ENUM_DEFINE_FUNCTION_ISSTRINGVALID(MACRO_DEFINITION, enum_name)
 create getter for function isStringValue
#define __N_ENUM_DEFINE_FUNCTION_ISVALID(MACRO_DEFINITION, enum_name)
 create getter functions is_valid
#define __N_ENUM_DEFINE_FUNCTION_TOSTRING(MACRO_DEFINITION, enum_name)
 create getter functions toString
#define __N_ENUM_FUNCTION_FROMSTRING(enum_name)
 create a value from string function
#define __N_ENUM_FUNCTION_FROMSTRING_EX(enum_name)
 create a value from string function
#define __N_ENUM_FUNCTION_ISSTRINGVALID(enum_name)
 create a is string valid function
#define __N_ENUM_FUNCTION_ISVALID(enum_name)
 create a test function
#define __N_ENUM_FUNCTION_TOSTRING(enum_name)
 create a to string function
#define __N_ENUM_MACRO_ENTRY_CASE(element_name)
 utils macro case value
#define __N_ENUM_MACRO_ENTRY_COMPARE(element_name)
 utils macros string compare
#define __N_ENUM_MACRO_ENTRY_COMPARE_EX(element_name)
 utils macros string ex compare.
#define __N_ENUM_MACRO_ENTRY_TO_ENUM_ELEMENT(element_name, element_value)
 macro to convert N_ENUMS entry to a real ENUM element
#define __N_ENUM_MACRO_ENTRY_TO_FROMSTRING_COMPARE(element_name, element_value)
 macro to convert string to N_ENUMS value
#define __N_ENUM_MACRO_ENTRY_TO_FROMSTRING_COMPARE_EX(element_name, element_value)
 macro to convert string to N_ENUMS value
#define __N_ENUM_MACRO_ENTRY_TO_ISSTRINGVALID_COMPARE(element_name, element_value)
 macro to test if the string is a valid enum entry
#define __N_ENUM_MACRO_ENTRY_TO_ISVALID_CASE(element_name, element_value)
 macro to test N_ENUMS entry
#define __N_ENUM_MACRO_ENTRY_TO_TOSTRING_CASE(element_name, element_value)
 macro to convert N_ENUMS entry to a string element
#define __N_ENUM_MACRO_ENTRY_UNKNOWN_VALUE(enum_name)
 utils macros unknown value
#define N_ENUM_DECLARE(MACRO_DEFINITION, enum_name)
 Macro to declare a N_ENUM.
#define N_ENUM_DEFINE(MACRO_DEFINITION, enum_name)
 Macro to define an N_ENUM.
#define N_ENUM_ENTRY(class, method)
 helper to build an N_ENUM

Detailed Description

Macro Definition Documentation

◆ __N_ENUM_DECLARE_ENUM

#define __N_ENUM_DECLARE_ENUM ( MACRO_DEFINITION,
enum_name )
Value:
typedef enum enum_name { \
__N_ENUM_MACRO_ENTRY_UNKNOWN_VALUE(enum_name) \
} enum_name;
#define __N_ENUM_MACRO_ENTRY_TO_ENUM_ELEMENT(element_name, element_value)
macro to convert N_ENUMS entry to a real ENUM element
Definition n_enum.h:61

macro for ENUM declaration

Definition at line 87 of file n_enum.h.

◆ __N_ENUM_DECLARE_FUNCTION

#define __N_ENUM_DECLARE_FUNCTION ( __N_ENUM_FUNCTION,
enum_name )
Value:
__N_ENUM_FUNCTION(enum_name);

create a getter function

Definition at line 96 of file n_enum.h.

◆ __N_ENUM_DEFINE_FUNCTION_FROMSTRING

#define __N_ENUM_DEFINE_FUNCTION_FROMSTRING ( MACRO_DEFINITION,
enum_name )
Value:
if (!str_value) return __N_ENUM_MACRO_ENTRY_UNKNOWN_VALUE(enum_name); \
}
#define __N_ENUM_FUNCTION_FROMSTRING(enum_name)
create a value from string function
Definition n_enum.h:107
#define __N_ENUM_MACRO_ENTRY_TO_FROMSTRING_COMPARE(element_name, element_value)
macro to convert string to N_ENUMS value
Definition n_enum.h:72
#define __N_ENUM_MACRO_ENTRY_UNKNOWN_VALUE(enum_name)
utils macros unknown value
Definition n_enum.h:58

create getter functions fromString

Definition at line 141 of file n_enum.h.

◆ __N_ENUM_DEFINE_FUNCTION_FROMSTRING_EX

#define __N_ENUM_DEFINE_FUNCTION_FROMSTRING_EX ( MACRO_DEFINITION,
enum_name )
Value:
if (!str_value) return __N_ENUM_MACRO_ENTRY_UNKNOWN_VALUE(enum_name); \
}
#define __N_ENUM_MACRO_ENTRY_TO_FROMSTRING_COMPARE_EX(element_name, element_value)
macro to convert string to N_ENUMS value
Definition n_enum.h:76
#define __N_ENUM_FUNCTION_FROMSTRING_EX(enum_name)
create a value from string function
Definition n_enum.h:110

create getter functions fromStringEx

Definition at line 148 of file n_enum.h.

◆ __N_ENUM_DEFINE_FUNCTION_ISSTRINGVALID

#define __N_ENUM_DEFINE_FUNCTION_ISSTRINGVALID ( MACRO_DEFINITION,
enum_name )
Value:
if (!str_value) return false; \
return false; \
}
#define __N_ENUM_FUNCTION_ISSTRINGVALID(enum_name)
create a is string valid function
Definition n_enum.h:104
#define __N_ENUM_MACRO_ENTRY_TO_ISSTRINGVALID_COMPARE(element_name, element_value)
macro to test if the string is a valid enum entry
Definition n_enum.h:80

create getter for function isStringValue

Definition at line 134 of file n_enum.h.

◆ __N_ENUM_DEFINE_FUNCTION_ISVALID

#define __N_ENUM_DEFINE_FUNCTION_ISVALID ( MACRO_DEFINITION,
enum_name )
Value:
switch (value) { \
default: \
return false; \
} \
}
#define __N_ENUM_FUNCTION_ISVALID(enum_name)
create a test function
Definition n_enum.h:98
#define __N_ENUM_MACRO_ENTRY_TO_ISVALID_CASE(element_name, element_value)
macro to test N_ENUMS entry
Definition n_enum.h:64

create getter functions is_valid

Definition at line 116 of file n_enum.h.

◆ __N_ENUM_DEFINE_FUNCTION_TOSTRING

#define __N_ENUM_DEFINE_FUNCTION_TOSTRING ( MACRO_DEFINITION,
enum_name )
Value:
switch (value) { \
default: \
return 0; \
} \
}
#define __N_ENUM_MACRO_ENTRY_TO_TOSTRING_CASE(element_name, element_value)
macro to convert N_ENUMS entry to a string element
Definition n_enum.h:68
#define __N_ENUM_FUNCTION_TOSTRING(enum_name)
create a to string function
Definition n_enum.h:101

create getter functions toString

Definition at line 125 of file n_enum.h.

◆ __N_ENUM_FUNCTION_FROMSTRING

#define __N_ENUM_FUNCTION_FROMSTRING ( enum_name)
Value:
enum_name N_ENUM_ENTRY(enum_name, fromString)(const char* str_value)
#define N_ENUM_ENTRY(class, method)
helper to build an N_ENUM
Definition n_enum.h:46

create a value from string function

Definition at line 107 of file n_enum.h.

◆ __N_ENUM_FUNCTION_FROMSTRING_EX

#define __N_ENUM_FUNCTION_FROMSTRING_EX ( enum_name)
Value:
enum_name N_ENUM_ENTRY(enum_name, fromStringEx)(const char* str_value, int index)

create a value from string function

Definition at line 110 of file n_enum.h.

◆ __N_ENUM_FUNCTION_ISSTRINGVALID

#define __N_ENUM_FUNCTION_ISSTRINGVALID ( enum_name)
Value:
bool N_ENUM_ENTRY(enum_name, isStringValid)(const char* str_value)

create a is string valid function

Definition at line 104 of file n_enum.h.

◆ __N_ENUM_FUNCTION_ISVALID

#define __N_ENUM_FUNCTION_ISVALID ( enum_name)
Value:
bool N_ENUM_ENTRY(enum_name, isValid)(enum_name value)

create a test function

Definition at line 98 of file n_enum.h.

◆ __N_ENUM_FUNCTION_TOSTRING

#define __N_ENUM_FUNCTION_TOSTRING ( enum_name)
Value:
const char* N_ENUM_ENTRY(enum_name, toString)(enum_name value)

create a to string function

Definition at line 101 of file n_enum.h.

◆ __N_ENUM_MACRO_ENTRY_CASE

#define __N_ENUM_MACRO_ENTRY_CASE ( element_name)
Value:
case element_name:

utils macro case value

Definition at line 49 of file n_enum.h.

◆ __N_ENUM_MACRO_ENTRY_COMPARE

#define __N_ENUM_MACRO_ENTRY_COMPARE ( element_name)
Value:
if (!strcmp(#element_name, str_value))

utils macros string compare

Definition at line 51 of file n_enum.h.

◆ __N_ENUM_MACRO_ENTRY_COMPARE_EX

#define __N_ENUM_MACRO_ENTRY_COMPARE_EX ( element_name)
Value:
if (!strcmp(&(#element_name)[index], str_value))

utils macros string ex compare.

The subscript spelling is deliberate: #element_name + index is the same pointer, but clang reads adding an int to a string literal as a probable "append" mistake and warns (-Wstring-plus-int) at every expansion, which is once per enum entry.

Definition at line 56 of file n_enum.h.

◆ __N_ENUM_MACRO_ENTRY_TO_ENUM_ELEMENT

#define __N_ENUM_MACRO_ENTRY_TO_ENUM_ELEMENT ( element_name,
element_value )
Value:
element_name = element_value,
static float element_value(const unsigned char *p, int element, const char *dtype)
convert one stored element to a float
Definition n_pth.c:599

macro to convert N_ENUMS entry to a real ENUM element

Definition at line 61 of file n_enum.h.

◆ __N_ENUM_MACRO_ENTRY_TO_FROMSTRING_COMPARE

#define __N_ENUM_MACRO_ENTRY_TO_FROMSTRING_COMPARE ( element_name,
element_value )
Value:
return element_name;
#define __N_ENUM_MACRO_ENTRY_COMPARE(element_name)
utils macros string compare
Definition n_enum.h:51

macro to convert string to N_ENUMS value

Definition at line 72 of file n_enum.h.

◆ __N_ENUM_MACRO_ENTRY_TO_FROMSTRING_COMPARE_EX

#define __N_ENUM_MACRO_ENTRY_TO_FROMSTRING_COMPARE_EX ( element_name,
element_value )
Value:
return element_name;
#define __N_ENUM_MACRO_ENTRY_COMPARE_EX(element_name)
utils macros string ex compare.
Definition n_enum.h:56

macro to convert string to N_ENUMS value

Definition at line 76 of file n_enum.h.

◆ __N_ENUM_MACRO_ENTRY_TO_ISSTRINGVALID_COMPARE

#define __N_ENUM_MACRO_ENTRY_TO_ISSTRINGVALID_COMPARE ( element_name,
element_value )
Value:
return true;

macro to test if the string is a valid enum entry

Definition at line 80 of file n_enum.h.

◆ __N_ENUM_MACRO_ENTRY_TO_ISVALID_CASE

#define __N_ENUM_MACRO_ENTRY_TO_ISVALID_CASE ( element_name,
element_value )
Value:
__N_ENUM_MACRO_ENTRY_CASE(element_name) \
return true;
#define __N_ENUM_MACRO_ENTRY_CASE(element_name)
utils macro case value
Definition n_enum.h:49

macro to test N_ENUMS entry

Definition at line 64 of file n_enum.h.

◆ __N_ENUM_MACRO_ENTRY_TO_TOSTRING_CASE

#define __N_ENUM_MACRO_ENTRY_TO_TOSTRING_CASE ( element_name,
element_value )
Value:
__N_ENUM_MACRO_ENTRY_CASE(element_name) \
return #element_name;

macro to convert N_ENUMS entry to a string element

Definition at line 68 of file n_enum.h.

◆ __N_ENUM_MACRO_ENTRY_UNKNOWN_VALUE

#define __N_ENUM_MACRO_ENTRY_UNKNOWN_VALUE ( enum_name)
Value:
__##enum_name##_UNKNOWN_VALUE__

utils macros unknown value

Definition at line 58 of file n_enum.h.

◆ N_ENUM_DECLARE

#define N_ENUM_DECLARE ( MACRO_DEFINITION,
enum_name )
Value:
__N_ENUM_DECLARE_ENUM(MACRO_DEFINITION, enum_name) \
__N_ENUM_DECLARE_FUNCTION(__N_ENUM_FUNCTION_ISVALID, enum_name) \
__N_ENUM_DECLARE_FUNCTION(__N_ENUM_FUNCTION_ISSTRINGVALID, enum_name) \
__N_ENUM_DECLARE_FUNCTION(__N_ENUM_FUNCTION_TOSTRING, enum_name) \
__N_ENUM_DECLARE_FUNCTION(__N_ENUM_FUNCTION_FROMSTRING, enum_name) \
__N_ENUM_DECLARE_FUNCTION(__N_ENUM_FUNCTION_FROMSTRING_EX, enum_name)
#define __N_ENUM_DECLARE_ENUM(MACRO_DEFINITION, enum_name)
macro for ENUM declaration
Definition n_enum.h:87

Macro to declare a N_ENUM.

Definition at line 158 of file n_enum.h.

◆ N_ENUM_DEFINE

#define N_ENUM_DEFINE ( MACRO_DEFINITION,
enum_name )
Value:
__N_ENUM_DEFINE_FUNCTION_ISVALID(MACRO_DEFINITION, enum_name) \
__N_ENUM_DEFINE_FUNCTION_ISSTRINGVALID(MACRO_DEFINITION, enum_name) \
__N_ENUM_DEFINE_FUNCTION_TOSTRING(MACRO_DEFINITION, enum_name) \
__N_ENUM_DEFINE_FUNCTION_FROMSTRING(MACRO_DEFINITION, enum_name) \
__N_ENUM_DEFINE_FUNCTION_FROMSTRING_EX(MACRO_DEFINITION, enum_name)
#define __N_ENUM_DEFINE_FUNCTION_ISVALID(MACRO_DEFINITION, enum_name)
create getter functions is_valid
Definition n_enum.h:116

Macro to define an N_ENUM.

Definition at line 169 of file n_enum.h.

◆ N_ENUM_ENTRY

#define N_ENUM_ENTRY ( class,
method )
Value:
class##__##method

helper to build an N_ENUM

Definition at line 46 of file n_enum.h.

Referenced by netw_close(), and netw_wait_msg().