Webdar 1.0.0
Web user interface to libdar
html_fichier.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_FICHIER_HPP
25#define HTML_FICHIER_HPP
26
27#include "my_config.h"
28
29 // C system header files
30extern "C"
31{
32
33}
34
35 // C++ system header files
36
37
38 // webdar headers
39#include "body_builder.hpp"
40
41
43
45{
46public:
47 html_fichier() = default;
48 html_fichier(const html_fichier & ref) = default;
49 html_fichier(html_fichier && ref) noexcept = delete;
50 html_fichier & operator = (const html_fichier & ref) = default;
51 html_fichier & operator = (html_fichier && ref) noexcept = delete;
52 ~html_fichier() = default;
53
55 void set_data(const std::string & arg) { data = arg; };
56
58 void clear() { data.clear(); };
59
61 bool is_empty() const { return data.empty(); };
62
63protected:
65 virtual std::string inherited_get_body_part(const chemin & path,
66 const request & req) override
67 {
68 return data;
69 };
70
71private:
72 std::string data;
73
74};
75
76
77#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
class html_fichier is a body_builder object that only shows if the request path is exactly its path
Definition: html_fichier.hpp:45
bool is_empty() const
whether some data is present
Definition: html_fichier.hpp:61
virtual std::string inherited_get_body_part(const chemin &path, const request &req) override
inherited from body_builder
Definition: html_fichier.hpp:65
void set_data(const std::string &arg)
define the content to return upon request
Definition: html_fichier.hpp:55
void clear()
clear content
Definition: html_fichier.hpp:58
class holding fields of an HTTP request (method, URI, header, cookies, and so on)
Definition: request.hpp:45