summaryrefslogtreecommitdiff
path: root/include/hashcomp.h
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2019-09-03 12:17:48 +0100
committerPeter Powell <petpow@saberuk.com>2019-09-03 12:28:58 +0100
commit0d6a4a31d848201a1309ec7a9606cb10187a6374 (patch)
treefdd0e2b2704f33416da3f80415093767a726c787 /include/hashcomp.h
parente566a2d666f6f54eeab364794145e3b0999383ed (diff)
Add GetNumericToken to sepstream.
This removes some boilerplate when retrieving numeric types.
Diffstat (limited to 'include/hashcomp.h')
-rw-r--r--include/hashcomp.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/hashcomp.h b/include/hashcomp.h
index 453e28c45..58b6c05ed 100644
--- a/include/hashcomp.h
+++ b/include/hashcomp.h
@@ -31,6 +31,7 @@
#include <map>
#include <set>
#include "inspircd.h"
+#include "convto.h"
/*******************************************************
* This file contains classes and templates that deal
@@ -139,6 +140,21 @@ namespace irc
*/
bool GetToken(std::string& token);
+ /** Fetch the next numeric token from the stream
+ * @param token The next token from the stream is placed here
+ * @return True if tokens still remain, false if there are none left
+ */
+ template<typename Numeric>
+ bool GetNumericToken(Numeric& token)
+ {
+ std::string str;
+ if (!GetToken(str))
+ return false;
+
+ token = ConvToNum<Numeric>(str);
+ return true;
+ }
+
/** Fetch the entire remaining stream, without tokenizing
* @return The remaining part of the stream
*/