WPILibC++ 2024.3.2
wpi::HttpPath Class Reference

Class for HTTP path matching. More...

#include <wpinet/HttpUtil.h>

Public Member Functions

 HttpPath ()=default
 Constructs an empty HTTP path. More...
 
 HttpPath (std::string_view path)
 Constructs a HTTP path from an escaped path string. More...
 
 operator bool () const
 Evaluates to true if the path is not empty. More...
 
bool empty () const
 Returns true if the path has no elements. More...
 
size_t size () const
 Returns number of elements in the path. More...
 
bool equals (std::initializer_list< std::string_view > match) const
 Returns true if the path exactly matches the provided match list. More...
 
bool equals (std::span< const std::string_view > match) const
 
bool equals (std::string_view match) const
 
bool equals (size_t start, std::initializer_list< std::string_view > match) const
 Returns true if the elements of the path starting at the "start" element match the provided match list, and there are no additional elements. More...
 
bool equals (size_t start, std::span< const std::string_view > match) const
 
bool equals (size_t start, std::string_view match) const
 
bool startswith (std::initializer_list< std::string_view > match) const
 Returns true if the first elements of the path match the provided match list. More...
 
bool startswith (std::span< const std::string_view > match) const
 
bool startswith (std::string_view match) const
 
bool startswith (size_t start, std::initializer_list< std::string_view > match) const
 Returns true if the elements of the path starting at the "start" element match the provided match list. More...
 
bool startswith (size_t start, std::span< const std::string_view > match) const
 
bool startswith (size_t start, std::string_view match) const
 
std::string_view operator[] (size_t n) const
 Gets a single element of the path. More...
 
HttpPathRef drop_front (size_t n) const
 Returns a path reference with the first N elements of the path removed. More...
 

Detailed Description

Class for HTTP path matching.

A root path is represented as a single empty element, otherwise the path consists of each non-empty element between the '/' characters:

  • "" -> []
  • "/" -> [""]
  • "/foo" -> ["foo"]
  • "/foo/bar" -> ["foo", "bar"]
  • "/foo//bar/" -> ["foo", "bar"]

All path elements are unescaped.

Constructor & Destructor Documentation

◆ HttpPath() [1/2]

wpi::HttpPath::HttpPath ( )
default

Constructs an empty HTTP path.

◆ HttpPath() [2/2]

wpi::HttpPath::HttpPath ( std::string_view  path)
explicit

Constructs a HTTP path from an escaped path string.

Makes a copy of the path, so it's safe to be a temporary.

Member Function Documentation

◆ drop_front()

HttpPathRef wpi::HttpPath::drop_front ( size_t  n) const
inline

Returns a path reference with the first N elements of the path removed.

◆ empty()

bool wpi::HttpPath::empty ( ) const
inline

Returns true if the path has no elements.

◆ equals() [1/6]

bool wpi::HttpPath::equals ( size_t  start,
std::initializer_list< std::string_view match 
) const
inline

Returns true if the elements of the path starting at the "start" element match the provided match list, and there are no additional elements.

Parameters
startelement to start matching at
matchmatch list
Returns
True if match

◆ equals() [2/6]

bool wpi::HttpPath::equals ( size_t  start,
std::span< const std::string_view match 
) const
inline

◆ equals() [3/6]

bool wpi::HttpPath::equals ( size_t  start,
std::string_view  match 
) const
inline

◆ equals() [4/6]

bool wpi::HttpPath::equals ( std::initializer_list< std::string_view match) const
inline

Returns true if the path exactly matches the provided match list.

Parameters
matchmatch list
Returns
True if path equals match list

◆ equals() [5/6]

bool wpi::HttpPath::equals ( std::span< const std::string_view match) const
inline

◆ equals() [6/6]

bool wpi::HttpPath::equals ( std::string_view  match) const
inline

◆ operator bool()

wpi::HttpPath::operator bool ( ) const
inlineexplicit

Evaluates to true if the path is not empty.

◆ operator[]()

std::string_view wpi::HttpPath::operator[] ( size_t  n) const

Gets a single element of the path.

◆ size()

size_t wpi::HttpPath::size ( ) const
inline

Returns number of elements in the path.

◆ startswith() [1/6]

bool wpi::HttpPath::startswith ( size_t  start,
std::initializer_list< std::string_view match 
) const
inline

Returns true if the elements of the path starting at the "start" element match the provided match list.

The path may have additional elements.

Parameters
startelement to start matching at
matchmatch list
Returns
True if path starting at the start element matches the match list

◆ startswith() [2/6]

bool wpi::HttpPath::startswith ( size_t  start,
std::span< const std::string_view match 
) const

◆ startswith() [3/6]

bool wpi::HttpPath::startswith ( size_t  start,
std::string_view  match 
) const
inline

◆ startswith() [4/6]

bool wpi::HttpPath::startswith ( std::initializer_list< std::string_view match) const
inline

Returns true if the first elements of the path match the provided match list.

The path may have additional elements.

Parameters
matchmatch list
Returns
True if path starts with match list

◆ startswith() [5/6]

bool wpi::HttpPath::startswith ( std::span< const std::string_view match) const
inline

◆ startswith() [6/6]

bool wpi::HttpPath::startswith ( std::string_view  match) const
inline

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