general/util.h

Go to the documentation of this file.
00001 /* $Id:util.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.
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 UTIL_H
00015 #define UTIL_H
00016 
00017 #include <string>
00018 #include <sigc++/signal.h>
00019 
00020 #define nmin(a,b) (((a)<(b)?(a):(b))
00021 #define nmax(a,b) (((a)>(b)?(a):(b))
00022 
00023 int toint(char* s);
00024 int toint(std::string s);
00025 std::string tostr(long l);
00026 std::string tostr(int i);
00027 long tolong(char* s);
00028 long tolong(std::string s);
00029 std::string ncpy(int n, std::string s);
00030 
00031 
00032 // return the part of `parm` till the text `txt` or the whole `parm`, cut that part from `parm`
00033 
00034 std::string split(std::string *parm, std::string txt);
00035 
00036 class pos {
00037   public:
00038     pos(std::string p);
00039     pos(int ix=0, int iy=0) { x=ix; y=iy; };
00040     int x:16;
00041     int y:16;
00042 };
00043 
00044 struct pos_cmp {
00045     bool operator()( const pos a, const pos b) const {
00046         if (a.y<b.y) return true;
00047         if (a.y>b.y) return false;
00048         return a.x<b.x;
00049     };
00050 };
00051 
00052 std::string filename(
00053     std::string fname  
00054 );
00055 
00056 bool isfile(
00057     std::string fname 
00058 );
00059 
00060 void directory(std::string dir, sigc::signal<void, std::string> handler);
00061 
00062 #endif // UTIL_H


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