#include "absl/strings/cord.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <ios>
#include <iostream>
#include <limits>
#include <memory>
#include <ostream>
#include <sstream>
#include <string>
#include <utility>
#include "absl/base/attributes.h"
#include "absl/base/config.h"
#include "absl/base/internal/endian.h"
#include "absl/base/internal/raw_logging.h"
#include "absl/base/macros.h"
#include "absl/base/optimization.h"
#include "absl/base/nullability.h"
#include "absl/container/inlined_vector.h"
#include "absl/crc/crc32c.h"
#include "absl/crc/internal/crc_cord_state.h"
#include "absl/functional/function_ref.h"
#include "absl/strings/cord_buffer.h"
#include "absl/strings/escaping.h"
#include "absl/strings/internal/cord_data_edge.h"
#include "absl/strings/internal/cord_internal.h"
#include "absl/strings/internal/cord_rep_btree.h"
#include "absl/strings/internal/cord_rep_crc.h"
#include "absl/strings/internal/cord_rep_flat.h"
#include "absl/strings/internal/cordz_update_tracker.h"
#include "absl/strings/internal/resize_uninitialized.h"
#include "absl/strings/match.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
#include "absl/strings/strip.h"
#include "absl/types/optional.h"
#include "absl/types/span.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
CordRep;
CordRepBtree;
CordRepCrc;
CordRepExternal;
CordRepFlat;
CordRepSubstring;
CordzUpdateTracker;
InlineData;
kMaxFlatLength;
kMinFlatLength;
kInlinedVectorSize;
kMaxBytesToCopy;
static void DumpNode(absl::Nonnull<CordRep*> nonnull_rep, bool include_data,
absl::Nonnull<std::ostream*> os, int indent = 0);
static bool VerifyNode(absl::Nonnull<CordRep*> root,
absl::Nonnull<CordRep*> start_node);
static inline absl::Nullable<CordRep*> VerifyTree(
absl::Nullable<CordRep*> node) { … }
static absl::Nonnull<CordRepFlat*> CreateFlat(absl::Nonnull<const char*> data,
size_t length,
size_t alloc_hint) { … }
static absl::Nonnull<CordRep*> NewBtree(absl::Nonnull<const char*> data,
size_t length, size_t alloc_hint) { … }
static absl::Nullable<CordRep*> NewTree(absl::Nullable<const char*> data,
size_t length, size_t alloc_hint) { … }
namespace cord_internal {
void InitializeCordRepExternal(absl::string_view data,
absl::Nonnull<CordRepExternal*> rep) { … }
}
static absl::Nonnull<CordRep*> CordRepFromString(std::string&& src) { … }
#ifdef ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
constexpr unsigned char Cord::InlineRep::kMaxInline;
#endif
inline void Cord::InlineRep::set_data(absl::Nonnull<const char*> data,
size_t n) { … }
inline absl::Nonnull<char*> Cord::InlineRep::set_data(size_t n) { … }
inline void Cord::InlineRep::reduce_size(size_t n) { … }
inline void Cord::InlineRep::remove_prefix(size_t n) { … }
static absl::Nonnull<CordRepBtree*> ForceBtree(CordRep* rep) { … }
void Cord::InlineRep::AppendTreeToInlined(absl::Nonnull<CordRep*> tree,
MethodIdentifier method) { … }
void Cord::InlineRep::AppendTreeToTree(absl::Nonnull<CordRep*> tree,
MethodIdentifier method) { … }
void Cord::InlineRep::AppendTree(absl::Nonnull<CordRep*> tree,
MethodIdentifier method) { … }
void Cord::InlineRep::PrependTreeToInlined(absl::Nonnull<CordRep*> tree,
MethodIdentifier method) { … }
void Cord::InlineRep::PrependTreeToTree(absl::Nonnull<CordRep*> tree,
MethodIdentifier method) { … }
void Cord::InlineRep::PrependTree(absl::Nonnull<CordRep*> tree,
MethodIdentifier method) { … }
static inline bool PrepareAppendRegion(
absl::Nonnull<CordRep*> root, absl::Nonnull<absl::Nullable<char*>*> region,
absl::Nonnull<size_t*> size, size_t max_length) { … }
void Cord::InlineRep::AssignSlow(const Cord::InlineRep& src) { … }
void Cord::InlineRep::UnrefTree() { … }
Cord::Cord(absl::string_view src, MethodIdentifier method)
: … { … }
template <typename T, Cord::EnableIfString<T>>
Cord::Cord(T&& src) : contents_(InlineData::kDefaultInit) { … }
template Cord::Cord(std::string&& src);
void Cord::DestroyCordSlow() { … }
void Cord::Clear() { … }
Cord& Cord::AssignLargeString(std::string&& src) { … }
Cord& Cord::operator=(absl::string_view src) { … }
void Cord::InlineRep::AppendArray(absl::string_view src,
MethodIdentifier method) { … }
inline absl::Nonnull<CordRep*> Cord::TakeRep() const& { … }
inline absl::Nonnull<CordRep*> Cord::TakeRep() && { … }
template <typename C>
inline void Cord::AppendImpl(C&& src) { … }
static CordRep::ExtractResult ExtractAppendBuffer(absl::Nonnull<CordRep*> rep,
size_t min_capacity) { … }
static CordBuffer CreateAppendBuffer(InlineData& data, size_t block_size,
size_t capacity) { … }
CordBuffer Cord::GetAppendBufferSlowPath(size_t block_size, size_t capacity,
size_t min_capacity) { … }
void Cord::Append(const Cord& src) { … }
void Cord::Append(Cord&& src) { … }
template <typename T, Cord::EnableIfString<T>>
void Cord::Append(T&& src) { … }
template void Cord::Append(std::string&& src);
void Cord::Prepend(const Cord& src) { … }
void Cord::PrependArray(absl::string_view src, MethodIdentifier method) { … }
void Cord::AppendPrecise(absl::string_view src, MethodIdentifier method) { … }
void Cord::PrependPrecise(absl::string_view src, MethodIdentifier method) { … }
template <typename T, Cord::EnableIfString<T>>
inline void Cord::Prepend(T&& src) { … }
template void Cord::Prepend(std::string&& src);
void Cord::RemovePrefix(size_t n) { … }
void Cord::RemoveSuffix(size_t n) { … }
Cord Cord::Subcord(size_t pos, size_t new_size) const { … }
namespace {
int ClampResult(int memcmp_res) { … }
int CompareChunks(absl::Nonnull<absl::string_view*> lhs,
absl::Nonnull<absl::string_view*> rhs,
absl::Nonnull<size_t*> size_to_compare) { … }
template <typename ResultType>
ResultType ComputeCompareResult(int memcmp_res) { … }
template <>
bool ComputeCompareResult<bool>(int memcmp_res) { … }
}
inline absl::string_view Cord::InlineRep::FindFlatStartPiece() const { … }
void Cord::SetCrcCordState(crc_internal::CrcCordState state) { … }
void Cord::SetExpectedChecksum(uint32_t crc) { … }
absl::Nullable<const crc_internal::CrcCordState*> Cord::MaybeGetCrcCordState()
const { … }
absl::optional<uint32_t> Cord::ExpectedChecksum() const { … }
inline int Cord::CompareSlowPath(absl::string_view rhs, size_t compared_size,
size_t size_to_compare) const { … }
inline int Cord::CompareSlowPath(const Cord& rhs, size_t compared_size,
size_t size_to_compare) const { … }
inline absl::string_view Cord::GetFirstChunk(const Cord& c) { … }
inline absl::string_view Cord::GetFirstChunk(absl::string_view sv) { … }
template <typename ResultType, typename RHS>
ResultType GenericCompare(const Cord& lhs, const RHS& rhs,
size_t size_to_compare) { … }
bool Cord::EqualsImpl(absl::string_view rhs, size_t size_to_compare) const { … }
bool Cord::EqualsImpl(const Cord& rhs, size_t size_to_compare) const { … }
template <typename RHS>
inline int SharedCompareImpl(const Cord& lhs, const RHS& rhs) { … }
int Cord::Compare(absl::string_view rhs) const { … }
int Cord::CompareImpl(const Cord& rhs) const { … }
bool Cord::EndsWith(absl::string_view rhs) const { … }
bool Cord::EndsWith(const Cord& rhs) const { … }
operator basic_string()
void CopyCordToString(const Cord& src, absl::Nonnull<std::string*> dst) { … }
void AppendCordToString(const Cord& src, absl::Nonnull<std::string*> dst) { … }
void Cord::CopyToArraySlowPath(absl::Nonnull<char*> dst) const { … }
Cord Cord::ChunkIterator::AdvanceAndReadBytes(size_t n) { … }
char Cord::operator[](size_t i) const { … }
namespace {
bool IsSubstringInCordAt(absl::Cord::CharIterator position,
absl::string_view needle) { … }
}
absl::Cord::CharIterator absl::Cord::FindImpl(CharIterator it,
absl::string_view needle) const { … }
absl::Cord::CharIterator absl::Cord::Find(absl::string_view needle) const { … }
namespace {
bool IsSubcordInCordAt(absl::Cord::CharIterator haystack,
absl::Cord::CharIterator needle_begin,
absl::Cord::CharIterator needle_end) { … }
bool IsSubcordInCordAt(absl::Cord::CharIterator position,
const absl::Cord& needle) { … }
}
absl::Cord::CharIterator absl::Cord::Find(const absl::Cord& needle) const { … }
bool Cord::Contains(absl::string_view rhs) const { … }
bool Cord::Contains(const absl::Cord& rhs) const { … }
absl::string_view Cord::FlattenSlowPath() { … }
bool Cord::GetFlatAux(absl::Nonnull<CordRep*> rep,
absl::Nonnull<absl::string_view*> fragment) { … }
void Cord::ForEachChunkAux(
absl::Nonnull<absl::cord_internal::CordRep*> rep,
absl::FunctionRef<void(absl::string_view)> callback) { … }
static void DumpNode(absl::Nonnull<CordRep*> nonnull_rep, bool include_data,
absl::Nonnull<std::ostream*> os, int indent) { … }
static std::string ReportError(absl::Nonnull<CordRep*> root,
absl::Nonnull<CordRep*> node) { … }
static bool VerifyNode(absl::Nonnull<CordRep*> root,
absl::Nonnull<CordRep*> start_node) { … }
std::ostream& operator<<(std::ostream& out, const Cord& cord) { … }
namespace strings_internal {
size_t CordTestAccess::FlatOverhead() { … }
size_t CordTestAccess::MaxFlatLength() { … }
size_t CordTestAccess::FlatTagToLength(uint8_t tag) { … }
uint8_t CordTestAccess::LengthToTag(size_t s) { … }
size_t CordTestAccess::SizeofCordRepExternal() { … }
size_t CordTestAccess::SizeofCordRepSubstring() { … }
}
ABSL_NAMESPACE_END
}