// // Copyright 2020 The Abseil Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // ----------------------------------------------------------------------------- // File: commandlineflag.h // ----------------------------------------------------------------------------- // // This header file defines the `CommandLineFlag`, which acts as a type-erased // handle for accessing metadata about the Abseil Flag in question. // // Because an actual Abseil flag is of an unspecified type, you should not // manipulate or interact directly with objects of that type. Instead, use the // CommandLineFlag type as an intermediary. #ifndef ABSL_FLAGS_COMMANDLINEFLAG_H_ #define ABSL_FLAGS_COMMANDLINEFLAG_H_ #include <memory> #include <string> #include "absl/base/config.h" #include "absl/base/internal/fast_type_id.h" #include "absl/flags/internal/commandlineflag.h" #include "absl/strings/string_view.h" #include "absl/types/optional.h" namespace absl { ABSL_NAMESPACE_BEGIN namespace flags_internal { class PrivateHandleAccessor; } // namespace flags_internal // CommandLineFlag // // This type acts as a type-erased handle for an instance of an Abseil Flag and // holds reflection information pertaining to that flag. Use CommandLineFlag to // access a flag's name, location, help string etc. // // To obtain an absl::CommandLineFlag, invoke `absl::FindCommandLineFlag()` // passing it the flag name string. // // Example: // // // Obtain reflection handle for a flag named "flagname". // const absl::CommandLineFlag* my_flag_data = // absl::FindCommandLineFlag("flagname"); // // // Now you can get flag info from that reflection handle. // std::string flag_location = my_flag_data->Filename(); // ... // These are only used as constexpr global objects. // They do not use a virtual destructor to simplify their implementation. // They are not destroyed except at program exit, so leaks do not matter. #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" #endif class CommandLineFlag { … }; #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic pop #endif ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_FLAGS_COMMANDLINEFLAG_H_