Webdar 1.0.0
Web user interface to libdar
html_form.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_FORM_HPP
25#define HTML_FORM_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 "body_builder.hpp"
39#include "events.hpp"
40
42
49
50class html_form : public body_builder, public events
51{
52public:
53 static const std::string changed;
54
55 html_form(const std::string & validate_msg = "send");
56 html_form(const html_form & ref) = default;
57 html_form(html_form && ref) noexcept = delete;
58 html_form & operator = (const html_form & ref) = default;
59 html_form & operator = (html_form && ref) noexcept = delete;
60 ~html_form() = default;
61
63 void set_enctype(const std::string & enc) { enctype = enc; };
64
66
70
72
75 void add_button_css_class(const std::string & name);
76
78
80 std::string get_button_css_classes() const;
81
83 virtual void bind_to_anchor(const std::string & value) override { anchor_to = value; };
84
85protected:
87 virtual std::string inherited_get_body_part(const chemin & path,
88 const request & req) override;
89
90private:
91 std::string go_mesg;
92 std::string enctype;
93 std::set<std::string> css_button_classes;
94 std::string anchor_to;
95};
96
97#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 events
Definition: events.hpp:52
class html_form implements HTML form feature
Definition: html_form.hpp:51
void clear_button_css_classes()
clear css class for the form button (not for the whole form)
Definition: html_form.cpp:53
virtual std::string inherited_get_body_part(const chemin &path, const request &req) override
inherited methods from body_builder
Definition: html_form.cpp:89
void set_enctype(const std::string &enc)
encoding type for HTTP code generation ; "multipart/form-data" for example
Definition: html_form.hpp:63
void add_button_css_class(const std::string &name)
add css class for the form button (not for the whole form)
Definition: html_form.cpp:59
virtual void bind_to_anchor(const std::string &value) override
inherited from body_builder
Definition: html_form.hpp:83
std::string get_button_css_classes() const
return the button assigned css classes as inlined CSS, suitable to be added in a html marker
Definition: html_form.cpp:69
class holding fields of an HTTP request (method, URI, header, cookies, and so on)
Definition: request.hpp:45
defines the event class