// Copyright 2022 The Abseil Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef ABSL_STRINGS_INTERNAL_STR_FORMAT_CONSTEXPR_PARSER_H_ #define ABSL_STRINGS_INTERNAL_STR_FORMAT_CONSTEXPR_PARSER_H_ #include <cassert> #include <cstdint> #include <cstdio> #include <limits> #include "absl/base/config.h" #include "absl/base/const_init.h" #include "absl/base/optimization.h" #include "absl/strings/internal/str_format/extension.h" namespace absl { ABSL_NAMESPACE_BEGIN namespace str_format_internal { // The analyzed properties of a single specified conversion. struct UnboundConversion { … }; // Helper tag class for the table below. // It allows fast `char -> ConversionChar/LengthMod/Flags` checking and // conversions. class ConvTag { … }; struct ConvTagHolder { … }; // Keep a single table for all the conversion chars and length modifiers. constexpr ConvTag GetTagForChar(char c) { … } constexpr bool CheckFastPathSetting(const UnboundConversion& conv) { … } constexpr int ParseDigits(char& c, const char*& pos, const char* const end) { … } template <bool is_positional> constexpr const char* ConsumeConversion(const char* pos, const char* const end, UnboundConversion* conv, int* next_arg) { … } // Consume conversion spec prefix (not including '%') of [p, end) if valid. // Examples of valid specs would be e.g.: "s", "d", "-12.6f". // If valid, it returns the first character following the conversion spec, // and the spec part is broken down and returned in 'conv'. // If invalid, returns nullptr. constexpr const char* ConsumeUnboundConversion(const char* p, const char* end, UnboundConversion* conv, int* next_arg) { … } } // namespace str_format_internal ABSL_NAMESPACE_END } // namespace absl #endif // ABSL_STRINGS_INTERNAL_STR_FORMAT_CONSTEXPR_PARSER_H_