From 436f4de38f511508710eb1492f4d23a9f427e7f7 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Tue, 18 Dec 2018 12:12:21 +0100 Subject: src: add kUInteger parsing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds support for uint64_t option parsing. PR-URL: https://github.com/nodejs/node/pull/24811 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Myles Borins Reviewed-By: Michael Dawson Reviewed-By: Сковорода Никита Андреевич Reviewed-By: James M Snell Reviewed-By: Jeremiah Senkpiel --- src/node_options-inl.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/node_options-inl.h') diff --git a/src/node_options-inl.h b/src/node_options-inl.h index d25557e6a5..f482bcd366 100644 --- a/src/node_options-inl.h +++ b/src/node_options-inl.h @@ -39,6 +39,19 @@ void OptionsParser::AddOption(const std::string& name, help_text}); } +template +void OptionsParser::AddOption(const std::string& name, + const std::string& help_text, + uint64_t Options::* field, + OptionEnvvarSettings env_setting) { + options_.emplace( + name, + OptionInfo{kUInteger, + std::make_shared>(field), + env_setting, + help_text}); +} + template void OptionsParser::AddOption(const std::string& name, const std::string& help_text, @@ -401,6 +414,9 @@ void OptionsParser::Parse( case kInteger: *Lookup(info.field, options) = std::atoll(value.c_str()); break; + case kUInteger: + *Lookup(info.field, options) = std::stoull(value.c_str()); + break; case kString: *Lookup(info.field, options) = value; break; -- cgit v1.2.3