|
||||
File indexing completed on 2025-01-18 09:27:16
0001 // 0002 // Copyright 2019 The Abseil Authors. 0003 // 0004 // Licensed under the Apache License, Version 2.0 (the "License"); 0005 // you may not use this file except in compliance with the License. 0006 // You may obtain a copy of the License at 0007 // 0008 // https://www.apache.org/licenses/LICENSE-2.0 0009 // 0010 // Unless required by applicable law or agreed to in writing, software 0011 // distributed under the License is distributed on an "AS IS" BASIS, 0012 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0013 // See the License for the specific language governing permissions and 0014 // limitations under the License. 0015 0016 #ifndef ABSL_FLAGS_INTERNAL_PARSE_H_ 0017 #define ABSL_FLAGS_INTERNAL_PARSE_H_ 0018 0019 #include <iostream> 0020 #include <ostream> 0021 #include <string> 0022 #include <vector> 0023 0024 #include "absl/base/config.h" 0025 #include "absl/flags/declare.h" 0026 #include "absl/flags/internal/usage.h" 0027 #include "absl/strings/string_view.h" 0028 0029 ABSL_DECLARE_FLAG(std::vector<std::string>, flagfile); 0030 ABSL_DECLARE_FLAG(std::vector<std::string>, fromenv); 0031 ABSL_DECLARE_FLAG(std::vector<std::string>, tryfromenv); 0032 ABSL_DECLARE_FLAG(std::vector<std::string>, undefok); 0033 0034 namespace absl { 0035 ABSL_NAMESPACE_BEGIN 0036 namespace flags_internal { 0037 0038 enum class UsageFlagsAction { kHandleUsage, kIgnoreUsage }; 0039 enum class OnUndefinedFlag { 0040 kIgnoreUndefined, 0041 kReportUndefined, 0042 kAbortIfUndefined 0043 }; 0044 0045 // This is not a public interface. This interface exists to expose the ability 0046 // to change help output stream in case of parsing errors. This is used by 0047 // internal unit tests to validate expected outputs. 0048 // When this was written, `EXPECT_EXIT` only supported matchers on stderr, 0049 // but not on stdout. 0050 std::vector<char*> ParseCommandLineImpl( 0051 int argc, char* argv[], UsageFlagsAction usage_flag_action, 0052 OnUndefinedFlag undef_flag_action, 0053 std::ostream& error_help_output = std::cout); 0054 0055 // -------------------------------------------------------------------- 0056 // Inspect original command line 0057 0058 // Returns true if flag with specified name was either present on the original 0059 // command line or specified in flag file present on the original command line. 0060 bool WasPresentOnCommandLine(absl::string_view flag_name); 0061 0062 // Return existing flags similar to the parameter, in order to help in case of 0063 // misspellings. 0064 std::vector<std::string> GetMisspellingHints(absl::string_view flag); 0065 0066 } // namespace flags_internal 0067 ABSL_NAMESPACE_END 0068 } // namespace absl 0069 0070 #endif // ABSL_FLAGS_INTERNAL_PARSE_H_
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |