From d95d1567165d449e4c213ea31a15cbb112a9865f Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Fri, 7 Feb 2020 13:06:07 -0800 Subject: Export of internal Abseil changes -- 832be2d52d7695cf72fd70248909791fb8ad1003 by Gennadiy Rozental : Migrate some FlagImpl fields to bit fields. To save padding space we are migrating some fields representing bool and enums into bit fields. Eventually we'll use remaining padding space for call_once control flag. No other semantic changes made in this CL. PiperOrigin-RevId: 293878165 -- 09162bba5fd8eddacfd732d46fcfeb33074a259f by Samuel Benzaquen : Correctly initialize the `length_mod` member. Now that it is a raw enum, the default initialization is not enough. PiperOrigin-RevId: 293827817 -- 842b7b805d75c5ab670c52ccd7368cdeba11853d by Matthew Brown : Move str_format_internal::LengthMod from extension.h to parser.h; change to enum PiperOrigin-RevId: 293697274 GitOrigin-RevId: 832be2d52d7695cf72fd70248909791fb8ad1003 Change-Id: I90899519e9480543e22638616fdf31a41e7f75c0 --- absl/strings/internal/str_format/parser.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'absl/strings/internal/str_format/parser.h') diff --git a/absl/strings/internal/str_format/parser.h b/absl/strings/internal/str_format/parser.h index 116dda06d4e2..6cbe257697e4 100644 --- a/absl/strings/internal/str_format/parser.h +++ b/absl/strings/internal/str_format/parser.h @@ -6,10 +6,12 @@ #include #include +#include #include #include #include #include +#include #include #include "absl/strings/internal/str_format/checker.h" @@ -19,6 +21,10 @@ namespace absl { ABSL_NAMESPACE_BEGIN namespace str_format_internal { +enum class LengthMod : std::uint8_t { h, hh, l, ll, L, j, z, t, q, none }; + +std::string LengthModToString(LengthMod v); + // The analyzed properties of a single specified conversion. struct UnboundConversion { UnboundConversion() @@ -60,7 +66,7 @@ struct UnboundConversion { InputValue precision; Flags flags; - LengthMod length_mod; + LengthMod length_mod = LengthMod::none; ConversionChar conv; }; @@ -79,7 +85,8 @@ class ConvTag { constexpr ConvTag(ConversionChar::Id id) : tag_(id) {} // NOLINT // We invert the length modifiers to make them negative so that we can easily // test for them. - constexpr ConvTag(LengthMod::Id id) : tag_(~id) {} // NOLINT + constexpr ConvTag(LengthMod length_mod) // NOLINT + : tag_(~static_cast(length_mod)) {} // Everything else is -128, which is negative to make is_conv() simpler. constexpr ConvTag() : tag_(-128) {} @@ -91,7 +98,7 @@ class ConvTag { } LengthMod as_length() const { assert(is_length()); - return LengthMod::FromId(static_cast(~tag_)); + return static_cast(~tag_); } private: -- cgit 1.4.1