A sequence of characters stored as a tree of buffers.

Synopsis

Declared in <absl/strings/cord.h>

class Cord;

Types

Name

Description

CharIterator

Iterates over the constituent characters of a Cord.

CharRange

A range over the characters of a Cord, usable in a range‐based for loop.

ChunkIterator

Iterates over the constituent chunks of a Cord.

ChunkRange

A range over the chunks of a Cord, usable in a range‐based for loop.

Member Functions

Name

Description

Cord [constructor]

Constructors

~Cord [destructor]

Destructs the Cord.

operator=

Assignment operators

Append

Append overloads

Chars

Returns a Cord::CharRange for iterating over the characters of a Cord with a range‐based for‐loop.

Chunks

Returns a Cord::ChunkRange for iterating over the chunks of a Cord with a range‐based for‐loop.

Clear

Releases the Cord data.

Compare

Compare overloads

Contains

Contains overloads

EndsWith

EndsWith overloads

EstimatedMemoryUsage

Returns the approximate number of bytes held by this cord.

ExpectedChecksum

Returns this cord's expected checksum, if it has one. Otherwise, returns nullopt.

Find

Find overloads

Flatten

Flattens the cord into a single array and returns a view of the data.

GetAppendBuffer

Returns a CordBuffer, re‐using potential existing capacity in this cord.

GetCustomAppendBuffer

Returns a CordBuffer, re‐using potential existing capacity in this cord.

Prepend

Prepend overloads

RemovePrefix

Removes the first n bytes of a Cord.

RemoveSuffix

Removes the last n bytes of a Cord.

SetExpectedChecksum

Stores a checksum value with this non‐empty cord instance, for later retrieval.

StartsWith

StartsWith overloads

Subcord

Returns a new Cord representing the subrange [pos, pos + new_size) of] *this.

TryFlat

If this cord's representation is a single flat array, returns a string_view referencing that array. Otherwise returns nullopt.

char_begin

Returns an iterator to the first character of the Cord.

char_end

Returns an iterator to one past the last character of the Cord.

chunk_begin

Returns an iterator to the first chunk of the Cord.

chunk_end

Returns an iterator one increment past the last chunk of the Cord.

empty

Determines whether the given Cord is empty, returning true if so.

operator[]

Gets the "i"th character of the Cord and returns it, provided that 0 <= i < Cord.size().

size

Returns the size of the Cord.

swap

Swaps the contents of the Cord with other.

operator std::string

Converts a Cord into a std::string().

Static Member Functions

Name

Description

Advance

Advances the Cord::CharIterator by n_bytes.

AdvanceAndRead

Advances the Cord::CharIterator by n_bytes and returns the bytes advanced as a separate Cord.

ChunkRemaining

Returns the longest contiguous view starting at the iterator's position.

Distance

Returns the distance between first and last, as if std::distance(first, last) was called.

Friends

Name

Description

absl::CrcCord

absl::GenericCompare

Compares lhs and rhs over the first size_to_compare bytes.

absl::GetCordzInfoForTesting

Returns the internal Cordz sampling info for cord, for testing.

absl::operator<=>

Three‐way compares string data with a Cord.

absl::operator<=>

Three‐way compares a Cord with string data.

absl::operator<=>

Three‐way compares two Cords.

absl::operator==

Compares a Cord with string data for equality.

absl::operator==

Compares two Cords for equality.

absl::CordTestPeer

Test‐only accessor granting access to Cord internals.

strings::CordReader

absl::AbslHashValue

Combines the Cord's contents into a hash state.

absl::AbslStringify

Supports automatic stringification with absl::StrCat and absl::StrFormat.

absl::AbslFormatFlush

Supports absl::Cord as a sink object for absl::Format().

absl::CopyCordToSpan

Copies up to dst.size() bytes starting from the beginning of src to dst.

absl::AppendCordToString

Appends the contents of a src Cord to a *dst string.

absl::CopyCordToString

Copies the contents of a src Cord into a *dst string.

absl::swap

Swaps the contents of two Cords.

absl::MakeCordFromExternal

Creates a Cord that takes ownership of external string memory.

Non-Member Functions

Name

Description

operator!=

Compares two Cords for inequality.

operator!=

Compares a Cord with string data for inequality.

operator<

Orders one Cord before another.

operator<

Orders a Cord before string data.

operator<=

Tests whether a Cord is ordered at or before string data.

operator<=

Tests whether one Cord is ordered at or before another.

operator>

Orders one Cord after another.

operator>

Orders a Cord after string data.

operator>=

Tests whether one Cord is ordered at or after another.

operator>=

Tests whether a Cord is ordered at or after string data.

Created with MrDocs