ZEDA  1.6.18
Macros
zeda_name.h File Reference

common named class. More...

#include <zeda/zeda_misc.h>
Include dependency graph for zeda_name.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define Z_NAMED_CLASS   char *name;
 an inheritance of named class. More...
 
#define ZNONAME   "noname"
 the default name for no-name. More...
 
#define zNamePtr(c)   (c)->name
 
#define zNameSetPtr(c, p)   ( (c)->name = (p) )
 
#define zName(c)   ( (c) && zNamePtr(c) ? zNamePtr(c) : ZNONAME )
 
#define zNameSet(c, n)   zNameSetPtr( c, zStrClone(n) )
 
#define zNameFree(c)   zFree( zNamePtr(c) )
 
#define zNameFind(array, n, name, ptr)
 

Detailed Description

common named class.

Author
Zhidao

Macro Definition Documentation

◆ Z_NAMED_CLASS

#define Z_NAMED_CLASS   char *name;

an inheritance of named class.

Z_NAMED_CLASS macro works as a keyword to inherit a named class, namely, a class which can be identified by a string.

The inheritance can have a string to represent its name, which is referred by zName(). Use zNameSet() to set the name. Use zNameFree() to free the name string.

When searching an instance with a name name from an array of the class, call zNameFind( array, n, name, ptr ); where array is the pointer to array, n is the size of the array, name is a string to be referred, and ptr is a pointer to the element found. If it fails to find a corresponding element, the null pointer set for ptr.

◆ ZNONAME

#define ZNONAME   "noname"

the default name for no-name.

◆ zNamePtr

#define zNamePtr (   c)    (c)->name

◆ zNameSetPtr

#define zNameSetPtr (   c,
 
)    ( (c)->name = (p) )

◆ zName

#define zName (   c)    ( (c) && zNamePtr(c) ? zNamePtr(c) : ZNONAME )

◆ zNameSet

#define zNameSet (   c,
 
)    zNameSetPtr( c, zStrClone(n) )

◆ zNameFree

#define zNameFree (   c)    zFree( zNamePtr(c) )

◆ zNameFind

#define zNameFind (   array,
  n,
  name,
  ptr 
)
Value:
do{\
int __z_name_find_id;\
(ptr) = NULL;\
if( (name) != NULL && strcmp( (name), ZNONAME ) && (array) != NULL )\
for( __z_name_find_id=0; __z_name_find_id<(n); __z_name_find_id++ )\
if( zNamePtr( &(array)[__z_name_find_id] ) &&\
!strcmp( (name), zName( (&(array)[__z_name_find_id]) ) ) ){\
(ptr) = &(array)[__z_name_find_id];\
break;\
}\
} while(0)
#define zName(c)
Definition: zeda_name.h:47
#define zNamePtr(c)
Definition: zeda_name.h:45
#define ZNONAME
the default name for no-name.
Definition: zeda_name.h:43