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: declare.h 00018 // ----------------------------------------------------------------------------- 00019 // 00020 // This file defines the ABSL_DECLARE_FLAG macro, allowing you to declare an 00021 // `absl::Flag` for use within a translation unit. You should place this 00022 // declaration within the header file associated with the .cc file that defines 00023 // and owns the `Flag`. 00024 00025 #ifndef ABSL_FLAGS_DECLARE_H_ 00026 #define ABSL_FLAGS_DECLARE_H_ 00027 00028 #include "absl/strings/string_view.h" 00029 00030 namespace absl { 00031 namespace flags_internal { 00032 00033 // absl::Flag<T> represents a flag of type 'T' created by ABSL_FLAG. 00034 template <typename T> 00035 class Flag; 00036 00037 } // namespace flags_internal 00038 00039 // Flag 00040 // 00041 // Forward declaration of the `absl::Flag` type for use in defining the macro. 00042 template <typename T> 00043 using Flag = flags_internal::Flag<T>; 00044 00045 } // namespace absl 00046 00047 // ABSL_DECLARE_FLAG() 00048 // 00049 // This macro is a convenience for declaring use of an `absl::Flag` within a 00050 // translation unit. This macro should be used within a header file to 00051 // declare usage of the flag within any .cc file including that header file. 00052 // 00053 // The ABSL_DECLARE_FLAG(type, name) macro expands to: 00054 // 00055 // extern absl::Flag<type> FLAGS_name; 00056 #define ABSL_DECLARE_FLAG(type, name) extern ::absl::Flag<type> FLAGS_##name 00057 00058 #endif // ABSL_FLAGS_DECLARE_H_