Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QHttpHeaderRange Class Reference

QHttpHeaderRange represents a single byte range as used in the HTTP {Range} and {Content-Range} headers. More...

#include <qhttpheaders.h>

Collaboration diagram for QHttpHeaderRange:

Public Member Functions

constexpr QHttpHeaderRange () noexcept=default
 Constructs a default-initialized range.
constexpr QHttpHeaderRange (std::optional< qint64 > start, std::optional< qint64 > end) noexcept
 Constructs a range with start and end byte offsets.
constexpr std::optional< qint64start () const noexcept
 Returns the start byte offset of the range, or {std::nullopt} if no start was set.
constexpr std::optional< qint64end () const noexcept
 Returns the end byte offset of the range, or {std::nullopt} if no end was set.
constexpr void setStart (std::optional< qint64 > start) noexcept
 Sets the start byte offset to start.
constexpr void setEnd (std::optional< qint64 > end) noexcept
 Sets the end byte offset to end.
constexpr bool isValid () const noexcept
 Returns true if the range is well-formed, false otherwise.

Friends

Q_NETWORK_EXPORT QDebug operator<< (QDebug debug, const QHttpHeaderRange &range)
constexpr bool comparesEqual (const QHttpHeaderRange &lhs, const QHttpHeaderRange &rhs) noexcept

Detailed Description

QHttpHeaderRange represents a single byte range as used in the HTTP {Range} and {Content-Range} headers.

Since
6.12 \inmodule QtNetwork \compares equality

A range has an optional start and an optional end, both expressed as byte offsets. A missing start or end is represented as {std::nullopt}.

Use \l isValid() to check whether a range is well-formed before passing it to \l QHttpHeaders::setRangeValues().

See also
QHttpHeaders::rangeValues(), QHttpHeaders::setRangeValues()

Definition at line 23 of file qhttpheaders.h.

Constructor & Destructor Documentation

◆ QHttpHeaderRange() [1/2]

QHttpHeaderRange::QHttpHeaderRange ( )
constexprdefaultnoexcept

Constructs a default-initialized range.

Both \l start() and \l end() will be {std::nullopt}. The resulting range is not valid according to \l isValid().

◆ QHttpHeaderRange() [2/2]

QHttpHeaderRange::QHttpHeaderRange ( std::optional< qint64 > start,
std::optional< qint64 > end )
inlineconstexprnoexcept

Constructs a range with start and end byte offsets.

Either or both may be {std::nullopt} to represent an open-ended range; see \l isValid() for the constraints.

Definition at line 27 of file qhttpheaders.h.

References QHttpHeaderRange().

Referenced by QHttpHeaderRange().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ end()

std::optional< qint64 > QHttpHeaderRange::end ( ) const
inlineconstexprnoexcept

Returns the end byte offset of the range, or {std::nullopt} if no end was set.

A range with a start but without an end (e.g., {bytes=500-}) requests all bytes from the given offset to the end of the resource.

See also
setEnd(), start()

Definition at line 31 of file qhttpheaders.h.

◆ isValid()

bool QHttpHeaderRange::isValid ( ) const
inlineconstexprnoexcept

Returns true if the range is well-formed, false otherwise.

A range is considered invalid if: \list

  • Both start and end are {std::nullopt}.
  • The start value is negative.
  • The end value is negative.
  • Both start and end are set, and start is greater than end. \endlist

Definition at line 35 of file qhttpheaders.h.

◆ setEnd()

void QHttpHeaderRange::setEnd ( std::optional< qint64 > end)
inlineconstexprnoexcept

Sets the end byte offset to end.

Pass {std::nullopt} to clear the end.

See also
end(), setStart()

Definition at line 33 of file qhttpheaders.h.

◆ setStart()

void QHttpHeaderRange::setStart ( std::optional< qint64 > start)
inlineconstexprnoexcept

Sets the start byte offset to start.

Pass {std::nullopt} to clear the start.

See also
start(), setEnd()

Definition at line 32 of file qhttpheaders.h.

◆ start()

std::optional< qint64 > QHttpHeaderRange::start ( ) const
inlineconstexprnoexcept

Returns the start byte offset of the range, or {std::nullopt} if no start was set.

A range without a start but with an end (e.g., {bytes=-500}) represents the last N bytes of the resource.

See also
setStart(), end()

Definition at line 30 of file qhttpheaders.h.

◆ comparesEqual

bool comparesEqual ( const QHttpHeaderRange & lhs,
const QHttpHeaderRange & rhs )
friend

Definition at line 53 of file qhttpheaders.h.

◆ operator<<

Q_NETWORK_EXPORT QDebug operator<< ( QDebug debug,
const QHttpHeaderRange & range )
friend
Since
6.12

Writes range to the debug stream.

Definition at line 2039 of file qhttpheaders.cpp.


The documentation for this class was generated from the following files: