Export of internal Abseil changes
-- d35c72d705155dcd89a92835103540f14c643d10 by Gennadiy Rozental <rogeeff@google.com>: helpxml changed to report types of flags with built-in value type. PiperOrigin-RevId: 275131440 -- f3478792943d7dd40a6ef6083a8e5d374f43a65e by Abseil Team <absl-team@google.com>: Add space padding tests for hex conversions. PiperOrigin-RevId: 275120155 -- 7c2e4725403e173660f33f94af686a75d3722936 by Andy Soffer <asoffer@google.com>: Fix https://github.com/abseil/abseil-cpp/issues/379 by renaming `roundup` to `round_up` PiperOrigin-RevId: 275106110 -- 84cb30d6ee509961ac4359cfdda1360973b9527d by Laramie Leavitt <lar@google.com>: Move random_internal::wide_multiply into a file by the same name. PiperOrigin-RevId: 275059359 -- 06d691a8c187b5d899e7863784b23bdcfd580cb2 by Abseil Team <absl-team@google.com>: Add missing "return" keyword. PiperOrigin-RevId: 275036408 GitOrigin-RevId: d35c72d705155dcd89a92835103540f14c643d10 Change-Id: Id837b4de6c9cfe18f0a088363754bfe389df985b
This commit is contained in:
parent
ab3552a189
commit
a15364ce4d
12 changed files with 275 additions and 118 deletions
|
|
@ -47,6 +47,27 @@ namespace absl {
|
|||
namespace flags_internal {
|
||||
namespace {
|
||||
|
||||
absl::string_view TypenameForHelp(const flags_internal::CommandLineFlag& flag) {
|
||||
// Only report names of v1 built-in types
|
||||
#define HANDLE_V1_BUILTIN_TYPE(t) \
|
||||
if (flag.IsOfType<t>()) { \
|
||||
return #t; \
|
||||
}
|
||||
|
||||
HANDLE_V1_BUILTIN_TYPE(bool);
|
||||
HANDLE_V1_BUILTIN_TYPE(int32_t);
|
||||
HANDLE_V1_BUILTIN_TYPE(int64_t);
|
||||
HANDLE_V1_BUILTIN_TYPE(uint64_t);
|
||||
HANDLE_V1_BUILTIN_TYPE(double);
|
||||
#undef HANDLE_V1_BUILTIN_TYPE
|
||||
|
||||
if (flag.IsOfType<std::string>()) {
|
||||
return "string";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
// This class is used to emit an XML element with `tag` and `text`.
|
||||
// It adds opening and closing tags and escapes special characters in the text.
|
||||
// For example:
|
||||
|
|
@ -186,7 +207,7 @@ void FlagHelpHumanReadable(const flags_internal::CommandLineFlag& flag,
|
|||
|
||||
// Flag data type (for V1 flags only).
|
||||
if (!flag.IsAbseilFlag() && !flag.IsRetired()) {
|
||||
printer.Write(absl::StrCat("type: ", flag.Typename(), ";"));
|
||||
printer.Write(absl::StrCat("type: ", TypenameForHelp(flag), ";"));
|
||||
}
|
||||
|
||||
// The listed default value will be the actual default from the flag
|
||||
|
|
@ -223,6 +244,9 @@ void FlagsHelpImpl(std::ostream& out, flags_internal::FlagKindFilter filter_cb,
|
|||
} else {
|
||||
// XML schema is not a part of our public API for now.
|
||||
out << "<?xml version=\"1.0\"?>\n"
|
||||
<< "<!-- This output should be used with care. We do not report type "
|
||||
"names for flags with user defined types -->\n"
|
||||
<< "<!-- Prefer flag only_check_args for validating flag inputs -->\n"
|
||||
// The document.
|
||||
<< "<AllFlags>\n"
|
||||
// The program name and usage.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue