ZEDA  1.6.18
zeda_name.h
Go to the documentation of this file.
1 /* ZEDA - Elementary Data and Algorithms
2  * Copyright (C) 1998 Tomomichi Sugihara (Zhidao)
3  */
9 #ifndef __ZEDA_NAME_H__
10 #define __ZEDA_NAME_H__
11 
12 #include <zeda/zeda_misc.h>
13 
15 
36 #ifdef __cplusplus
37 #define Z_NAMED_CLASS public: char *name;
38 #else
39 #define Z_NAMED_CLASS char *name;
40 #endif /* __cplusplus */
41 
43 #define ZNONAME "noname"
44 
45 #define zNamePtr(c) (c)->name
46 #define zNameSetPtr(c,p) ( (c)->name = (p) )
47 #define zName(c) ( (c) && zNamePtr(c) ? zNamePtr(c) : ZNONAME )
48 #define zNameSet(c,n) zNameSetPtr( c, zStrClone(n) )
49 #define zNameFree(c) zFree( zNamePtr(c) )
50 
51 #define zNameFind(array,n,name,ptr) do{\
52  int __z_name_find_id;\
53  (ptr) = NULL;\
54  if( (name) != NULL && strcmp( (name), ZNONAME ) && (array) != NULL )\
55  for( __z_name_find_id=0; __z_name_find_id<(n); __z_name_find_id++ )\
56  if( zNamePtr( &(array)[__z_name_find_id] ) &&\
57  !strcmp( (name), zName( (&(array)[__z_name_find_id]) ) ) ){\
58  (ptr) = &(array)[__z_name_find_id];\
59  break;\
60  }\
61 } while(0)
62 
64 
65 #endif /* __ZEDA_NAME_H__ */
#define __END_DECLS
Definition: zeda_defs.h:30
miscellanies.
#define __BEGIN_DECLS
Definition: zeda_defs.h:26