Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

util.h

Go to the documentation of this file.
00001 // util.h
00002 //
00003 // Copyright (C) 2001, Chris Laurel <claurel@shatters.net>
00004 //
00005 // Miscellaneous useful functions.
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 
00012 #ifndef _UTIL_H_
00013 #define _UTIL_H_
00014 
00015 #include <string>
00016 #include <vector>
00017 #include <iostream>
00018 #include <functional>
00019 
00020 #ifndef min
00021 #define min(a, b) ((a) < (b) ? (a) : (b))
00022 #endif
00023 
00024 #ifndef max
00025 #define max(a, b) ((a) < (b) ? (b) : (a))
00026 #endif
00027                                       
00028 #ifdef _WIN32
00029 #define _(s) s
00030 #else
00031 #define _(s) gettext(s)
00032 #endif
00033 
00034 extern int compareIgnoringCase(const std::string& s1, const std::string& s2);
00035 extern int compareIgnoringCase(const std::string& s1, const std::string& s2, int n);
00036 
00037 class CompareIgnoringCasePredicate : public std::binary_function<std::string, std::string, bool>
00038 {
00039  public:
00040     bool operator()(const std::string&, const std::string&) const;
00041 };
00042 
00043 template <class T> struct printlineFunc : public std::unary_function<T, void>
00044 {
00045     printlineFunc(std::ostream& o) : out(o) {};
00046     void operator() (T x) { out << x << '\n'; };
00047     std::ostream& out;
00048 };
00049 
00050 template <class T> struct deleteFunc : public std::unary_function<T, void>
00051 {
00052     deleteFunc() {};
00053     void operator() (T x) { delete x; };
00054     int dummy;
00055 };
00056 
00057 #endif // _UTIL_H_

Generated on Sat Jan 14 22:30:32 2006 for Celestia by  doxygen 1.4.1