Webdar 1.0.0
Web user interface to libdar
html_text.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_TEXT_HPP
25#define HTML_TEXT_HPP
26
27 // C system header files
28#include "my_config.h"
29extern "C"
30{
31
32}
33
34 // C++ system header files
35
36
37 // webdar headers
38#include "html_tooltip.hpp"
39#include "static_body_builder.hpp"
40
42
49
50class html_text : public html_tooltip,
52{
53public:
54 html_text() { txt = ""; };
55 html_text(unsigned int level, const std::string & text) { add_text(level, text); };
56 html_text(const html_text & ref) = default;
57 html_text(html_text && ref) noexcept = delete;
58 html_text & operator = (const html_text & ref) = default;
59 html_text & operator = (html_text && ref) noexcept = delete;
60 ~html_text() = default;
61
66 void add_text(unsigned int level, const std::string & text);
67 html_text & add_nl() { txt += "<br />"; my_body_part_has_changed(); return *this; };
68 html_text & add_paragraph() { txt += "<p />"; my_body_part_has_changed(); return *this; };
69
71
73 void set_raw_value(const std::string & val) { txt = val; };
74
76 std::string get_raw_value() const { return txt; };
77
79 void clear() { txt = ""; my_body_part_has_changed(); };
80
81
83 virtual std::string get_body_part() const override;
84
85protected:
87 virtual std::string inherited_get_body_part(const chemin & path,
88 const request & req) override;
89
90private:
91 std::string txt;
92
93};
94
95
96#endif
void my_body_part_has_changed()
let a class record a change in what inherited_get_body_part() would return if it was called again wit...
Definition: body_builder.cpp:420
class chemin definition
Definition: chemin.hpp:51
class html_text manage text and header in html document
Definition: html_text.hpp:52
std::string get_raw_value() const
get raw value
Definition: html_text.hpp:76
void clear()
clear the whole component value (gets as if it was just created)
Definition: html_text.hpp:79
virtual std::string get_body_part() const override
inherited from static_body_builder
Definition: html_text.cpp:57
void add_text(unsigned int level, const std::string &text)
Definition: html_text.cpp:44
virtual std::string inherited_get_body_part(const chemin &path, const request &req) override
inherited from body_builder
Definition: html_text.cpp:70
void set_raw_value(const std::string &val)
clear and replace component value by the provided string
Definition: html_text.hpp:73
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
base class of html components that are static
Definition: static_body_builder.hpp:47