You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

parse.h 2.1 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //
  2. // Copyright 2019 The Abseil Authors.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // https://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. #ifndef ABSL_FLAGS_INTERNAL_PARSE_H_
  16. #define ABSL_FLAGS_INTERNAL_PARSE_H_
  17. #include <string>
  18. #include <vector>
  19. #include "absl/base/config.h"
  20. #include "absl/flags/declare.h"
  21. #include "absl/strings/string_view.h"
  22. ABSL_DECLARE_FLAG(std::vector<std::string>, flagfile);
  23. ABSL_DECLARE_FLAG(std::vector<std::string>, fromenv);
  24. ABSL_DECLARE_FLAG(std::vector<std::string>, tryfromenv);
  25. ABSL_DECLARE_FLAG(std::vector<std::string>, undefok);
  26. namespace absl
  27. {
  28. ABSL_NAMESPACE_BEGIN
  29. namespace flags_internal
  30. {
  31. enum class ArgvListAction
  32. {
  33. kRemoveParsedArgs,
  34. kKeepParsedArgs
  35. };
  36. enum class UsageFlagsAction
  37. {
  38. kHandleUsage,
  39. kIgnoreUsage
  40. };
  41. enum class OnUndefinedFlag
  42. {
  43. kIgnoreUndefined,
  44. kReportUndefined,
  45. kAbortIfUndefined
  46. };
  47. std::vector<char*> ParseCommandLineImpl(int argc, char* argv[], ArgvListAction arg_list_act, UsageFlagsAction usage_flag_act, OnUndefinedFlag on_undef_flag);
  48. // --------------------------------------------------------------------
  49. // Inspect original command line
  50. // Returns true if flag with specified name was either present on the original
  51. // command line or specified in flag file present on the original command line.
  52. bool WasPresentOnCommandLine(absl::string_view flag_name);
  53. } // namespace flags_internal
  54. ABSL_NAMESPACE_END
  55. } // namespace absl
  56. #endif // ABSL_FLAGS_INTERNAL_PARSE_H_