Nilorea Library
C utilities for networking, threading, graphics
ENUMERATIONS: quick and clean enum macro set

Macros

#define __N_ENUM_DECLARE_ENUM(MACRO_DEFINITION, enum_name)
 macro for ENUM declaration More...
 
#define __N_ENUM_DECLARE_FUNCTION(__N_ENUM_FUNCTION, enum_name)   __N_ENUM_FUNCTION(enum_name);
 create a getter function More...
 
#define __N_ENUM_DEFINE_FUNCTION_FROMSTRING(MACRO_DEFINITION, enum_name)
 create getter functions fromString More...
 
#define __N_ENUM_DEFINE_FUNCTION_FROMSTRING_EX(MACRO_DEFINITION, enum_name)
 create getter functions fromStringEx More...
 
#define __N_ENUM_DEFINE_FUNCTION_ISSTRINGVALID(MACRO_DEFINITION, enum_name)
 create getter for function isStringValue More...
 
#define __N_ENUM_DEFINE_FUNCTION_ISVALID(MACRO_DEFINITION, enum_name)
 create getter functions is_valid More...
 
#define __N_ENUM_DEFINE_FUNCTION_TOSTRING(MACRO_DEFINITION, enum_name)
 create getter functions toString More...
 
#define __N_ENUM_FUNCTION_FROMSTRING(enum_name)    enum_name N_ENUM_ENTRY(enum_name, fromString)(const char* str_value)
 create a value from string function More...
 
#define __N_ENUM_FUNCTION_FROMSTRING_EX(enum_name)    enum_name N_ENUM_ENTRY(enum_name, fromStringEx)(const char* str_value, int index)
 create a value from string function More...
 
#define __N_ENUM_FUNCTION_ISSTRINGVALID(enum_name)    bool N_ENUM_ENTRY(enum_name, isStringValid)(const char* str_value)
 create a is string valid function More...
 
#define __N_ENUM_FUNCTION_ISVALID(enum_name)    bool N_ENUM_ENTRY(enum_name, isValid)(enum_name value)
 create a test function More...
 
#define __N_ENUM_FUNCTION_TOSTRING(enum_name)    const char* N_ENUM_ENTRY(enum_name, toString)(enum_name value)
 create a to string function More...
 
#define __N_ENUM_MACRO_ENTRY_CASE(element_name)   case element_name:
 utils macro case value More...
 
#define __N_ENUM_MACRO_ENTRY_COMPARE(element_name)   if(!strcmp(#element_name, str_value))
 utils macros string compare More...
 
#define __N_ENUM_MACRO_ENTRY_COMPARE_EX(element_name)   if(!strcmp(#element_name + index, str_value))
 utils macros string ex compare More...
 
#define __N_ENUM_MACRO_ENTRY_TO_ENUM_ELEMENT(element_name, element_value)    element_name = element_value,
 macro to convert N_ENUMS entry to a real ENUM element More...
 
#define __N_ENUM_MACRO_ENTRY_TO_FROMSTRING_COMPARE(element_name, element_value)    __N_ENUM_MACRO_ENTRY_COMPARE(element_name) return element_name;
 macro to convert string to N_ENUMS value More...
 
#define __N_ENUM_MACRO_ENTRY_TO_FROMSTRING_COMPARE_EX(element_name, element_value)    __N_ENUM_MACRO_ENTRY_COMPARE_EX(element_name) return element_name;
 macro to convert string to N_ENUMS value More...
 
#define __N_ENUM_MACRO_ENTRY_TO_ISSTRINGVALID_COMPARE(element_name, element_value)    __N_ENUM_MACRO_ENTRY_COMPARE(element_name) return true;
 macro to test if the string is a valid enum entry More...
 
#define __N_ENUM_MACRO_ENTRY_TO_ISVALID_CASE(element_name, element_value)    __N_ENUM_MACRO_ENTRY_CASE(element_name) return true;
 macro to test N_ENUMS entry More...
 
#define __N_ENUM_MACRO_ENTRY_TO_TOSTRING_CASE(element_name, element_value)    __N_ENUM_MACRO_ENTRY_CASE(element_name) return #element_name;
 macro to convert N_ENUMS entry to a string element More...
 
#define __N_ENUM_MACRO_ENTRY_UNKNOWN_VALUE(enum_name)   __##enum_name##_UNKNOWN_VALUE__
 utils macros unknown value More...
 
#define N_ENUM_DECLARE(MACRO_DEFINITION, enum_name)
 Macro to declare a N_ENUM. More...
 
#define N_ENUM_DEFINE(MACRO_DEFINITION, enum_name)
 Macro to define an N_ENUM. More...
 
#define N_ENUM_ENTRY(class, method)   class##_##method
 helper to build an N_ENUM More...
 

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:39

macro for ENUM declaration

Definition at line 60 of file n_enum.h.

◆ __N_ENUM_DECLARE_FUNCTION

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

create a getter function

Definition at line 71 of file n_enum.h.

◆ __N_ENUM_DEFINE_FUNCTION_FROMSTRING

#define __N_ENUM_DEFINE_FUNCTION_FROMSTRING (   MACRO_DEFINITION,
  enum_name 
)
Value:
{\
}
#define __N_ENUM_FUNCTION_FROMSTRING(enum_name)
create a value from string function
Definition: n_enum.h:82
#define __N_ENUM_MACRO_ENTRY_TO_FROMSTRING_COMPARE(element_name, element_value)
macro to convert string to N_ENUMS value
Definition: n_enum.h:48
#define __N_ENUM_MACRO_ENTRY_UNKNOWN_VALUE(enum_name)
utils macros unknown value
Definition: n_enum.h:35

create getter functions fromString

Definition at line 118 of file n_enum.h.

◆ __N_ENUM_DEFINE_FUNCTION_FROMSTRING_EX

#define __N_ENUM_DEFINE_FUNCTION_FROMSTRING_EX (   MACRO_DEFINITION,
  enum_name 
)
Value:
{\
}
#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:51
#define __N_ENUM_FUNCTION_FROMSTRING_EX(enum_name)
create a value from string function
Definition: n_enum.h:85

create getter functions fromStringEx

Definition at line 125 of file n_enum.h.

◆ __N_ENUM_DEFINE_FUNCTION_ISSTRINGVALID

#define __N_ENUM_DEFINE_FUNCTION_ISSTRINGVALID (   MACRO_DEFINITION,
  enum_name 
)
Value:
{\
return false;\
}
#define __N_ENUM_FUNCTION_ISSTRINGVALID(enum_name)
create a is string valid function
Definition: n_enum.h:79
#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:54

create getter for function isStringValue

Definition at line 111 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:73
#define __N_ENUM_MACRO_ENTRY_TO_ISVALID_CASE(element_name, element_value)
macro to test N_ENUMS entry
Definition: n_enum.h:42

create getter functions is_valid

Definition at line 91 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:45
#define __N_ENUM_FUNCTION_TOSTRING(enum_name)
create a to string function
Definition: n_enum.h:76

create getter functions toString

Definition at line 101 of file n_enum.h.

◆ __N_ENUM_FUNCTION_FROMSTRING

#define __N_ENUM_FUNCTION_FROMSTRING (   enum_name)     enum_name N_ENUM_ENTRY(enum_name, fromString)(const char* str_value)

create a value from string function

Definition at line 82 of file n_enum.h.

◆ __N_ENUM_FUNCTION_FROMSTRING_EX

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

create a value from string function

Definition at line 85 of file n_enum.h.

◆ __N_ENUM_FUNCTION_ISSTRINGVALID

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

create a is string valid function

Definition at line 79 of file n_enum.h.

◆ __N_ENUM_FUNCTION_ISVALID

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

create a test function

Definition at line 73 of file n_enum.h.

◆ __N_ENUM_FUNCTION_TOSTRING

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

create a to string function

Definition at line 76 of file n_enum.h.

◆ __N_ENUM_MACRO_ENTRY_CASE

#define __N_ENUM_MACRO_ENTRY_CASE (   element_name)    case element_name:

utils macro case value

Definition at line 29 of file n_enum.h.

◆ __N_ENUM_MACRO_ENTRY_COMPARE

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

utils macros string compare

Definition at line 31 of file n_enum.h.

◆ __N_ENUM_MACRO_ENTRY_COMPARE_EX

#define __N_ENUM_MACRO_ENTRY_COMPARE_EX (   element_name)    if(!strcmp(#element_name + index, str_value))

utils macros string ex compare

Definition at line 33 of file n_enum.h.

◆ __N_ENUM_MACRO_ENTRY_TO_ENUM_ELEMENT

#define __N_ENUM_MACRO_ENTRY_TO_ENUM_ELEMENT (   element_name,
  element_value 
)     element_name = element_value,

macro to convert N_ENUMS entry to a real ENUM element

Definition at line 39 of file n_enum.h.

◆ __N_ENUM_MACRO_ENTRY_TO_FROMSTRING_COMPARE

#define __N_ENUM_MACRO_ENTRY_TO_FROMSTRING_COMPARE (   element_name,
  element_value 
)     __N_ENUM_MACRO_ENTRY_COMPARE(element_name) return element_name;

macro to convert string to N_ENUMS value

Definition at line 48 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 
)     __N_ENUM_MACRO_ENTRY_COMPARE_EX(element_name) return element_name;

macro to convert string to N_ENUMS value

Definition at line 51 of file n_enum.h.

◆ __N_ENUM_MACRO_ENTRY_TO_ISSTRINGVALID_COMPARE

#define __N_ENUM_MACRO_ENTRY_TO_ISSTRINGVALID_COMPARE (   element_name,
  element_value 
)     __N_ENUM_MACRO_ENTRY_COMPARE(element_name) return true;

macro to test if the string is a valid enum entry

Definition at line 54 of file n_enum.h.

◆ __N_ENUM_MACRO_ENTRY_TO_ISVALID_CASE

#define __N_ENUM_MACRO_ENTRY_TO_ISVALID_CASE (   element_name,
  element_value 
)     __N_ENUM_MACRO_ENTRY_CASE(element_name) return true;

macro to test N_ENUMS entry

Definition at line 42 of file n_enum.h.

◆ __N_ENUM_MACRO_ENTRY_TO_TOSTRING_CASE

#define __N_ENUM_MACRO_ENTRY_TO_TOSTRING_CASE (   element_name,
  element_value 
)     __N_ENUM_MACRO_ENTRY_CASE(element_name) return #element_name;

macro to convert N_ENUMS entry to a string element

Definition at line 45 of file n_enum.h.

◆ __N_ENUM_MACRO_ENTRY_UNKNOWN_VALUE

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

utils macros unknown value

Definition at line 35 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:60

Macro to declare a N_ENUM.

Definition at line 135 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:91

Macro to define an N_ENUM.

Definition at line 146 of file n_enum.h.

◆ N_ENUM_ENTRY

#define N_ENUM_ENTRY (   class,
  method 
)    class##_##method

helper to build an N_ENUM

Definition at line 26 of file n_enum.h.