*/
-/* $Core */
-
#include "inspircd.h"
-#include "hashcomp.h"
/******************************************************
*
return (national_case_insensitive_map[*n1] == national_case_insensitive_map[*n2]);
}
+bool irc::insensitive_swo::operator()(const std::string& a, const std::string& b) const
+{
+ const unsigned char* charmap = national_case_insensitive_map;
+ std::string::size_type asize = a.size();
+ std::string::size_type bsize = b.size();
+ std::string::size_type maxsize = std::min(asize, bsize);
+
+ for (std::string::size_type i = 0; i < maxsize; i++)
+ {
+ unsigned char A = charmap[(unsigned char)a[i]];
+ unsigned char B = charmap[(unsigned char)b[i]];
+ if (A > B)
+ return false;
+ else if (A < B)
+ return true;
+ }
+ return (asize < bsize);
+}
+
size_t irc::insensitive::operator()(const std::string &s) const
{
/* XXX: NO DATA COPIES! :)
return returnval;
}
-irc::sepstream::sepstream(const std::string& source, char seperator, bool allowempty)
+irc::sepstream::sepstream(const std::string& source, char separator, bool allowempty)
: tokens(source), sep(separator), pos(0), allow_empty(allowempty)
{
}
return n;
}
-irc::stringjoiner::stringjoiner(const std::string& seperator, const std::vector<std::string>& sequence, unsigned int begin, unsigned int end)
+std::string irc::stringjoiner(const std::vector<std::string>& sequence, char separator)
{
- if (end < begin)
- return; // nothing to do here
+ std::string joined;
+ if (sequence.empty())
+ return joined; // nothing to do here
- for (unsigned int v = begin; v < end; v++)
- joined.append(sequence[v]).append(seperator);
- joined.append(sequence[end]);
+ for (std::vector<std::string>::const_iterator i = sequence.begin(); i != sequence.end(); ++i)
+ joined.append(*i).push_back(separator);
+ joined.erase(joined.end()-1);
+ return joined;
}
irc::portparser::portparser(const std::string &source, bool allow_overlapped)