Webdar 1.0.0
Web user interface to libdar
html_url.hpp
1/*********************************************************************/
2// webdar - a web server and interface program to libdar
3// Copyright (C) 2013-2025 Denis Corbin
4//
5// This file is part of Webdar
6//
7// Webdar is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// Webdar is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with Webdar. If not, see <http://www.gnu.org/licenses/>
19//
20//----
21// to contact the author: dar.linux@free.fr
22/*********************************************************************/
23
24#ifndef HTML_URL_HPP
25#define HTML_URL_HPP
26
27 // C system header files
28#include "my_config.h"
29extern "C"
30{
31
32}
33
34 // C++ system header files
35#include "body_builder.hpp"
36#include "static_body_builder.hpp"
37
38 // webdar headers
39
41
42class html_url : public body_builder
43{
44public:
45 html_url(const std::string & url);
46 html_url(const html_url & ref) = default;
47 html_url(html_url && ref) noexcept = delete;
48 html_url & operator = (const html_url & ref) = default;
49 html_url & operator = (html_url && ref) noexcept = delete;
50 ~html_url() = default;
51
52 void change_url(const std::string & newurl);
53 const std::string & get_url() const { return x_url; };
54
56 virtual void bind_to_anchor(const std::string & val) override { anchor_to = val; };
57
59 void set_download(bool mode) { download = mode; };
60
63 void set_filename(const std::string & name) { filename = name; };
64
66 void set_target_new_page(bool mode) { blank = mode; };
67
68protected:
70 virtual std::string inherited_get_body_part(const chemin & path,
71 const request & req) override;
72
73
74private:
75 std::string anchor_to;
76 std::string x_url;
77 bool download;
78 std::string filename;
79 bool blank;
80};
81
82
83#endif
class body_builder is the root class of object generating HTML body
Definition: body_builder.hpp:99
class chemin definition
Definition: chemin.hpp:51
html component implementing the usual hyperlink component
Definition: html_url.hpp:43
void set_filename(const std::string &name)
Definition: html_url.hpp:63
void set_download(bool mode)
whether to download or display the URL target
Definition: html_url.hpp:59
void set_target_new_page(bool mode)
open a new page (_blank target)
Definition: html_url.hpp:66
virtual void bind_to_anchor(const std::string &val) override
inherited from body_builder
Definition: html_url.hpp:56
virtual std::string inherited_get_body_part(const chemin &path, const request &req) override
inherited from body_builder
Definition: html_url.cpp:60
class holding fields of an HTTP request (method, URI, header, cookies, and so on)
Definition: request.hpp:45