general/general.h

Go to the documentation of this file.
00001 /* $Id:general.h jjs $ */
00002 /*
00003    Copyright (C) 2007 by Jurjen Stellingwerff <jurjen@stwerff.xs4all.nl>
00004    Part of the Moros Project http://moros.sourceforge.net/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License version 3.
00008    This program is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY.
00010 
00011    See the COPYING file for more details.
00012 */
00013 
00014 #ifndef __GENERAL_H
00015 #define __GENERAL_H
00016 
00017 class invalid { /* .. */ };
00018 class nullpointer { /* .. */ };
00019 class unnamed { /* .. */ };
00020 
00021 #define loopMap(r,v,t) \
00022     map<string,t>& v##_t=(r); \
00023     map<string,t> :: iterator v##_i = v##_t.begin(); \
00024     for( \
00025         t* v=&v##_i->second; \
00026         v##_i != v##_t.end(); \
00027         v##_i++, v=(v##_i != v##_t.end())?&v##_i->second:0 \
00028     )
00029 #define loopMapi(r,v,t) \
00030     map<int,t>& v##_t=(r); \
00031     map<int,t> :: iterator v##_i = v##_t.begin(); \
00032     for( \
00033         t* v=&v##_i->second; \
00034         v##_i != v##_t.end(); \
00035         v##_i++, v=(v##_i != v##_t.end())?&v##_i->second:0 \
00036     )
00037 #define loopSingle(r,v,t,s) \
00038     s<t>& v##_t=(r); \
00039     s<t> :: iterator v##_i = v##_t.begin(); \
00040     for( \
00041         t* v=&(*v##_i); \
00042         v##_i != v##_t.end(); \
00043         v##_i++, v=(v##_i != v##_t.end())?&(*v##_i):0 \
00044     )
00045 #define loopArray(r,v,t) \
00046     const t *v=r; \
00047     unsigned int v##_c=sizeof r/sizeof r[0]; \
00048     for ( \
00049         unsigned int v##_i=0; \
00050         v##_i< v##_c; \
00051         v##_i++, v=(v##_i<v##_c)?r+v##_i:0 \
00052     )
00053 
00054 #endif


Generated on Tue Jan 1 17:30:00 2008 for general/general.h Source File by  doxygen   Visit the project page on SourceForge.net Logo