1 #ifndef ABSL_STRINGS_INTERNAL_STR_FORMAT_PARSER_H_ 2 #define ABSL_STRINGS_INTERNAL_STR_FORMAT_PARSER_H_ 9 #include <initializer_list> 103 return kTags[
static_cast<unsigned char>(c)];
116 template <
typename Consumer>
119 const char* p = src.
data();
120 const char*
const end = p + src.
size();
122 const char* percent =
static_cast<const char*
>(memchr(p,
'%', end - p));
148 conv.
conv = tag.as_conv();
151 !consumer.ConvertOne(conv,
string_view(percent + 1, 1)))) {
154 }
else if (percent[1] !=
'%') {
159 conv,
string_view(percent + 1, p - (percent + 1))))) {
174 return s.
empty() || s[0] == s[0];
180 std::initializer_list<Conv> convs);
187 if (
this == &other)
return *
this;
190 size_t text_size = items_.empty() ? 0 : items_.back().text_end;
191 data_.reset(
new char[text_size]);
192 memcpy(
data_.get(), other.
data_.get(), text_size);
197 if (
this == &other)
return *
this;
202 other.items_.clear();
206 template <
typename Consumer>
208 const char*
const base =
data_.get();
210 for (
const auto& item : items_) {
212 text =
string_view(end, (base + item.text_end) - end);
213 if (item.is_conversion) {
214 if (!consumer.ConvertOne(item.conv, text))
return false;
216 if (!consumer.Append(text))
return false;
227 bool MatchesConversions(
bool allow_ignored,
228 std::initializer_list<Conv> convs)
const;
230 struct ParsedFormatConsumer;
277 #if ABSL_INTERNAL_ENABLE_FORMAT_CHECKER 280 "Format std::string is not constexpr."),
281 enable_if(str_format_internal::ValidFormatImpl<C...>(format),
282 "Format specified does not match the template arguments.")))
283 #endif // ABSL_INTERNAL_ENABLE_FORMAT_CHECKER 300 return New(format,
false);
304 return New(format,
true);
309 bool allow_ignored) {
310 std::unique_ptr<ExtendedParsedFormat>
conv(
312 if (conv->has_error())
return nullptr;
322 #endif // ABSL_STRINGS_INTERNAL_STR_FORMAT_PARSER_H_
#define ABSL_PREDICT_FALSE(x)
constexpr size_type size() const noexcept
std::string format(const std::string &, const time_point< seconds > &, const femtoseconds &, const time_zone &)
constexpr bool empty() const noexcept
constexpr const_pointer data() const noexcept
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept