Export of internal Abseil changes
-- 47f13ea42ae272c995b1cd5073a45e046fa325eb by Matthew Brown <matthewbr@google.com>: absl::StrFormat: Centralize FormatConversionCharSet vs FormatConversionSpec checking - Move it into a central location, rather than requiring individual overloads to validate. PiperOrigin-RevId: 310583805 -- a567c8fc8032031d551d6b457755851f442e65ad by Gennadiy Rozental <rogeeff@google.com>: Internal change PiperOrigin-RevId: 310427635 -- 49848f7fab9b0f528d33f60cbccf688e2ea68afa by Gennadiy Rozental <rogeeff@google.com>: Make Get/Set private methods of absl::Flag<T>. PiperOrigin-RevId: 310413908 GitOrigin-RevId: 47f13ea42ae272c995b1cd5073a45e046fa325eb Change-Id: I6530c754731c1a9463877561fa61786460ed60af
This commit is contained in:
parent
a35ef8a62c
commit
c45d1c09d5
8 changed files with 148 additions and 36 deletions
|
|
@ -86,10 +86,6 @@ template <class AbslCord, typename std::enable_if<std::is_same<
|
|||
StringConvertResult FormatConvertImpl(const AbslCord& value,
|
||||
FormatConversionSpecImpl conv,
|
||||
FormatSinkImpl* sink) {
|
||||
if (conv.conversion_char() != FormatConversionCharInternal::s) {
|
||||
return {false};
|
||||
}
|
||||
|
||||
bool is_left = conv.has_left_flag();
|
||||
size_t space_remaining = 0;
|
||||
|
||||
|
|
@ -249,6 +245,15 @@ struct FormatArgImplFriend {
|
|||
}
|
||||
};
|
||||
|
||||
template <typename Arg>
|
||||
constexpr FormatConversionCharSet ArgumentToConv() {
|
||||
return absl::str_format_internal::ExtractCharSet(
|
||||
decltype(str_format_internal::FormatConvertImpl(
|
||||
std::declval<const Arg&>(),
|
||||
std::declval<const FormatConversionSpecImpl&>(),
|
||||
std::declval<FormatSinkImpl*>())){});
|
||||
}
|
||||
|
||||
// A type-erased handle to a format argument.
|
||||
class FormatArgImpl {
|
||||
private:
|
||||
|
|
@ -411,9 +416,13 @@ class FormatArgImpl {
|
|||
return ToInt<T>(arg, static_cast<int*>(out), std::is_integral<T>(),
|
||||
std::is_enum<T>());
|
||||
}
|
||||
|
||||
if (ABSL_PREDICT_FALSE(!Contains(ArgumentToConv<T>(),
|
||||
spec.conversion_char()))) {
|
||||
return false;
|
||||
}
|
||||
return str_format_internal::FormatConvertImpl(
|
||||
Manager<T>::Value(arg), spec, static_cast<FormatSinkImpl*>(out))
|
||||
Manager<T>::Value(arg), spec,
|
||||
static_cast<FormatSinkImpl*>(out))
|
||||
.value;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue