From 0d6a4a31d848201a1309ec7a9606cb10187a6374 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Tue, 3 Sep 2019 12:17:48 +0100 Subject: Add GetNumericToken to sepstream. This removes some boilerplate when retrieving numeric types. --- include/hashcomp.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 #include #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 + bool GetNumericToken(Numeric& token) + { + std::string str; + if (!GetToken(str)) + return false; + + token = ConvToNum(str); + return true; + } + /** Fetch the entire remaining stream, without tokenizing * @return The remaining part of the stream */ -- cgit v1.2.3