29 namespace flags_internal {
35 const char* kTrue[] = {
"1",
"t",
"true",
"y",
"yes"};
36 const char* kFalse[] = {
"0",
"f",
"false",
"n",
"no"};
37 static_assert(
sizeof(kTrue) ==
sizeof(kFalse),
"true_false_equal");
60 const bool hex = (text.
size() >= 2 && text[0] ==
'0' &&
61 (text[1] ==
'x' || text[1] ==
'X'));
65 template <
typename IntType>
75 if (static_cast<short>(val) != val)
77 *dst =
static_cast<short>(val);
84 if (static_cast<unsigned short>(val) !=
87 *dst =
static_cast<unsigned short>(val);
131 dst->assign(text.
data(), text.
size());
153 std::string
Unparse(
bool v) {
return v ?
"true" :
"false"; }
162 template <
typename T>
166 std::string digit10_str =
168 if (std::isnan(v) || std::isinf(v))
return digit10_str;
173 roundtrip_val == v) {
179 return absl::StrFormat(
"%.*g", std::numeric_limits<T>::max_digits10, v);
ABSL_MUST_USE_RESULT std::string StrFormat(const FormatSpec< Args... > &format, const Args &... args)
std::string StrJoin(Iterator start, Iterator end, absl::string_view sep, Formatter &&fmt)
bool ParseFlagImpl(absl::string_view text, IntType *dst)
bool AbslParseFlag(absl::string_view text, bool *dst, std::string *)
std::string StrCat(const AlphaNum &a, const AlphaNum &b)
constexpr size_type size() const noexcept
bool SimpleAtod(absl::string_view str, double *out)
bool SimpleAtof(absl::string_view str, float *out)
strings_internal::Splitter< typename strings_internal::SelectDelimiter< Delimiter >::type, AllowEmpty > StrSplit(strings_internal::ConvertibleToStringView text, Delimiter d)
static int NumericBase(absl::string_view text)
ABSL_MUST_USE_RESULT absl::string_view StripAsciiWhitespace(absl::string_view str)
std::string Unparse(FlagMarshallingOpFn op, const void *val)
constexpr bool empty() const noexcept
ABSL_MUST_USE_RESULT bool safe_strtoi_base(absl::string_view s, int_type *out, int base)
std::string AbslUnparseFlag(absl::string_view v)
std::string UnparseFloatingPointVal(T v)
#define ABSL_ARRAYSIZE(array)
constexpr const_pointer data() const noexcept
bool ParseFlag(absl::string_view input, T *dst, std::string *error)
bool EqualsIgnoreCase(absl::string_view piece1, absl::string_view piece2)