diff options
author | Matteo Collina <hello@matteocollina.com> | 2018-12-18 12:12:21 +0100 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2018-12-20 09:31:52 -0500 |
commit | 436f4de38f511508710eb1492f4d23a9f427e7f7 (patch) | |
tree | 7158f1292bc30d749f2beb5f76846c01e262ad11 /src/node_options-inl.h | |
parent | cdcb1b77379f780b7b187d711c44181dbd0a6e24 (diff) | |
download | node-new-436f4de38f511508710eb1492f4d23a9f427e7f7.tar.gz |
src: add kUInteger parsing
This commit adds support for uint64_t option parsing.
PR-URL: https://github.com/nodejs/node/pull/24811
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'src/node_options-inl.h')
-rw-r--r-- | src/node_options-inl.h | 16 |
1 files changed, 16 insertions, 0 deletions
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 @@ -42,6 +42,19 @@ void OptionsParser<Options>::AddOption(const std::string& name, template <typename Options> void OptionsParser<Options>::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<SimpleOptionField<uint64_t>>(field), + env_setting, + help_text}); +} + +template <typename Options> +void OptionsParser<Options>::AddOption(const std::string& name, + const std::string& help_text, int64_t Options::* field, OptionEnvvarSettings env_setting) { options_.emplace( @@ -401,6 +414,9 @@ void OptionsParser<Options>::Parse( case kInteger: *Lookup<int64_t>(info.field, options) = std::atoll(value.c_str()); break; + case kUInteger: + *Lookup<uint64_t>(info.field, options) = std::stoull(value.c_str()); + break; case kString: *Lookup<std::string>(info.field, options) = value; break; |