]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Add GetNumericToken to sepstream.
authorPeter Powell <petpow@saberuk.com>
Tue, 3 Sep 2019 11:17:48 +0000 (12:17 +0100)
committerPeter Powell <petpow@saberuk.com>
Tue, 3 Sep 2019 11:28:58 +0000 (12:28 +0100)
This removes some boilerplate when retrieving numeric types.

include/hashcomp.h

index 453e28c4572d6e1dd8f050c9f9a838d1119849ad..58b6c05edd9d9437c15a7e03f2617f7543b5657e 100644 (file)
@@ -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
                 */