10 #include <initializer_list> 14 #include <unordered_set> 22 {}, {}, {}, {}, {}, {}, {}, {},
23 {}, {}, {}, {}, {}, {}, {}, {},
24 {}, {}, {}, {}, {}, {}, {}, {},
25 {}, {}, {}, {}, {}, {}, {}, {},
26 {}, {}, {}, {}, {}, {}, {}, {},
27 {}, {}, {}, {}, {}, {}, {}, {},
28 {}, {}, {}, {}, {}, {}, {}, {},
29 {}, {}, {}, {}, {}, {}, {}, {},
30 {}, CC::A, {},
CC::C, {}, CC::E, CC::F, CC::G,
31 {}, {}, {}, {}, LM::L, {}, {}, {},
32 {}, {}, {}, CC::S, {}, {}, {}, {},
33 CC::X, {}, {}, {}, {}, {}, {}, {},
34 {},
CC::a, {}, CC::c, CC::d, CC::e, CC::f, CC::g,
36 CC::p, LM::q, {}, CC::s, LM::t, CC::u, {}, {},
37 CC::x, {}, LM::z, {}, {}, {}, {}, {},
38 {}, {}, {}, {}, {}, {}, {}, {},
39 {}, {}, {}, {}, {}, {}, {}, {},
40 {}, {}, {}, {}, {}, {}, {}, {},
41 {}, {}, {}, {}, {}, {}, {}, {},
42 {}, {}, {}, {}, {}, {}, {}, {},
43 {}, {}, {}, {}, {}, {}, {}, {},
44 {}, {}, {}, {}, {}, {}, {}, {},
45 {}, {}, {}, {}, {}, {}, {}, {},
46 {}, {}, {}, {}, {}, {}, {}, {},
47 {}, {}, {}, {}, {}, {}, {}, {},
48 {}, {}, {}, {}, {}, {}, {}, {},
49 {}, {}, {}, {}, {}, {}, {}, {},
50 {}, {}, {}, {}, {}, {}, {}, {},
51 {}, {}, {}, {}, {}, {}, {}, {},
52 {}, {}, {}, {}, {}, {}, {}, {},
53 {}, {}, {}, {}, {}, {}, {}, {},
59 bool should_be_basic = !conv.
flags.
left &&
68 "basic=%d left=%d show_pos=%d sign_col=%d alt=%d zero=%d " 69 "width=%d precision=%d\n",
77 template <
bool is_positional>
78 const char *ConsumeConversion(
const char *pos,
const char *
const end,
80 const char*
const original_pos = pos;
84 #define ABSL_FORMAT_PARSER_INTERNAL_GET_CHAR() \ 86 if (ABSL_PREDICT_FALSE(pos == end)) return nullptr; \ 90 const auto parse_digits = [&] {
95 int num_digits = std::numeric_limits<int>::digits10;
99 if (!std::isdigit(c))
break;
102 digits = 10 * digits + c -
'0';
155 int maybe_width = parse_digits();
156 if (!is_positional && c ==
'$') {
162 return ConsumeConversion<true>(original_pos,
end, conv, next_arg);
165 }
else if (c ==
'*') {
180 if (std::isdigit(c)) {
182 }
else if (c ==
'*') {
187 if (c !=
'$')
return nullptr;
220 assert(CheckFastPathSetting(*conv));
221 (void)(&CheckFastPathSetting);
223 conv->
conv = tag.as_conv();
232 if (*next_arg < 0)
return ConsumeConversion<true>(p,
end, conv, next_arg);
233 return ConsumeConversion<false>(p,
end, conv, next_arg);
241 if (s.empty())
return true;
245 if (!
parsed->items_.empty() && !
parsed->items_.back().is_conversion) {
247 parsed->items_.back().text_end = text_end;
250 parsed->items_.push_back({
false, text_end, {}});
255 bool ConvertOne(
const UnboundConversion &conv, string_view s) {
257 parsed->items_.push_back({
true, text_end, conv});
262 memcpy(
data_pos, s.data(), s.size());
264 return static_cast<size_t>(data_pos -
parsed->data_.get());
272 std::initializer_list<Conv> convs)
273 :
data_(format.empty() ? nullptr : new char[format.
size()]) {
279 bool allow_ignored, std::initializer_list<Conv> convs)
const {
280 std::unordered_set<int> used;
281 auto add_if_valid_conv = [&](
int pos,
char c) {
282 if (static_cast<size_t>(pos) > convs.size() ||
283 !
Contains(convs.begin()[pos - 1], c))
289 if (!item.is_conversion)
continue;
290 auto &conv = item.conv;
291 if (conv.precision.is_from_arg() &&
292 !add_if_valid_conv(conv.precision.get_from_arg(),
'*'))
294 if (conv.width.is_from_arg() &&
295 !add_if_valid_conv(conv.width.get_from_arg(),
'*'))
297 if (!add_if_valid_conv(conv.arg_position, conv.conv.Char()))
return false;
299 return used.size() == convs.size() || allow_ignored;
#define ABSL_PREDICT_FALSE(x)
constexpr T & get(variant< Types... > &v)
#define ABSL_FORMAT_PARSER_INTERNAL_GET_CHAR()
std::string format(const std::string &, const time_point< seconds > &, const femtoseconds &, const time_zone &)