diff options
author | Eric Holk <eholk@google.com> | 2021-01-30 02:03:29 +0000 |
---|---|---|
committer | Treehugger Robot <treehugger-gerrit@google.com> | 2021-02-17 15:05:02 +0000 |
commit | 3dba023d4fb47882fa215715c196cfa3be30c098 (patch) | |
tree | da22f82b7cde87f37100f715a0e05f332b377f73 /cmdline/cmdline_parser.h | |
parent | 381d35c1b01401e193544f679bfaf4f5c197f7cd (diff) |
Add a server-configurable flags API
Adds a new set of flags that can be set by the command line, server
configuration, or system properties. These flags can be used to enable
or disable certain features or otherwise change their behavior. The
flexible configuration options facilitate both development and also
experimentation.
As an example of their use, this CL also moves the
-Xwrite-metrics-to-log command line option to the flags system
instead. Future work will migrate the rest of the metrics settings.
Test: ./test/run-test --host --jit 2232-write-metrics-to-log
Bug: 175050458
Change-Id: I1ef37e7d355204a3172b7aa5c0baa4cbd8c7076b
Diffstat (limited to 'cmdline/cmdline_parser.h')
-rw-r--r-- | cmdline/cmdline_parser.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/cmdline/cmdline_parser.h b/cmdline/cmdline_parser.h index 22eb44c211..7e343f8ef2 100644 --- a/cmdline/cmdline_parser.h +++ b/cmdline/cmdline_parser.h @@ -210,6 +210,24 @@ struct CmdlineParser { return parent_; } + // Write the results of this argument into a variable pointed to by destination. + // An optional is used to tell whether the command line argument was present. + CmdlineParser::Builder& IntoLocation(std::optional<TArg>* destination) { + save_value_ = [destination](TArg& value) { + *destination = value; + }; + + load_value_ = [destination]() -> TArg& { + return destination->value(); + }; + + save_value_specified_ = true; + load_value_specified_ = true; + + CompleteArgument(); + return parent_; + } + // Ensure we always move this when returning a new builder. ArgumentBuilder(ArgumentBuilder&&) = default; |