datagen.h

00001 
00004 #ifndef DATAGEN_H
00005 #define DATAGEN_H
00006 
00013 #include "ctl/ctldef.h"
00014 #include "ctl/gstring.h"
00015 #include "ctl/algorithm.h"
00016 #include "ctl/xml.h"
00017 #include "ctl/serial.h"
00018 #include "ctl/record.h"
00019 
00020 /****************************************************************************
00021 
00022 The functions we're looking for
00023 
00024 ****************************************************************************/
00025 
00031 #define ctl_datagen_declare_functions(label)\
00032     /* Used to clear up certain conditions so we can skip iterations over parts of known size */\
00033     extern const bool ppConcat(label,_isscalar);\
00034     /* Initialize this record to a known, default state */\
00035     void ppConcat(label,_init)( label* self );\
00036     /* Replicate a record, copying from 'src' to 'dst' */\
00037     void ppConcat(label,_copy)( label* dst, const label* src );\
00038     /* Move contents from 'src' to 'dst', leaving 'src' uninitialized. */\
00039     void ppConcat(label,_move)( label* dst, label* src );\
00040     /* Swap contents of two records */\
00041     void ppConcat(label,_swap)( label* p1, label* p2 );\
00042     /* Declare array sort for this record */\
00043     ctl_array_qsort_declare(label);\
00044     /* Compare this record to another record, return <0 if p1<p2, >0 if p2>p1 and 0 if they're equal */\
00045     int ppConcat(label,_compare)( const label* p1, const label* p2 );\
00046     /* Compare this record to another record, return >0 if p1<p2, <0 if p2>p1 and 0 if they're equal */\
00047     int ppConcat(label,_rcompare)( const label* p1, const label* p2 );\
00048     /* Destroy this record, freeing any contained data */\
00049     void ppConcat(label,_destroy)( label* self );\
00050     /* Determine if a record is valid-looking; all validated members in expected range */\
00051     bool ppConcat(label,_valid)( const label* self );\
00052     /* Determine total memory footprint of this record */\
00053     size_t ppConcat(label,_size)( const label* self );\
00054     /* Determine total size of this record as stingy serial data */\
00055     size_t ppConcat(label,_serial_size)( const label* self );\
00056     /* Write data to a stingy serial record */\
00057     void ppConcat(label,_serial_write)( const label* self, ctl_serial* serial );\
00058     /* Read data from a stingy serial record */\
00059     void ppConcat(label,_serial_read)( label* self, ctl_serial* serial );\
00060     /* Determine total size of this record as robust/archive serial data */\
00061     size_t ppConcat(label,_record_size)( const label* self, const char* szlabel );\
00062     /* Write data to a robust binary serial record */\
00063     void ppConcat(label,_record_write)( const label* self, ctl_serial* serial, const char* szlabel );\
00064     /* Read data from a robust/archive binary serial record */\
00065     bool ppConcat(label,_record_read)( label* self, ctl_serial* serial, const char* szlabel );\
00066     /* Read data from an XML record */\
00067     bool ppConcat(label,_xml_read)( label* self, ctl_xmlread* xml, const char* szlabel );\
00068     /* Write data to an XML record */\
00069     void ppConcat(label,_xml_write)( const label* self, ctl_xmlwrite* xml, const char* szlabel )
00070 
00071 #ifndef DG_ARRAY_H
00072 #include "ctl/dg/array.h"
00073 #endif
00074 #ifndef DG_VECTOR_H
00075 #include "ctl/dg/vector.h"
00076 #endif
00077 #ifndef DG_LIST_H
00078 #include "ctl/dg/list.h"
00079 #endif
00080 #ifndef DG_SET_H
00081 #include "ctl/dg/set.h"
00082 #endif
00083 #ifndef DG_MAP_H
00084 #include "ctl/dg/map.h"
00085 #endif
00086 
00087 
00088 /* Manufacture array sorts for scalars */
00089 #define XSORTS(def,param)   ctl_array_qsort_declare(def);
00090 DEF_ENUMTYPES(XSORTS,unused)
00091 #undef XSORTS
00092 
00093 /* Declare scalar qsort comparisons */
00094 #define XCOMPS(type,param)  int ppConcat(type,_compare)( const type* p1, const type* p2 );
00095 DEF_ENUMTYPES(XCOMPS,unused)
00096 #undef XCOMPS
00097 
00098 /* Declare reversed scalar qsort comparisons */
00099 #define XCOMPS(type,param)  int ppConcat(type,_rcompare)( const type* p1, const type* p2 );
00100 DEF_ENUMTYPES(XCOMPS,unused)
00101 #undef XCOMPS
00102 
00103 
00107 void char_string_swap( char* s1, char* s2, size_t count );
00108 void wchar_t_string_swap( wchar_t* s1, wchar_t* s2, size_t count );
00109 
00110 
00111 /* Manufacture vectors for various types supported by the system */
00112 #define DECL_scalar_vectors(type,unused)        ctl_declare_vector(ppConcat(type,_vector),type);
00113 DEF_ENUMTYPES(DECL_scalar_vectors,unused)
00114 #undef DECL_scalar_vectors
00115 
00121 #define enum_count( enum )              ppConcat(enum,_COUNT)
00122 
00130 #define enum_isvalid(enum,value)        ( ((unsigned)(value)) < ((unsigned)ppConcat(enum,_COUNT)) )
00131 
00139 #define enum_itemname(enum,value)       ( enum_isvalid(enum,value) ? ppConcat(szz,enum)[(value)] : #enum "INVALID" )
00140 
00146 #define enum_itemnames( enum )          ppConcat(szz,enum)
00147 
00154 #define enum_rand(enum)                 ((enum)(rand() % enum_count( enum )))
00155 
00162 #define enum_foreach(enum,iterator)     enum iterator; for ( iterator = (enum)0; iterator < enum_count( enum ); iterator = (enum)(1 + iterator) )
00163 
00170 #define enum_foreach_reverse(enum,iterator) enum iterator = enum_count( enum ); while( iterator-- )
00171 
00172 #endif /*DATAGEN_H */

Generated on Fri Jan 2 15:28:34 2009 for Squat by  doxygen 1.5.6