C and C++ web framework. http://rapida.vilor.one/docs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
1.3 KiB

/* SPDX-License-Identifier: GPL-3.0-or-later */
/* Copyright 2022 Ivan Polyakov */
#ifndef RAPIDA_URL_HXX_ENTRY
#define RAPIDA_URL_HXX_ENTRY
#include "url.h"
namespace rpd {
/*!
* \brief C++ URL wrapper.
*/
class Url {
public:
/*!
* \brief Default constructor.
*
* Initializes URL with null values.
*/
Url()
{
url.parts = NULL;
url.parts_len = 0;
}
/*!
* \brief Constructor.
*/
Url(const char *url) { parse(url); }
/*!
* \brief Parse URL.
*
* \param url URL.
*
* \return Status code. A non-zero value is an error.
*/
int parse(const char *url)
{
return rpd_url_parse(&this->url, url);
}
/*!
* \brief Get number of URL parts.
*
* \return Number of URL parts.
*/
int length() const
{
return url.parts_len;
}
/*!
* \brief Get URL part at index.
*
* \param idx Index of the URL part.
*
* \return URL part.
*/
const char *operator[](int idx)
{
return url.parts[idx];
}
/*!
* \brief Destructor.
*/
virtual ~Url()
{
rpd_url_cleanup(&url);
}
private:
rpd_url url; //< Composition with C implementation.
};
}
#endif // RAPIDA_URL_HXX_ENTRY