summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-02-19 23:14:37 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-02-19 23:14:37 +0000
commitf0610a1fa232346ca050b6a4757dcf09e5f043a7 (patch)
tree005f0da966c360563b57384ffe9e0e141b593abd
parentbf0f3f06ffcefb14b10c03efad68c8641b172df9 (diff)
Added + and == operators between std::string and irc::string.
Its too late at night to wrestle with the = operator, this can wait for another time. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3260 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/hashcomp.h9
-rw-r--r--src/hashcomp.cpp20
2 files changed, 29 insertions, 0 deletions
diff --git a/include/hashcomp.h b/include/hashcomp.h
index 3aa838da2..0d6bc7e6f 100644
--- a/include/hashcomp.h
+++ b/include/hashcomp.h
@@ -136,4 +136,13 @@ namespace irc
std::ostream& operator<<(std::ostream &os, const irc::string &str);
std::istream& operator>>(std::istream &is, irc::string &str);
+/* Define operators for + and == with irc::string to std::string for easy assignment
+ * and comparison - Brain
+ */
+
+std::string& operator+ (std::string& leftval, irc::string& rightval);
+irc::string& operator+ (irc::string& leftval, std::string& rightval);
+std::string& operator== (std::string& leftval, irc::string& rightval);
+irc::string& operator== (irc::string& leftval, std::string& rightval);
+
#endif
diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp
index 652618a79..c5725a0bd 100644
--- a/src/hashcomp.cpp
+++ b/src/hashcomp.cpp
@@ -142,6 +142,26 @@ int irc::irc_char_traits::compare(const char* str1, const char* str2, size_t n)
return 0;
}
+std::string& operator+ (std::string& leftval, irc::string& rightval)
+{
+ return leftval + std::string(rightval.c_str());
+}
+
+irc::string& operator+ (irc::string& leftval, std::string& rightval)
+{
+ return leftval + irc::string(rightval.c_str());
+}
+
+std::string& operator== (std::string& leftval, irc::string& rightval)
+{
+ return (leftval == std::string(rightval.c_str()));
+}
+
+irc::string& operator== (irc::string& leftval, std::string& rightval)
+{
+ return (rightval == irc::string(leftval.c_str()));
+}
+
const char* irc::irc_char_traits::find(const char* s1, int n, char c)
{
while(n-- > 0 && lowermap[(unsigned)*s1] != lowermap[(unsigned)c])