folly::io::Cursor::readTerminatedString

Read a string of bytes until the given terminator character is seen.

Synopsis

Declared in <folly/io/Cursor.h>

std::string
readTerminatedString(
    char termChar = '\0',
    size_t maxLength = std::numeric_limits<size_t>::max());

Description

methodset Consumers

Raises an std::length_error if maxLength bytes have been processed before the terminator is seen.

See comments in readFixedString() about when it's appropriate to use this vs. using pull().

Return Value

The bytes read, up to but excluding the terminator.

Parameters

NameDescription
termCharThe byte that terminates the string.
maxLengthThe maximum number of bytes to read.