LibQuicR
quicr::TrackNamespace Class Reference

An N-tuple representation of a MOQ namespace. More...

#include <track_name.h>

Public Member Functions

 TrackNamespace ()=default
 Construct an empty namespace. More...
 
template<typename... B, std::enable_if_t< std::is_same_v< std::common_type_t< B... >, std::vector< uint8_t >>, bool > = true>
 TrackNamespace (B &&... entries)
 Constructs a namespace from a variadic number of Bytes parameters. More...
 
template<typename... S, std::enable_if_t< std::is_same_v< std::common_type_t< S... >, std::string >, bool > = true>
 TrackNamespace (S &&... entries)
 Constructs a namespace from a variadic number of string parameters. More...
 
 TrackNamespace (std::span< const std::span< const uint8_t >> entries)
 Construct a namespace by copying byte-span entries. More...
 
 TrackNamespace (const std::vector< std::vector< uint8_t >> &entries)
 Construct a namespace by copying byte-vector entries. More...
 
 TrackNamespace (const std::vector< std::string > &entries)
 Construct a namespace by copying string entries as bytes. More...
 
 TrackNamespace (const TrackNamespace &other)
 Copy a namespace and rebind its entry views to the new object's storage. More...
 
 TrackNamespace (TrackNamespace &&other)
 Move a namespace and rebind its entry views to the moved storage. More...
 
TrackNamespace & operator= (const TrackNamespace &other)
 Copy-assign a namespace and rebind its entry views. More...
 
TrackNamespace & operator= (TrackNamespace &&other)
 Move-assign a namespace and rebind its entry views. More...
 
const std::vector< std::span< const uint8_t > > & GetEntries () const noexcept
 Access the namespace tuple entries. More...
 
const auto & GetHashes () const noexcept
 Return the per-entry hashes in tuple order. More...
 
auto Str () const noexcept
 Render entries as slash-separated text. More...
 
TrackNamespace GetPrefix (std::size_t length) const
 Copy the first length tuple entries. More...
 
TrackNamespace GetSuffix (std::size_t length) const
 Copy the last length tuple entries. More...
 
auto begin () noexcept
 Return an iterator to the first byte in the flattened namespace. More...
 
auto end () noexcept
 Return an iterator past the last byte in the flattened namespace. More...
 
auto begin () const noexcept
 Return a const iterator to the first byte in the flattened namespace. More...
 
auto end () const noexcept
 Return a const iterator past the last byte in the flattened namespace. More...
 
auto data () const noexcept
 Return the flattened namespace byte storage. More...
 
auto size () const noexcept
 Return the flattened namespace size in bytes. More...
 
bool empty () const noexcept
 Return whether the flattened namespace contains no bytes. More...
 
std::partial_ordering IsPrefixOf (const TrackNamespace &rhs) const noexcept
 Compare this namespace with rhs by tuple-entry prefix. More...
 
bool HasSamePrefix (const TrackNamespace &other) const noexcept
 Test whether all per-entry hashes in the shorter namespace match the longer namespace's prefix. More...
 

Detailed Description

An N-tuple representation of a MOQ namespace.

Examples
simple_publish/main.cpp, and simple_subscribe/main.cpp.

Constructor & Destructor Documentation

◆ TrackNamespace() [1/8]

quicr::TrackNamespace::TrackNamespace ( )
default

Construct an empty namespace.

◆ TrackNamespace() [2/8]

template<typename... B, std::enable_if_t< std::is_same_v< std::common_type_t< B... >, std::vector< uint8_t >>, bool > = true>
quicr::TrackNamespace::TrackNamespace ( B &&...  entries)
inlineexplicit

Constructs a namespace from a variadic number of Bytes parameters.

Template Parameters
BByte-vector argument types; their common type must be std::vector<uint8_t>.
Parameters
entriesNamespace tuple entries in order.
Precondition
Between 1 and 31 entries must be supplied.

◆ TrackNamespace() [3/8]

template<typename... S, std::enable_if_t< std::is_same_v< std::common_type_t< S... >, std::string >, bool > = true>
quicr::TrackNamespace::TrackNamespace ( S &&...  entries)
inlineexplicit

Constructs a namespace from a variadic number of string parameters.

Template Parameters
SString argument types; their common type must be std::string.
Parameters
entriesNamespace tuple entries in order.
Precondition
Between 1 and 31 entries must be supplied.

◆ TrackNamespace() [4/8]

quicr::TrackNamespace::TrackNamespace ( std::span< const std::span< const uint8_t >>  entries)
inline

Construct a namespace by copying byte-span entries.

Parameters
entriesNamespace tuple entries in order.
Exceptions
std::invalid_argumentif more than 32 entries are supplied.

◆ TrackNamespace() [5/8]

quicr::TrackNamespace::TrackNamespace ( const std::vector< std::vector< uint8_t >> &  entries)
inline

Construct a namespace by copying byte-vector entries.

Parameters
entriesNamespace tuple entries in order.
Exceptions
std::invalid_argumentif more than 32 entries are supplied.

◆ TrackNamespace() [6/8]

quicr::TrackNamespace::TrackNamespace ( const std::vector< std::string > &  entries)
inline

Construct a namespace by copying string entries as bytes.

Parameters
entriesNamespace tuple entries in order.
Exceptions
std::invalid_argumentif more than 32 entries are supplied.

◆ TrackNamespace() [7/8]

quicr::TrackNamespace::TrackNamespace ( const TrackNamespace &  other)
inline

Copy a namespace and rebind its entry views to the new object's storage.

Parameters
otherNamespace to copy.

◆ TrackNamespace() [8/8]

quicr::TrackNamespace::TrackNamespace ( TrackNamespace &&  other)
inline

Move a namespace and rebind its entry views to the moved storage.

Parameters
otherNamespace to move; its entry list is cleared.

Member Function Documentation

◆ begin() [1/2]

auto quicr::TrackNamespace::begin ( ) const
inlinenoexcept

Return a const iterator to the first byte in the flattened namespace.

Returns
Const byte iterator.

◆ begin() [2/2]

auto quicr::TrackNamespace::begin ( )
inlinenoexcept

Return an iterator to the first byte in the flattened namespace.

Returns
Mutable byte iterator.

◆ data()

auto quicr::TrackNamespace::data ( ) const
inlinenoexcept

Return the flattened namespace byte storage.

Returns
Pointer valid until assignment or destruction; it may be null when empty.

◆ empty()

bool quicr::TrackNamespace::empty ( ) const
inlinenoexcept

Return whether the flattened namespace contains no bytes.

Returns
true when there are no flattened bytes.

◆ end() [1/2]

auto quicr::TrackNamespace::end ( ) const
inlinenoexcept

Return a const iterator past the last byte in the flattened namespace.

Returns
Past-the-end const byte iterator.

◆ end() [2/2]

auto quicr::TrackNamespace::end ( )
inlinenoexcept

Return an iterator past the last byte in the flattened namespace.

Returns
Past-the-end mutable byte iterator.

◆ GetEntries()

const std::vector<std::span<const uint8_t> >& quicr::TrackNamespace::GetEntries ( ) const
inlinenoexcept

Access the namespace tuple entries.

Returns
Views into storage owned by this namespace; invalidated by assignment or destruction.

◆ GetHashes()

const auto& quicr::TrackNamespace::GetHashes ( ) const
inlinenoexcept

Return the per-entry hashes in tuple order.

Returns
Reference valid until this namespace is assigned or destroyed.

◆ GetPrefix()

TrackNamespace quicr::TrackNamespace::GetPrefix ( std::size_t  length) const
inline

Copy the first length tuple entries.

Parameters
lengthNumber of leading entries to include.
Returns
The requested prefix, or an empty namespace when length is zero.
Exceptions
std::invalid_argumentif length exceeds the entry count.

◆ GetSuffix()

TrackNamespace quicr::TrackNamespace::GetSuffix ( std::size_t  length) const
inline

Copy the last length tuple entries.

Parameters
lengthNumber of trailing entries to include.
Returns
The requested suffix, or an empty namespace when length is zero.
Exceptions
std::invalid_argumentif length exceeds the entry count.

◆ HasSamePrefix()

bool quicr::TrackNamespace::HasSamePrefix ( const TrackNamespace &  other) const
inlinenoexcept

Test whether all per-entry hashes in the shorter namespace match the longer namespace's prefix.

Parameters
otherNamespace to compare.
Returns
true when either namespace is a prefix of the other.

◆ IsPrefixOf()

std::partial_ordering quicr::TrackNamespace::IsPrefixOf ( const TrackNamespace &  rhs) const
inlinenoexcept

Compare this namespace with rhs by tuple-entry prefix.

Parameters
rhsNamespace to compare.
Returns
less when this is a proper prefix, greater when rhs is a proper prefix, equivalent when their per-entry hashes match, and unordered when neither is a prefix.

◆ operator=() [1/2]

TrackNamespace& quicr::TrackNamespace::operator= ( const TrackNamespace &  other)
inline

Copy-assign a namespace and rebind its entry views.

Parameters
otherNamespace to copy.
Returns
This namespace.

◆ operator=() [2/2]

TrackNamespace& quicr::TrackNamespace::operator= ( TrackNamespace &&  other)
inline

Move-assign a namespace and rebind its entry views.

Parameters
otherNamespace to move.
Returns
This namespace.

◆ size()

auto quicr::TrackNamespace::size ( ) const
inlinenoexcept

Return the flattened namespace size in bytes.

Returns
Number of flattened bytes.

◆ Str()

auto quicr::TrackNamespace::Str ( ) const
inlinenoexcept

Render entries as slash-separated text.

Returns
A string containing the raw entry bytes separated by /.
Note
The result is for diagnostics; arbitrary entry bytes need not be valid text and embedded slash bytes are not escaped.

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