summaryrefslogtreecommitdiff
path: root/src/hashcomp.cpp
diff options
context:
space:
mode:
authorRobin Burchell w00t@inspircd.org <Robin Burchell w00t@inspircd.org@5417fbe8-f217-4b02-8779-1006273d7864>2008-10-13 12:32:37 +0000
committerRobin Burchell w00t@inspircd.org <Robin Burchell w00t@inspircd.org@5417fbe8-f217-4b02-8779-1006273d7864>2008-10-13 12:32:37 +0000
commit2b0e9c3f5f0eb631619bc111764146553bcdf303 (patch)
treedc85f649a57bf72fc300808b36bee606daff9688 /src/hashcomp.cpp
parent3324e62bae6f04e4f16f113b2e3352fae242f405 (diff)
Merge commit 'cbx/anopeng-config' into anopeng-config
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1429 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/hashcomp.cpp')
-rw-r--r--src/hashcomp.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp
new file mode 100644
index 000000000..0c6d7718c
--- /dev/null
+++ b/src/hashcomp.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2002-2008 InspIRCd Development Team
+ * Copyright (C) 2008 Anope Team <info@anope.org>
+ *
+ * Please read COPYING and README for further details.
+ *
+ * These classes have been copied from InspIRCd and modified
+ * for use in Anope.
+ *
+ * $Id$
+ *
+ */
+
+#include "hashcomp.h"
+
+sepstream::sepstream(const std::string &source, char seperator) : tokens(source), sep(seperator)
+{
+ last_starting_position = n = tokens.begin();
+}
+
+bool sepstream::GetToken(std::string &token)
+{
+ std::string::iterator lsp = last_starting_position;
+
+ while (n != tokens.end())
+ {
+ if (*n == sep || n + 1 == tokens.end())
+ {
+ last_starting_position = n + 1;
+ token = std::string(lsp, n + 1 == tokens.end() ? n + 1 : ++n);
+
+ while (token.length() && token.find_last_of(sep) == token.length() - 1)
+ token.erase(token.end() - 1);
+
+ if (token.empty())
+ ++n;
+
+ return n == tokens.end() ? false : true;
+ }
+
+ ++n;
+ }
+
+ token = "";
+ return false;
+}
+
+const std::string sepstream::GetRemaining()
+{
+ return std::string(n, tokens.end());
+}
+
+bool sepstream::StreamEnd()
+{
+ return n + 1 == tokens.end();
+}