Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

misc.h

Go to the documentation of this file.
00001 
00005 /*
00006     This file is part of Advanced Strategic Command; http://www.asc-hq.de
00007     Copyright (C) 1994-1999  Martin Bickel  and  Marc Schellenberger
00008 
00009     This program is free software; you can redistribute it and/or modify
00010     it under the terms of the GNU General Public License as published by
00011     the Free Software Foundation; either version 2 of the License, or
00012     (at your option) any later version.
00013 
00014     This program is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017     GNU General Public License for more details.
00018 
00019     You should have received a copy of the GNU General Public License
00020     along with this program; see the file COPYING. If not, write to the
00021     Free Software Foundation, Inc., 59 Temple Place, Suite 330,
00022     Boston, MA  02111-1307  USA
00023 */
00024 
00025 
00026 
00027 #ifndef miscH
00028    #define miscH
00029 
00030    #include "global.h"
00031    #include <string>
00032 
00033    #define dblue lightgray
00034    //153
00035    
00036   #ifdef UseMemAvail 
00037    extern int memavail ( void );       // dummy function
00038   #endif
00039 
00040 
00041    extern int firstBit(int i);
00042   
00043   
00045    inline int log2(int i) { return firstBit(i);};
00046 
00050    extern char* strr ( int a ) ;
00051    
00052    extern const char* digit[] ; 
00053    extern const char* letter[] ;
00054 
00058    extern char* strrr ( int a ) ;
00059    // extern char* strrr ( Uint32 a );
00060 
00064    extern char* strrr ( double a ) ;
00065 
00066    extern void beep( void );
00067 
00068    extern int  crc32buf( const void *vbuf, int len);
00069    
00070    extern int atoi ( const std::string& s );
00071    extern double atof ( const std::string& s );
00072 
00073 #ifdef min
00074 #undef min
00075 #endif
00076 
00077 #ifdef max
00078 #undef max
00079 #endif
00080 
00081 /*
00082 template<typename T>
00083 T min ( T a, T b )
00084 {
00085    if ( a > b )
00086       return b;
00087    else
00088       return a;
00089 }
00090 */
00091 
00092 template<typename T>
00093 const T& min ( const T& a, const T& b, const T&  c )
00094 {
00095    return min ( a, min ( b, c ));
00096 }
00097 
00098 /*
00099 template<typename T>
00100 T max ( T a, T b )
00101 {
00102    if ( a > b )
00103       return a;
00104    else
00105       return b;
00106 }
00107 */
00108 
00109 template<typename T>
00110 const T& max ( const T& a, const T& b, const T& c )
00111 {
00112    return max ( a, max ( b, c ));
00113 }
00114 
00115 
00116    extern char *strupr (const char *a);
00117 
00118   #ifndef HAVE_ITOA
00119    extern char* itoa ( int a, char* b, int c);
00120   #endif
00121 
00122    #if defined(MEMCHK) | defined(sgmain) | defined(karteneditor)
00123     extern void* asc_malloc ( size_t size );
00124     extern void asc_free ( void* p );
00125    #else
00126     #ifdef asc_malloc
00127      #undef asc_malloc
00128     #endif
00129     #define asc_malloc malloc
00130 
00131     #ifdef asc_free
00132      #undef asc_free
00133     #endif
00134     #define asc_free   free
00135    #endif
00136 
00137 #endif

Generated on Tue Jun 24 01:27:46 2008 for Advanced Strategic Command by  doxygen 1.4.2