#include "tensorstore/kvstore/byte_range.h"
struct tensorstore::OptionalByteRangeRequest;

Specifies an optional byte range request.

Constructors

constexpr OptionalByteRangeRequest();

Constructs a request for a full (unconstrained) byte range.

explicit constexpr OptionalByteRangeRequest(
    
int64_t inclusive_min,
    
int64_t exclusive_max = -1);

Constructs from the specified bounds.

constexpr OptionalByteRangeRequest(ByteRange r);

Constructs from an existing byte range.

Methods

bool IsFull() const;

Checks if no byte range restriction is specified.

bool IsRange() const;

Checks if this request specifies an explicit range with both inclusive_min and exclusive_max.

bool IsSuffixLength() const;

Check if this request specifies a suffix length.

bool IsSuffix() const;

Checks if this request specifies a suffix, with only inclusive_min specified.

static OptionalByteRangeRequest
Range(int64_t inclusive_minint64_t exclusive_max);

Constructs a request for an explicit range.

static OptionalByteRangeRequest SuffixLength(int64_t length);

Constructs a request for a suffix of the specified length.

static OptionalByteRangeRequest Suffix(int64_t inclusive_min);

Constructs a request for a suffix starting at the specified inclusive_min.

int64_t size() const;

Returns the number of bytes contained in the range, or -1 if unknown.

ByteRange AsByteRange() const;

Converts to a ByteRange.

constexpr bool SatisfiesInvariants() const;

Checks that this byte range is valid.

Result<ByteRange> Validate(int64_t size) const;

Returns a ByteRange for an object of size.

Data members

int64_t inclusive_min = 0;

Specifies the starting byte if non-negative, or suffix length if negative.

int64_t exclusive_max = -1;

Specifies the exclusive max, or -1 to indicate no upper bound.

Friend functions

friend bool operator==(const OptionalByteRangeRequesta,
                       
const OptionalByteRangeRequestb);
friend bool operator!=(const OptionalByteRangeRequesta,
                       
const OptionalByteRangeRequestb);

Compares for equality.

friend std::ostream&
operator<<(std::ostreamosconst OptionalByteRangeRequestr);

Prints a debugging string representation to an std::ostream.