00001 // 00002 // Copyright 2019 The Abseil Authors. 00003 // 00004 // Licensed under the Apache License, Version 2.0 (the "License"); 00005 // you may not use this file except in compliance with the License. 00006 // You may obtain a copy of the License at 00007 // 00008 // https://www.apache.org/licenses/LICENSE-2.0 00009 // 00010 // Unless required by applicable law or agreed to in writing, software 00011 // distributed under the License is distributed on an "AS IS" BASIS, 00012 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 // See the License for the specific language governing permissions and 00014 // limitations under the License. 00015 // 00016 // ----------------------------------------------------------------------------- 00017 // File: parse.h 00018 // ----------------------------------------------------------------------------- 00019 // 00020 // This file defines the main parsing function for Abseil flags: 00021 // `absl::ParseCommandLine()`. 00022 00023 #ifndef ABSL_FLAGS_PARSE_H_ 00024 #define ABSL_FLAGS_PARSE_H_ 00025 00026 #include <string> 00027 #include <vector> 00028 00029 #include "absl/flags/internal/parse.h" 00030 00031 namespace absl { 00032 00033 // ParseCommandLine() 00034 // 00035 // Parses the set of command-line arguments passed in the `argc` (argument 00036 // count) and `argv[]` (argument vector) parameters from `main()`, assigning 00037 // values to any defined Abseil flags. (Any arguments passed after the 00038 // flag-terminating delimiter (`--`) are treated as positional arguments and 00039 // ignored.) 00040 // 00041 // Any command-line flags (and arguments to those flags) are parsed into Abseil 00042 // Flag values, if those flags are defined. Any undefined flags will either 00043 // return an error, or be ignored if that flag is designated using `undefok` to 00044 // indicate "undefined is OK." 00045 // 00046 // Any command-line positional arguments not part of any command-line flag (or 00047 // arguments to a flag) are returned in a vector, with the program invocation 00048 // name at position 0 of that vector. (Note that this includes positional 00049 // arguments after the flag-terminating delimiter `--`.) 00050 // 00051 // After all flags and flag arguments are parsed, this function looks for any 00052 // built-in usage flags (e.g. `--help`), and if any were specified, it reports 00053 // help messages and then exits the program. 00054 std::vector<char*> ParseCommandLine(int argc, char* argv[]); 00055 00056 } // namespace absl 00057 00058 #endif // ABSL_FLAGS_PARSE_H_