Export of internal Abseil changes.
-- f4bb8afa9376b4120f56f3beff7b07260da4a5c2 by CJ Johnson <johnsoncj@google.com>: Add user to Github list PiperOrigin-RevId: 209630262 GitOrigin-RevId: f4bb8afa9376b4120f56f3beff7b07260da4a5c2 Change-Id: I3fedf35011d805ee4a20b92e073b43523b47d15b
This commit is contained in:
parent
fefc83638f
commit
bed5bd6e18
54 changed files with 302 additions and 302 deletions
|
|
@ -91,7 +91,7 @@ static_assert(std::numeric_limits<int>::digits10 >= kDecimalExponentDigitsMax,
|
|||
|
||||
// To avoid incredibly large inputs causing integer overflow for our exponent,
|
||||
// we impose an arbitrary but very large limit on the number of significant
|
||||
// digits we will accept. The implementation refuses to match a std::string with
|
||||
// digits we will accept. The implementation refuses to match a string with
|
||||
// more consecutive significant mantissa digits than this.
|
||||
constexpr int kDecimalDigitLimit = 50000000;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,16 +29,16 @@ using absl::strings_internal::ParseFloat;
|
|||
|
||||
namespace {
|
||||
|
||||
// Check that a given std::string input is parsed to the expected mantissa and
|
||||
// Check that a given string input is parsed to the expected mantissa and
|
||||
// exponent.
|
||||
//
|
||||
// Input std::string `s` must contain a '$' character. It marks the end of the
|
||||
// Input string `s` must contain a '$' character. It marks the end of the
|
||||
// characters that should be consumed by the match. It is stripped from the
|
||||
// input to ParseFloat.
|
||||
//
|
||||
// If input std::string `s` contains '[' and ']' characters, these mark the region
|
||||
// If input string `s` contains '[' and ']' characters, these mark the region
|
||||
// of characters that should be marked as the "subrange". For NaNs, this is
|
||||
// the location of the extended NaN std::string. For numbers, this is the location
|
||||
// the location of the extended NaN string. For numbers, this is the location
|
||||
// of the full, over-large mantissa.
|
||||
template <int base>
|
||||
void ExpectParsedFloat(std::string s, absl::chars_format format_flags,
|
||||
|
|
@ -92,10 +92,10 @@ void ExpectParsedFloat(std::string s, absl::chars_format format_flags,
|
|||
EXPECT_EQ(characters_matched, expected_characters_matched);
|
||||
}
|
||||
|
||||
// Check that a given std::string input is parsed to the expected mantissa and
|
||||
// Check that a given string input is parsed to the expected mantissa and
|
||||
// exponent.
|
||||
//
|
||||
// Input std::string `s` must contain a '$' character. It marks the end of the
|
||||
// Input string `s` must contain a '$' character. It marks the end of the
|
||||
// characters that were consumed by the match.
|
||||
template <int base>
|
||||
void ExpectNumber(std::string s, absl::chars_format format_flags,
|
||||
|
|
@ -106,7 +106,7 @@ void ExpectNumber(std::string s, absl::chars_format format_flags,
|
|||
expected_literal_exponent);
|
||||
}
|
||||
|
||||
// Check that a given std::string input is parsed to the given special value.
|
||||
// Check that a given string input is parsed to the given special value.
|
||||
//
|
||||
// This tests against both number bases, since infinities and NaNs have
|
||||
// identical representations in both modes.
|
||||
|
|
@ -116,7 +116,7 @@ void ExpectSpecial(const std::string& s, absl::chars_format format_flags,
|
|||
ExpectParsedFloat<16>(s, format_flags, type, 0, 0);
|
||||
}
|
||||
|
||||
// Check that a given input std::string is not matched by Float.
|
||||
// Check that a given input string is not matched by Float.
|
||||
template <int base>
|
||||
void ExpectFailedParse(absl::string_view s, absl::chars_format format_flags) {
|
||||
ParsedFloat parsed =
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
// limitations under the License.
|
||||
//
|
||||
|
||||
// These routines provide mem versions of standard C std::string routines,
|
||||
// These routines provide mem versions of standard C string routines,
|
||||
// such as strpbrk. They function exactly the same as the str versions,
|
||||
// so if you wonder what they are, replace the word "mem" by
|
||||
// "str" and check out the man page. I could return void*, as the
|
||||
|
|
@ -22,14 +22,14 @@
|
|||
// since this is by far the most common way these functions are called.
|
||||
//
|
||||
// The difference between the mem and str versions is the mem version
|
||||
// takes a pointer and a length, rather than a '\0'-terminated std::string.
|
||||
// takes a pointer and a length, rather than a '\0'-terminated string.
|
||||
// The memcase* routines defined here assume the locale is "C"
|
||||
// (they use absl::ascii_tolower instead of tolower).
|
||||
//
|
||||
// These routines are based on the BSD library.
|
||||
//
|
||||
// Here's a list of routines from std::string.h, and their mem analogues.
|
||||
// Functions in lowercase are defined in std::string.h; those in UPPERCASE
|
||||
// Here's a list of routines from string.h, and their mem analogues.
|
||||
// Functions in lowercase are defined in string.h; those in UPPERCASE
|
||||
// are defined here:
|
||||
//
|
||||
// strlen --
|
||||
|
|
|
|||
|
|
@ -25,18 +25,18 @@
|
|||
namespace absl {
|
||||
namespace strings_internal {
|
||||
|
||||
// The same as std::ostringstream but appends to a user-specified std::string,
|
||||
// The same as std::ostringstream but appends to a user-specified string,
|
||||
// and is faster. It is ~70% faster to create, ~50% faster to write to, and
|
||||
// completely free to extract the result std::string.
|
||||
// completely free to extract the result string.
|
||||
//
|
||||
// std::string s;
|
||||
// string s;
|
||||
// OStringStream strm(&s);
|
||||
// strm << 42 << ' ' << 3.14; // appends to `s`
|
||||
//
|
||||
// The stream object doesn't have to be named. Starting from C++11 operator<<
|
||||
// works with rvalues of std::ostream.
|
||||
//
|
||||
// std::string s;
|
||||
// string s;
|
||||
// OStringStream(&s) << 42 << ' ' << 3.14; // appends to `s`
|
||||
//
|
||||
// OStringStream is faster to create than std::ostringstream but it's still
|
||||
|
|
@ -45,14 +45,14 @@ namespace strings_internal {
|
|||
//
|
||||
// Creates unnecessary instances of OStringStream: slow.
|
||||
//
|
||||
// std::string s;
|
||||
// string s;
|
||||
// OStringStream(&s) << 42;
|
||||
// OStringStream(&s) << ' ';
|
||||
// OStringStream(&s) << 3.14;
|
||||
//
|
||||
// Creates a single instance of OStringStream and reuses it: fast.
|
||||
//
|
||||
// std::string s;
|
||||
// string s;
|
||||
// OStringStream strm(&s);
|
||||
// strm << 42;
|
||||
// strm << ' ';
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ void ResizeUninit(string_type* s, size_t new_size, std::false_type) {
|
|||
s->resize(new_size);
|
||||
}
|
||||
|
||||
// Returns true if the std::string implementation supports a resize where
|
||||
// the new characters added to the std::string are left untouched.
|
||||
// Returns true if the string implementation supports a resize where
|
||||
// the new characters added to the string are left untouched.
|
||||
//
|
||||
// (A better name might be "STLStringSupportsUninitializedResize", alluding to
|
||||
// the previous function.)
|
||||
|
|
@ -57,7 +57,7 @@ inline constexpr bool STLStringSupportsNontrashingResize(string_type*) {
|
|||
// Like str->resize(new_size), except any new characters added to "*str" as a
|
||||
// result of resizing may be left uninitialized, rather than being filled with
|
||||
// '0' bytes. Typically used when code is then going to overwrite the backing
|
||||
// store of the std::string with known data. Uses a Google extension to std::string.
|
||||
// store of the string with known data. Uses a Google extension to ::string.
|
||||
template <typename string_type, typename = void>
|
||||
inline void STLStringResizeUninitialized(string_type* s, size_t new_size) {
|
||||
ResizeUninit(s, new_size, HasResizeUninitialized<string_type>());
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ int FprintF(std::FILE* output, const UntypedFormatSpecImpl& format,
|
|||
int SnprintF(char* output, size_t size, const UntypedFormatSpecImpl& format,
|
||||
absl::Span<const FormatArgImpl> args);
|
||||
|
||||
// Returned by Streamed(v). Converts via '%s' to the std::string created
|
||||
// Returned by Streamed(v). Converts via '%s' to the string created
|
||||
// by std::ostream << v.
|
||||
template <typename T>
|
||||
class StreamedWrapper {
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class FormatRawSinkImpl {
|
|||
void (*write_)(void*, string_view);
|
||||
};
|
||||
|
||||
// An abstraction to which conversions write their std::string data.
|
||||
// An abstraction to which conversions write their string data.
|
||||
class FormatSinkImpl {
|
||||
public:
|
||||
explicit FormatSinkImpl(FormatRawSinkImpl raw) : raw_(raw) {}
|
||||
|
|
|
|||
|
|
@ -75,14 +75,14 @@ struct UnboundConversion {
|
|||
bool ConsumeUnboundConversion(string_view* src, UnboundConversion* conv,
|
||||
int* next_arg);
|
||||
|
||||
// Parse the format std::string provided in 'src' and pass the identified items into
|
||||
// Parse the format string provided in 'src' and pass the identified items into
|
||||
// 'consumer'.
|
||||
// Text runs will be passed by calling
|
||||
// Consumer::Append(string_view);
|
||||
// ConversionItems will be passed by calling
|
||||
// Consumer::ConvertOne(UnboundConversion, string_view);
|
||||
// In the case of ConvertOne, the string_view that is passed is the
|
||||
// portion of the format std::string corresponding to the conversion, not including
|
||||
// portion of the format string corresponding to the conversion, not including
|
||||
// the leading %. On success, it returns true. On failure, it stops and returns
|
||||
// false.
|
||||
template <typename Consumer>
|
||||
|
|
@ -237,7 +237,7 @@ class ParsedFormatBase {
|
|||
// This class also supports runtime format checking with the ::New() and
|
||||
// ::NewAllowIgnored() factory functions.
|
||||
// This is the only API that allows the user to pass a runtime specified format
|
||||
// std::string. These factory functions will return NULL if the format does not match
|
||||
// string. These factory functions will return NULL if the format does not match
|
||||
// the conversions requested by the user.
|
||||
template <str_format_internal::Conv... C>
|
||||
class ExtendedParsedFormat : public str_format_internal::ParsedFormatBase {
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ struct DefaultFormatter<std::unique_ptr<ValueType>>
|
|||
//
|
||||
|
||||
// The main joining algorithm. This simply joins the elements in the given
|
||||
// iterator range, each separated by the given separator, into an output std::string,
|
||||
// iterator range, each separated by the given separator, into an output string,
|
||||
// and formats each element using the provided Formatter object.
|
||||
template <typename Iterator, typename Formatter>
|
||||
std::string JoinAlgorithm(Iterator start, Iterator end, absl::string_view s,
|
||||
|
|
@ -205,20 +205,20 @@ std::string JoinAlgorithm(Iterator start, Iterator end, absl::string_view s,
|
|||
}
|
||||
|
||||
// A joining algorithm that's optimized for a forward iterator range of
|
||||
// std::string-like objects that do not need any additional formatting. This is to
|
||||
// optimize the common case of joining, say, a std::vector<std::string> or a
|
||||
// string-like objects that do not need any additional formatting. This is to
|
||||
// optimize the common case of joining, say, a std::vector<string> or a
|
||||
// std::vector<absl::string_view>.
|
||||
//
|
||||
// This is an overload of the previous JoinAlgorithm() function. Here the
|
||||
// Formatter argument is of type NoFormatter. Since NoFormatter is an internal
|
||||
// type, this overload is only invoked when strings::Join() is called with a
|
||||
// range of std::string-like objects (e.g., std::string, absl::string_view), and an
|
||||
// range of string-like objects (e.g., string, absl::string_view), and an
|
||||
// explicit Formatter argument was NOT specified.
|
||||
//
|
||||
// The optimization is that the needed space will be reserved in the output
|
||||
// std::string to avoid the need to resize while appending. To do this, the iterator
|
||||
// string to avoid the need to resize while appending. To do this, the iterator
|
||||
// range will be traversed twice: once to calculate the total needed size, and
|
||||
// then again to copy the elements and delimiters to the output std::string.
|
||||
// then again to copy the elements and delimiters to the output string.
|
||||
template <typename Iterator,
|
||||
typename = typename std::enable_if<std::is_convertible<
|
||||
typename std::iterator_traits<Iterator>::iterator_category,
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ namespace strings_internal {
|
|||
|
||||
// This class is implicitly constructible from everything that absl::string_view
|
||||
// is implicitly constructible from. If it's constructed from a temporary
|
||||
// std::string, the data is moved into a data member so its lifetime matches that of
|
||||
// string, the data is moved into a data member so its lifetime matches that of
|
||||
// the ConvertibleToStringView instance.
|
||||
class ConvertibleToStringView {
|
||||
public:
|
||||
|
|
@ -102,7 +102,7 @@ ConvertibleToStringView(std::string&& s) // NOLINT(runtime/explicit)
|
|||
absl::string_view value_;
|
||||
};
|
||||
|
||||
// An iterator that enumerates the parts of a std::string from a Splitter. The text
|
||||
// An iterator that enumerates the parts of a string from a Splitter. The text
|
||||
// to be split, the Delimiter, and the Predicate are all taken from the given
|
||||
// Splitter object. Iterators may only be compared if they refer to the same
|
||||
// Splitter instance.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue