RADLib
RADical C++ application framework
RADCore::RADUrl Class Reference

Lightweight URL parser for scheme, host, port, path, query, and fragment. More...

#include <RADCore.h>

Public Member Functions

 RADUrl ()=default
 Creates an invalid empty URL. More...
 
 RADUrl (std::string url)
 Parses url into a RADUrl. More...
 
bool isValid () const
 Returns true when parsing succeeded. More...
 
const std::string & scheme () const
 Returns URL scheme without colon. More...
 
const std::string & host () const
 Returns host name or address. More...
 
uint16_t port (uint16_t defaultPort=0) const
 Returns explicit port or defaultPort. More...
 
const std::string & path () const
 Returns URL path. More...
 
const std::string & query () const
 Returns query without '?'. More...
 
const std::string & fragment () const
 Returns fragment without '#'. More...
 
std::string toString () const
 Rebuilds the URL string. More...
 

Static Public Member Functions

static std::optional< RADUrlparse (const std::string &url)
 Parses url and returns nullopt on failure. More...
 

Detailed Description

Lightweight URL parser for scheme, host, port, path, query, and fragment.

Constructor & Destructor Documentation

◆ RADUrl() [1/2]

RADCore::RADUrl::RADUrl ( )
default

Creates an invalid empty URL.

◆ RADUrl() [2/2]

RADCore::RADUrl::RADUrl ( std::string  url)
explicit

Parses url into a RADUrl.

Member Function Documentation

◆ fragment()

const std::string& RADCore::RADUrl::fragment ( ) const

Returns fragment without '#'.

◆ host()

const std::string& RADCore::RADUrl::host ( ) const

Returns host name or address.

◆ isValid()

bool RADCore::RADUrl::isValid ( ) const

Returns true when parsing succeeded.

◆ parse()

static std::optional<RADUrl> RADCore::RADUrl::parse ( const std::string &  url)
static

Parses url and returns nullopt on failure.

◆ path()

const std::string& RADCore::RADUrl::path ( ) const

Returns URL path.

◆ port()

uint16_t RADCore::RADUrl::port ( uint16_t  defaultPort = 0) const

Returns explicit port or defaultPort.

◆ query()

const std::string& RADCore::RADUrl::query ( ) const

Returns query without '?'.

◆ scheme()

const std::string& RADCore::RADUrl::scheme ( ) const

Returns URL scheme without colon.

◆ toString()

std::string RADCore::RADUrl::toString ( ) const

Rebuilds the URL string.


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