diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-07-16 15:08:59 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-07-16 15:08:59 +0000 |
commit | 085cd4278f0f495c6d008a3d157026b33a23b787 (patch) | |
tree | b1c5df846e0c74891546f24ebd5f41040dc86dea /src/hashcomp.cpp | |
parent | 863d8a3d08f7c4089683822f3d1e5544b6419ec6 (diff) |
Created new class irc::commasepstream.
Will read comma seperated lists and works identically to irc::tokenstream
It's re-entrant so we can run two of them together for JOIN
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4412 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/hashcomp.cpp')
-rw-r--r-- | src/hashcomp.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index 5e6d2c077..34f53ea28 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -219,3 +219,31 @@ const std::string irc::tokenstream::GetToken() } return ""; } + +irc::commasepstream::commasepstream(const std::string &source) : tokens(source) +{ + last_starting_position = tokens.begin(); + n = tokens.begin(); +} + +const std::string irc::commasepstream::GetToken() +{ + std::string::iterator lsp = last_starting_position; + + while (n != tokens.end()) + { + if ((*n == ',') || (n+1 == tokens.end())) + { + last_starting_position = n+1; + return std::string(lsp, n+1 == tokens.end() ? n+1 : n++); + } + + n++; + } + + return ""; +} + +irc::commasepstream::~commasepstream() +{ +} |