28 namespace flags_internal {
42 assert(size <=
sizeof(int64_t));
43 memcpy(&t, data, size);
44 flag->
atomic.store(t, std::memory_order_release);
80 #define DONT_VALIDATE(T) \ 81 if (flag.IsOfType<T>()) return false; 96 #define STORE_ATOMIC(T) \ 97 else if (flag->IsOfType<T>()) { \ 98 StoreAtomic(flag, flag->cur, sizeof(T)); \ 106 InvokeCallback(flag, primary_lock);
114 if (!flag->inited.load(std::memory_order_acquire)) {
118 if (flag->locks ==
nullptr) {
121 mu = &flag->locks->primary_mu;
124 if (!flag->retired &&
125 flag->def ==
nullptr) {
126 flag->def = (*flag->make_init_value)();
127 flag->cur =
Clone(flag->op, flag->def);
131 flag->inited.store(
true, std::memory_order_release);
133 mu = &flag->locks->primary_mu;
142 #define CHANGED_FOR_TYPE(T) \ 143 if (flag->IsOfType<T>()) { \ 144 return *reinterpret_cast<const T*>(a) != *reinterpret_cast<const T*>(b); \ 153 #undef CHANGED_FOR_TYPE 194 "' is defined as one type and declared as another"));
211 "' is defined as one type and declared as another"));
214 if (ShouldValidateFlagValue(*
this)) {
215 void* obj =
Clone(op, src);
216 std::string ignored_error;
217 std::string src_as_str =
Unparse(marshalling_op, src);
218 if (!
Parse(marshalling_op, src_as_str, obj, &ignored_error) ||
221 "' to invalid value ", src_as_str));
236 if (IsAbseilFlag() || IsRetired())
return "";
238 #define HANDLE_V1_BUILTIN_TYPE(t) \ 239 if (IsOfType<t>()) { \ 248 #undef HANDLE_V1_BUILTIN_TYPE 250 if (IsOfType<std::string>()) {
262 return Unparse(this->marshalling_op, this->def);
266 return Unparse(this->marshalling_op, this->cur);
274 callback = mutation_callback;
276 InvokeCallback(
this, mu);
287 void* tentative_value =
Clone(flag->
op, flag->
def);
288 std::string parse_err;
293 *err =
absl::StrCat(
"Illegal value '", value,
"' specified for",
294 typename_sep, type_name,
" flag '", flag->
Name(),
"'",
300 if (!
Validate(flag, tentative_value)) {
303 "' for flag '", flag->
Name(),
"'");
309 Copy(flag->
op, tentative_value, dst);
325 if (IsRetired())
return false;
336 this->modified =
true;
340 this->on_command_line =
true;
346 if (!this->modified) {
348 this->modified =
true;
365 if (!this->modified) {
367 Copy(this->op, this->def, this->cur);
void Delete(FlagOpFn op, const void *obj)
#define EXCLUSIVE_LOCKS_REQUIRED(...)
const char * help_message_
bool IsAbseilFlag() const
bool Parse(FlagMarshallingOpFn op, absl::string_view text, void *dst, std::string *error)
static bool TryParseLocked(CommandLineFlag *flag, void *dst, absl::string_view value, std::string *err)
struct CommandLineFlagLocks * locks
void UpdateModifiedBit(CommandLineFlag *flag)
bool Validate(CommandLineFlag *, const void *)
void * Clone(FlagOpFn op, const void *obj)
std::string StrCat(const AlphaNum &a, const AlphaNum &b)
#define ABSL_PREDICT_FALSE(x)
void *(*)(FlagOp, const void *, void *) FlagOpFn
#define ABSL_FLAGS_INTERNAL_FOR_EACH_LOCK_FREE(A)
void CopyConstruct(FlagOpFn op, const void *src, void *dst)
std::string GetHelpText() const
HelpGenFunc help_function_
bool SetFromString(absl::string_view value, flags_internal::FlagSettingMode set_mode, flags_internal::ValueSource source, std::string *error)
#define CHANGED_FOR_TYPE(T)
#define ABSL_INTERNAL_LOG(severity, message)
static const int64_t kAtomicInit
#define HANDLE_V1_BUILTIN_TYPE(t)
void SetCallback(const flags_internal::FlagCallback mutation_callback)
void Unlock() UNLOCK_FUNCTION()
static char data[kDataSize]
void Copy(FlagOpFn op, const void *src, void *dst)
const char kStrippedFlagHelp[]
std::string Filename() const
FlagsUsageConfig GetUsageConfig()
std::string Unparse(FlagMarshallingOpFn op, const void *val)
constexpr bool empty() const noexcept
void Lock() EXCLUSIVE_LOCK_FUNCTION()
absl::string_view Typename() const
absl::string_view Name() const
void Read(void *dst, const flags_internal::FlagOpFn dst_op) const
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)
std::function< std::string(absl::string_view)> normalize_filename
bool ChangedDirectly(CommandLineFlag *flag, const void *a, const void *b)
std::string CurrentValue() const
void Write(const void *src, const flags_internal::FlagOpFn src_op)
std::string DefaultValue() const
std::atomic< int64_t > atomic