16 #ifndef ABSL_FLAGS_INTERNAL_COMMANDLINEFLAG_H_ 17 #define ABSL_FLAGS_INTERNAL_COMMANDLINEFLAG_H_ 27 namespace flags_internal {
81 void*
FlagOps(FlagOp op,
const void* v1,
void* v2) {
84 delete static_cast<const T*
>(v1);
87 return new T(*static_cast<const T*>(v1));
89 *
static_cast<T*
>(v2) = *static_cast<const T*>(v1);
92 new (v2) T(*static_cast<const T*>(v1));
95 return reinterpret_cast<void*
>(
sizeof(T));
101 template <
typename T>
107 T temp(*static_cast<T*>(v2));
108 if (!absl::ParseFlag<T>(*static_cast<const absl::string_view*>(v1), &temp,
109 static_cast<std::string*>(v3))) {
116 *
static_cast<std::string*
>(v2) =
117 absl::UnparseFlag<T>(*static_cast<const T*>(v1));
142 std::string* error) {
154 return static_cast<size_t>(
reinterpret_cast<intptr_t
>(
180 std::string GetHelpText()
const;
188 : help_function_(fn), help_message_(msg) {}
197 const char* name_arg,
HelpText help_text,
const char* filename_arg,
201 const bool retired_arg,
void* def_arg,
void* cur_arg)
204 filename(filename_arg),
206 marshalling_op(marshalling_op_arg),
207 make_init_value(initial_value_gen),
208 retired(retired_arg),
211 on_command_line(false),
225 std::string
Help()
const {
return help.GetHelpText(); }
231 return this->make_init_value !=
nullptr;
235 std::string Filename()
const;
236 std::string DefaultValue()
const;
237 std::string CurrentValue()
const;
240 template <
typename T>
242 return this->op == &flags_internal::FlagOps<T>;
247 template <
typename T>
249 if (IsRetired() || flags_internal::FlagOps<T> != this->op)
250 return absl::nullopt;
253 Read(&res, flags_internal::FlagOps<T>);
296 static const int64_t kAtomicInit = 0xababababababababll;
312 "temporary until FlagName call sites are migrated and validator API is " 314 const
char* NameAsCString()
const {
return name; }
349 #define ABSL_FLAGS_INTERNAL_FOR_EACH_LOCK_FREE(A) \ 358 A(unsigned long long) \ 365 #endif // ABSL_FLAGS_INTERNAL_COMMANDLINEFLAG_H_ void Delete(FlagOpFn op, const void *obj)
absl::optional< T > Get()
std::string(*)() HelpGenFunc
const char * help_message_
static constexpr HelpText FromStaticCString(const char *msg)
bool IsAbseilFlag() const
bool Parse(FlagMarshallingOpFn op, absl::string_view text, void *dst, std::string *error)
struct CommandLineFlagLocks * locks
void UpdateModifiedBit(CommandLineFlag *flag)
const InitialValGenFunc make_init_value
bool Validate(CommandLineFlag *, const void *)
static constexpr HelpText FromFunctionPointer(const HelpGenFunc fn)
void * Clone(FlagOpFn op, const void *obj)
size_t Sizeof(FlagOpFn op)
bool IsSpecifiedOnCommandLine() const
const char *const filename
void *(*)(FlagOp, const void *, void *) FlagOpFn
void CopyConstruct(FlagOpFn op, const void *src, void *dst)
ABSL_DEPRECATED("temporary until FlagName call sites are migrated and validator API is " "changed") const char *NameAsCString() const
void *(*)(FlagOp, const void *, void *, void *) FlagMarshallingOpFn
HelpGenFunc help_function_
std::atomic< bool > inited
constexpr CommandLineFlag(const char *name_arg, HelpText help_text, const char *filename_arg, const flags_internal::FlagOpFn op_arg, const flags_internal::FlagMarshallingOpFn marshalling_op_arg, const flags_internal::InitialValGenFunc initial_value_gen, const bool retired_arg, void *def_arg, void *cur_arg)
void Copy(FlagOpFn op, const void *src, void *dst)
const char kStrippedFlagHelp[]
std::string Unparse(FlagMarshallingOpFn op, const void *val)
constexpr HelpText(const HelpGenFunc fn, const char *msg)
void *(*)() InitialValGenFunc
absl::string_view Name() const
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
void UpdateCopy(CommandLineFlag *flag, absl::Mutex *primary_lock) EXCLUSIVE_LOCKS_REQUIRED(primary_lock)
const FlagMarshallingOpFn marshalling_op
absl::Mutex * InitFlagIfNecessary(CommandLineFlag *flag) LOCK_RETURNED(flag -> locks->primary_mu)
void * FlagOps(FlagOp op, const void *v1, void *v2)
void * FlagMarshallingOps(FlagOp op, const void *v1, void *v2, void *v3)
bool ChangedDirectly(CommandLineFlag *flag, const void *a, const void *b)
std::atomic< int64_t > atomic