From 582e4baf37cdfe23f17d4c6ca8fdd912108cfd29 Mon Sep 17 00:00:00 2001 From: Gil Date: Tue, 6 Feb 2018 09:35:10 -0800 Subject: Add StrCat, StrJoin and the rest of //strings from abseil-cpp (#756) From abseil-cpp version bf7fc9986e20f664958fc227547fd8d2fdcf863e --- .../abseil-cpp/absl/memory/CMakeLists.txt | 52 + .../third_party/abseil-cpp/absl/memory/memory.h | 640 +++++++++++ .../abseil-cpp/absl/memory/memory_test.cc | 614 ++++++++++ .../abseil-cpp/absl/numeric/CMakeLists.txt | 62 + .../third_party/abseil-cpp/absl/numeric/int128.cc | 206 ++++ .../third_party/abseil-cpp/absl/numeric/int128.h | 632 +++++++++++ .../absl/numeric/int128_have_intrinsic.inc | 3 + .../absl/numeric/int128_no_intrinsic.inc | 3 + .../abseil-cpp/absl/numeric/int128_stream_test.cc | 666 +++++++++++ .../abseil-cpp/absl/numeric/int128_test.cc | 429 +++++++ .../abseil-cpp/absl/strings/escaping.cc | 1109 ++++++++++++++++++ .../third_party/abseil-cpp/absl/strings/escaping.h | 161 +++ .../abseil-cpp/absl/strings/escaping_test.cc | 640 +++++++++++ .../abseil-cpp/absl/strings/internal/char_map.h | 154 +++ .../absl/strings/internal/char_map_test.cc | 172 +++ .../absl/strings/internal/escaping_test_common.inc | 113 ++ .../absl/strings/internal/numbers_test_common.inc | 156 +++ .../absl/strings/internal/ostringstream.cc | 34 + .../absl/strings/internal/ostringstream.h | 87 ++ .../absl/strings/internal/ostringstream_test.cc | 102 ++ .../absl/strings/internal/stl_type_traits.h | 213 ++++ .../absl/strings/internal/str_join_internal.h | 309 +++++ .../absl/strings/internal/str_split_internal.h | 435 +++++++ .../abseil-cpp/absl/strings/internal/utf8.cc | 51 + .../abseil-cpp/absl/strings/internal/utf8.h | 51 + .../abseil-cpp/absl/strings/internal/utf8_test.cc | 57 + .../third_party/abseil-cpp/absl/strings/numbers.cc | 919 +++++++++++++++ .../third_party/abseil-cpp/absl/strings/numbers.h | 172 +++ .../abseil-cpp/absl/strings/numbers_test.cc | 1186 ++++++++++++++++++++ .../third_party/abseil-cpp/absl/strings/str_cat.cc | 208 ++++ .../third_party/abseil-cpp/absl/strings/str_cat.h | 347 ++++++ .../abseil-cpp/absl/strings/str_cat_test.cc | 468 ++++++++ .../third_party/abseil-cpp/absl/strings/str_join.h | 288 +++++ .../abseil-cpp/absl/strings/str_join_test.cc | 473 ++++++++ .../abseil-cpp/absl/strings/str_replace.cc | 79 ++ .../abseil-cpp/absl/strings/str_replace.h | 213 ++++ .../abseil-cpp/absl/strings/str_replace_test.cc | 341 ++++++ .../abseil-cpp/absl/strings/str_split.cc | 136 +++ .../abseil-cpp/absl/strings/str_split.h | 511 +++++++++ .../abseil-cpp/absl/strings/str_split_test.cc | 902 +++++++++++++++ .../third_party/abseil-cpp/absl/strings/strip.h | 89 ++ .../abseil-cpp/absl/strings/strip_test.cc | 181 +++ .../abseil-cpp/absl/strings/substitute.cc | 117 ++ .../abseil-cpp/absl/strings/substitute.h | 664 +++++++++++ .../abseil-cpp/absl/strings/substitute_test.cc | 168 +++ 45 files changed, 14613 insertions(+) create mode 100644 Firestore/third_party/abseil-cpp/absl/memory/CMakeLists.txt create mode 100644 Firestore/third_party/abseil-cpp/absl/memory/memory.h create mode 100644 Firestore/third_party/abseil-cpp/absl/memory/memory_test.cc create mode 100644 Firestore/third_party/abseil-cpp/absl/numeric/CMakeLists.txt create mode 100644 Firestore/third_party/abseil-cpp/absl/numeric/int128.cc create mode 100644 Firestore/third_party/abseil-cpp/absl/numeric/int128.h create mode 100644 Firestore/third_party/abseil-cpp/absl/numeric/int128_have_intrinsic.inc create mode 100644 Firestore/third_party/abseil-cpp/absl/numeric/int128_no_intrinsic.inc create mode 100644 Firestore/third_party/abseil-cpp/absl/numeric/int128_stream_test.cc create mode 100644 Firestore/third_party/abseil-cpp/absl/numeric/int128_test.cc create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/escaping.cc create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/escaping.h create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/escaping_test.cc create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/internal/char_map.h create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/internal/char_map_test.cc create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/internal/escaping_test_common.inc create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/internal/numbers_test_common.inc create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/internal/ostringstream.cc create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/internal/ostringstream.h create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/internal/ostringstream_test.cc create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/internal/stl_type_traits.h create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/internal/str_join_internal.h create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/internal/utf8.cc create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/internal/utf8.h create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/internal/utf8_test.cc create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/numbers.cc create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/numbers.h create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/numbers_test.cc create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/str_cat.cc create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/str_cat.h create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/str_cat_test.cc create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/str_join.h create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/str_join_test.cc create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/str_replace.cc create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/str_replace.h create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/str_replace_test.cc create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/str_split.cc create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/str_split.h create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/str_split_test.cc create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/strip.h create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/strip_test.cc create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/substitute.cc create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/substitute.h create mode 100644 Firestore/third_party/abseil-cpp/absl/strings/substitute_test.cc (limited to 'Firestore/third_party') diff --git a/Firestore/third_party/abseil-cpp/absl/memory/CMakeLists.txt b/Firestore/third_party/abseil-cpp/absl/memory/CMakeLists.txt new file mode 100644 index 0000000..21bfc87 --- /dev/null +++ b/Firestore/third_party/abseil-cpp/absl/memory/CMakeLists.txt @@ -0,0 +1,52 @@ +# +# Copyright 2017 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 +# +# http://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. +# + +list(APPEND MEMORY_PUBLIC_HEADERS + "memory.h" +) + + +absl_header_library( + TARGET + absl_memory + EXPORT_NAME + memory +) + +# +## TESTS +# + +# test memory_test +list(APPEND MEMORY_TEST_SRC + "memory_test.cc" + ${MEMORY_PUBLIC_HEADERS} +) +set(MEMORY_TEST_PUBLIC_LIBRARIES absl::base absl::memory) + + + +absl_test( + TARGET + memory_test + SOURCES + ${MEMORY_TEST_SRC} + PUBLIC_LIBRARIES + ${MEMORY_TEST_PUBLIC_LIBRARIES} +) + + + diff --git a/Firestore/third_party/abseil-cpp/absl/memory/memory.h b/Firestore/third_party/abseil-cpp/absl/memory/memory.h new file mode 100644 index 0000000..2220ee4 --- /dev/null +++ b/Firestore/third_party/abseil-cpp/absl/memory/memory.h @@ -0,0 +1,640 @@ +// Copyright 2017 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 +// +// http://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. +// +// ----------------------------------------------------------------------------- +// File: memory.h +// ----------------------------------------------------------------------------- +// +// This header file contains utility functions for managing the creation and +// conversion of smart pointers. This file is an extension to the C++ +// standard library header file. + +#ifndef ABSL_MEMORY_MEMORY_H_ +#define ABSL_MEMORY_MEMORY_H_ + +#include +#include +#include +#include +#include +#include + +#include "absl/base/macros.h" +#include "absl/meta/type_traits.h" + +namespace absl { + +// ----------------------------------------------------------------------------- +// Function Template: WrapUnique() +// ----------------------------------------------------------------------------- +// +// Adopts ownership from a raw pointer and transfers it to the returned +// `std::unique_ptr`, whose type is deduced. +// +// Example: +// X* NewX(int, int); +// auto x = WrapUnique(NewX(1, 2)); // 'x' is std::unique_ptr. +// +// `absl::WrapUnique` is useful for capturing the output of a raw pointer +// factory. However, prefer 'absl::make_unique(args...) over +// 'absl::WrapUnique(new T(args...))'. +// +// auto x = WrapUnique(new X(1, 2)); // works, but nonideal. +// auto x = make_unique(1, 2); // safer, standard, avoids raw 'new'. +// +// Note that `absl::WrapUnique(p)` is valid only if `delete p` is a valid +// expression. In particular, `absl::WrapUnique()` cannot wrap pointers to +// arrays, functions or void, and it must not be used to capture pointers +// obtained from array-new expressions (even though that would compile!). +template +std::unique_ptr WrapUnique(T* ptr) { + static_assert(!std::is_array::value, "array types are unsupported"); + static_assert(std::is_object::value, "non-object types are unsupported"); + return std::unique_ptr(ptr); +} + +namespace memory_internal { + +// Traits to select proper overload and return type for `absl::make_unique<>`. +template +struct MakeUniqueResult { + using scalar = std::unique_ptr; +}; +template +struct MakeUniqueResult { + using array = std::unique_ptr; +}; +template +struct MakeUniqueResult { + using invalid = void; +}; + +} // namespace memory_internal + +#if __cplusplus >= 201402L || defined(_MSC_VER) +using std::make_unique; +#else +// ----------------------------------------------------------------------------- +// Function Template: make_unique() +// ----------------------------------------------------------------------------- +// +// Creates a `std::unique_ptr<>`, while avoiding issues creating temporaries +// during the construction process. `absl::make_unique<>` also avoids redundant +// type declarations, by avoiding the need to explicitly use the `new` operator. +// +// This implementation of `absl::make_unique<>` is designed for C++11 code and +// will be replaced in C++14 by the equivalent `std::make_unique<>` abstraction. +// `absl::make_unique<>` is designed to be 100% compatible with +// `std::make_unique<>` so that the eventual migration will involve a simple +// rename operation. +// +// For more background on why `std::unique_ptr(new T(a,b))` is problematic, +// see Herb Sutter's explanation on +// (Exception-Safe Function Calls)[http://herbsutter.com/gotw/_102/]. +// (In general, reviewers should treat `new T(a,b)` with scrutiny.) +// +// Example usage: +// +// auto p = make_unique(args...); // 'p' is a std::unique_ptr +// auto pa = make_unique(5); // 'pa' is a std::unique_ptr +// +// Three overloads of `absl::make_unique` are required: +// +// - For non-array T: +// +// Allocates a T with `new T(std::forward args...)`, +// forwarding all `args` to T's constructor. +// Returns a `std::unique_ptr` owning that object. +// +// - For an array of unknown bounds T[]: +// +// `absl::make_unique<>` will allocate an array T of type U[] with +// `new U[n]()` and return a `std::unique_ptr` owning that array. +// +// Note that 'U[n]()' is different from 'U[n]', and elements will be +// value-initialized. Note as well that `std::unique_ptr` will perform its +// own destruction of the array elements upon leaving scope, even though +// the array [] does not have a default destructor. +// +// NOTE: an array of unknown bounds T[] may still be (and often will be) +// initialized to have a size, and will still use this overload. E.g: +// +// auto my_array = absl::make_unique(10); +// +// - For an array of known bounds T[N]: +// +// `absl::make_unique<>` is deleted (like with `std::make_unique<>`) as +// this overload is not useful. +// +// NOTE: an array of known bounds T[N] is not considered a useful +// construction, and may cause undefined behavior in templates. E.g: +// +// auto my_array = absl::make_unique(); +// +// In those cases, of course, you can still use the overload above and +// simply initialize it to its desired size: +// +// auto my_array = absl::make_unique(10); + +// `absl::make_unique` overload for non-array types. +template +typename memory_internal::MakeUniqueResult::scalar make_unique( + Args&&... args) { + return std::unique_ptr(new T(std::forward(args)...)); +} + +// `absl::make_unique` overload for an array T[] of unknown bounds. +// The array allocation needs to use the `new T[size]` form and cannot take +// element constructor arguments. The `std::unique_ptr` will manage destructing +// these array elements. +template +typename memory_internal::MakeUniqueResult::array make_unique(size_t n) { + return std::unique_ptr(new typename absl::remove_extent_t[n]()); +} + +// `absl::make_unique` overload for an array T[N] of known bounds. +// This construction will be rejected. +template +typename memory_internal::MakeUniqueResult::invalid make_unique( + Args&&... /* args */) = delete; +#endif + +// ----------------------------------------------------------------------------- +// Function Template: RawPtr() +// ----------------------------------------------------------------------------- +// +// Extracts the raw pointer from a pointer-like value `ptr`. `absl::RawPtr` is +// useful within templates that need to handle a complement of raw pointers, +// `std::nullptr_t`, and smart pointers. +template +auto RawPtr(T&& ptr) -> decltype(&*ptr) { + // ptr is a forwarding reference to support Ts with non-const operators. + return (ptr != nullptr) ? &*ptr : nullptr; +} +inline std::nullptr_t RawPtr(std::nullptr_t) { return nullptr; } + +// ----------------------------------------------------------------------------- +// Function Template: ShareUniquePtr() +// ----------------------------------------------------------------------------- +// +// Adopts a `std::unique_ptr` rvalue and returns a `std::shared_ptr` of deduced +// type. Ownership (if any) of the held value is transferred to the returned +// shared pointer. +// +// Example: +// +// auto up = absl::make_unique(10); +// auto sp = absl::ShareUniquePtr(std::move(up)); // shared_ptr +// CHECK_EQ(*sp, 10); +// CHECK(up == nullptr); +// +// Note that this conversion is correct even when T is an array type, and more +// generally it works for *any* deleter of the `unique_ptr` (single-object +// deleter, array deleter, or any custom deleter), since the deleter is adopted +// by the shared pointer as well. The deleter is copied (unless it is a +// reference). +// +// Implements the resolution of [LWG 2415](http://wg21.link/lwg2415), by which a +// null shared pointer does not attempt to call the deleter. +template +std::shared_ptr ShareUniquePtr(std::unique_ptr&& ptr) { + return ptr ? std::shared_ptr(std::move(ptr)) : std::shared_ptr(); +} + +// ----------------------------------------------------------------------------- +// Function Template: WeakenPtr() +// ----------------------------------------------------------------------------- +// +// Creates a weak pointer associated with a given shared pointer. The returned +// value is a `std::weak_ptr` of deduced type. +// +// Example: +// +// auto sp = std::make_shared(10); +// auto wp = absl::WeakenPtr(sp); +// CHECK_EQ(sp.get(), wp.lock().get()); +// sp.reset(); +// CHECK(wp.lock() == nullptr); +// +template +std::weak_ptr WeakenPtr(const std::shared_ptr& ptr) { + return std::weak_ptr(ptr); +} + +namespace memory_internal { + +// ExtractOr::type evaluates to E if possible. Otherwise, D. +template