1cb93a386Sopenharmony_ci// 2cb93a386Sopenharmony_ci// Copyright 2019 The Abseil Authors. 3cb93a386Sopenharmony_ci// 4cb93a386Sopenharmony_ci// Licensed under the Apache License, Version 2.0 (the "License"); 5cb93a386Sopenharmony_ci// you may not use this file except in compliance with the License. 6cb93a386Sopenharmony_ci// You may obtain a copy of the License at 7cb93a386Sopenharmony_ci// 8cb93a386Sopenharmony_ci// https://www.apache.org/licenses/LICENSE-2.0 9cb93a386Sopenharmony_ci// 10cb93a386Sopenharmony_ci// Unless required by applicable law or agreed to in writing, software 11cb93a386Sopenharmony_ci// distributed under the License is distributed on an "AS IS" BASIS, 12cb93a386Sopenharmony_ci// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13cb93a386Sopenharmony_ci// See the License for the specific language governing permissions and 14cb93a386Sopenharmony_ci// limitations under the License. 15cb93a386Sopenharmony_ci// 16cb93a386Sopenharmony_ci// ----------------------------------------------------------------------------- 17cb93a386Sopenharmony_ci// File: parse.h 18cb93a386Sopenharmony_ci// ----------------------------------------------------------------------------- 19cb93a386Sopenharmony_ci// 20cb93a386Sopenharmony_ci// This file defines the main parsing function for Abseil flags: 21cb93a386Sopenharmony_ci// `absl::ParseCommandLine()`. 22cb93a386Sopenharmony_ci 23cb93a386Sopenharmony_ci#ifndef ABSL_FLAGS_PARSE_H_ 24cb93a386Sopenharmony_ci#define ABSL_FLAGS_PARSE_H_ 25cb93a386Sopenharmony_ci 26cb93a386Sopenharmony_ci#include <vector> 27cb93a386Sopenharmony_ci 28cb93a386Sopenharmony_ci#include "absl/base/config.h" 29cb93a386Sopenharmony_ci#include "absl/flags/internal/parse.h" 30cb93a386Sopenharmony_ci 31cb93a386Sopenharmony_cinamespace absl { 32cb93a386Sopenharmony_ciABSL_NAMESPACE_BEGIN 33cb93a386Sopenharmony_ci 34cb93a386Sopenharmony_ci// ParseCommandLine() 35cb93a386Sopenharmony_ci// 36cb93a386Sopenharmony_ci// Parses the set of command-line arguments passed in the `argc` (argument 37cb93a386Sopenharmony_ci// count) and `argv[]` (argument vector) parameters from `main()`, assigning 38cb93a386Sopenharmony_ci// values to any defined Abseil flags. (Any arguments passed after the 39cb93a386Sopenharmony_ci// flag-terminating delimiter (`--`) are treated as positional arguments and 40cb93a386Sopenharmony_ci// ignored.) 41cb93a386Sopenharmony_ci// 42cb93a386Sopenharmony_ci// Any command-line flags (and arguments to those flags) are parsed into Abseil 43cb93a386Sopenharmony_ci// Flag values, if those flags are defined. Any undefined flags will either 44cb93a386Sopenharmony_ci// return an error, or be ignored if that flag is designated using `undefok` to 45cb93a386Sopenharmony_ci// indicate "undefined is OK." 46cb93a386Sopenharmony_ci// 47cb93a386Sopenharmony_ci// Any command-line positional arguments not part of any command-line flag (or 48cb93a386Sopenharmony_ci// arguments to a flag) are returned in a vector, with the program invocation 49cb93a386Sopenharmony_ci// name at position 0 of that vector. (Note that this includes positional 50cb93a386Sopenharmony_ci// arguments after the flag-terminating delimiter `--`.) 51cb93a386Sopenharmony_ci// 52cb93a386Sopenharmony_ci// After all flags and flag arguments are parsed, this function looks for any 53cb93a386Sopenharmony_ci// built-in usage flags (e.g. `--help`), and if any were specified, it reports 54cb93a386Sopenharmony_ci// help messages and then exits the program. 55cb93a386Sopenharmony_cistd::vector<char*> ParseCommandLine(int argc, char* argv[]); 56cb93a386Sopenharmony_ci 57cb93a386Sopenharmony_ciABSL_NAMESPACE_END 58cb93a386Sopenharmony_ci} // namespace absl 59cb93a386Sopenharmony_ci 60cb93a386Sopenharmony_ci#endif // ABSL_FLAGS_PARSE_H_ 61