Webdar 1.0.0
Web user interface to libdar
html_level.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_LEVEL_HPP
25#define HTML_LEVEL_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 <string>
36#include <list>
37
38 // webdar headers
39#include "html_tooltip.hpp"
40
42
47
49{
50public:
51 html_level();
52 html_level(const html_level & ref) = delete;
53 html_level(html_level && ref) noexcept = delete;
54 html_level & operator = (const html_level & ref) = delete;
55 html_level & operator = (html_level && ref) noexcept = delete;
56 ~html_level() = default;
57
59 void adopt_static_html(const std::string & html);
60
62 void clear_children();
63
64protected:
66 virtual void has_adopted(body_builder *obj) override;
67
69 virtual void will_foresake(body_builder *obj) override;
70
72 struct bundle
73 {
75 std::string static_text;
76 bundle() { obj = nullptr; };
77 };
78
79 void reset_read_next() { nxt = table.begin(); };
80 bool read_next(bundle & bdl) const;
81
85 std::string get_body_part_from_children_as_a_block(const chemin & path,
86 const request & req);
87
88protected:
90 virtual std::string inherited_get_body_part(const chemin & path,
91 const request & req) override;
92
93private:
94 mutable std::list<bundle>::iterator nxt;
95 std::list<bundle> table;
96};
97
98#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_level is a pure virtual class
Definition: html_level.hpp:49
void clear_children()
clear all adopted data
Definition: html_level.cpp:62
virtual void will_foresake(body_builder *obj) override
inherited from body_builder
Definition: html_level.cpp:85
virtual void has_adopted(body_builder *obj) override
inherited from body_builder
Definition: html_level.cpp:74
bool read_next(bundle &bdl) const
return false if bdl could not be set (nor more entry to read)
Definition: html_level.cpp:100
std::string get_body_part_from_children_as_a_block(const chemin &path, const request &req)
Definition: html_level.cpp:112
void adopt_static_html(const std::string &html)
used in concurrency with body_builder::adopt()
Definition: html_level.cpp:50
virtual std::string inherited_get_body_part(const chemin &path, const request &req) override
inherited from body_builder
Definition: html_level.cpp:134
class html_tooltip is a partial body_builder implementation for inherited class to implement tooltips
Definition: html_tooltip.hpp:51
class holding fields of an HTTP request (method, URI, header, cookies, and so on)
Definition: request.hpp:45
struct recording the content of each level (dynamic or static html component)
Definition: html_level.hpp:73
std::string static_text
used if obj is nullptr
Definition: html_level.hpp:75
body_builder * obj
if set to nullptr, using static_text instead
Definition: html_level.hpp:74