00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef IRC_COMPARE_H
00017 #define IRC_COMPARE_H
00018
00019 #ifndef USE_PCH
00020 #include <cstddef>
00021 #include <string>
00022 #endif
00023
00024 #include "ircd_chattr.h"
00025
00026
00027
00028
00029 inline int IRCStringCompare(char c1, char c2)
00030 {
00031 int lc1 = static_cast<unsigned char>(ToLower(c1));
00032 int lc2 = static_cast<unsigned char>(ToLower(c2));
00033 if (lc1 < lc2)
00034 return -1;
00035 if (lc1 > lc2)
00036 return 1;
00037 return 0;
00038 }
00039
00040
00041
00042
00043 inline bool IRC_compare(char c1, char c2)
00044 {
00045 return static_cast<unsigned char>(ToLower(c1)) < static_cast<unsigned char>(ToLower(c2));
00046 }
00047
00048
00049 int IRCStringCompare(char const* s1, char const* s2);
00050
00051
00052
00053
00054 int IRCStringCompare(char const* s1, char const* s2, size_t count);
00055
00056
00057 inline int IRCStringCompare(std::string const& s1, std::string const& s2)
00058 {
00059 return IRCStringCompare(s1.c_str(), s2.c_str());
00060 }
00061
00062
00063
00064
00065 inline int IRCStringCompare(std::string const& s1, std::string const& s2, size_t count)
00066 {
00067 return IRCStringCompare(s1.c_str(), s2.c_str(), count);
00068 }
00069
00070
00071 inline int IRCStringCompare(std::string const& s1, char const* s2)
00072 {
00073 return IRCStringCompare(s1.c_str(), s2);
00074 }
00075
00076
00077
00078
00079 inline int IRCStringCompare(std::string const& s1, char const* s2, size_t count)
00080 {
00081 return IRCStringCompare(s1.c_str(), s2, count);
00082 }
00083
00084
00085 inline int IRCStringCompare(char const* s1, std::string const& s2)
00086 {
00087 return IRCStringCompare(s1, s2.c_str());
00088 }
00089
00090
00091
00092
00093 inline int IRCStringCompare(char const* s1, std::string const& s2, size_t count)
00094 {
00095 return IRCStringCompare(s1, s2.c_str(), count);
00096 }
00097
00098
00099 struct IRC_less {
00100
00101 bool operator()(std::string const& s1, std::string const& s2) const { return IRCStringCompare(s1, s2) < 0; }
00102 };
00103
00104 #endif // IRC_COMPARE_H
00105