00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
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_