Webdar 1.0.0
Web user interface to libdar
html_form_mask_expression.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_MASK_EXPRESSION_HPP
25#define HTML_FORM_MASK_EXPRESSION_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 <dar/libdar.hpp>
36#include <memory>
37
38 // webdar headers
39#include "body_builder.hpp"
40#include "html_mask.hpp"
41#include "html_form_fieldset.hpp"
42#include "html_form_input.hpp"
43#include "html_form_select.hpp"
44#include "actor.hpp"
45#include "jsoner.hpp"
46#include "events.hpp"
47
48
50
53
80
81
83 public html_mask,
84 public actor,
85 public jsoner,
86 public events
87{
88public:
89
90 // events
91
92 static const std::string changed;
93
94 // mask types
95 static constexpr const char* type_glob = "glob";
96 static constexpr const char* type_regex = "regex";
97
99
103 html_form_mask_expression(const std::string & subject);
106 html_form_mask_expression & operator = (const html_form_mask_expression & ref) = delete;
107 html_form_mask_expression & operator = (html_form_mask_expression && ref) noexcept = delete;
108 ~html_form_mask_expression() = default;
109
111 void clear();
112
114 std::unique_ptr<libdar::mask> get_mask() const override;
115
117 virtual bool is_relative() const override { return true; }; // always true as this is never a path expression
118
120 virtual void on_event(const std::string & event_name) override;
121
123 virtual void load_json(const json & source) override;
124
126 virtual json save_json() const override;
127
129 virtual void clear_json() override { clear(); };
130
132 void manually_set_mask_type(const std::string & mtype);
133
135 void manually_set_negate(bool mode);
136
138 void manually_set_casesensitivity(bool mode);
139
141 void manually_set_expression(const std::string & expr);
142
143protected:
145 virtual std::string inherited_get_body_part(const chemin & path,
146 const request & req) override;
147
149 virtual void new_css_library_available() override;
150
151private:
152 bool ignore_events;
153 std::string sujet;
154
156 html_form_select mask_type;
157 html_form_input negate;
158 html_form_input casesensitivity;
159 html_form_input mask_expression;
160
161 void init();
162 std::string tell_action() const;
163
164 static constexpr const unsigned int format_version = 1;
165 static constexpr const char* myclass_id = "html_form_mask_expression";
166
167 static constexpr const char* jlabel_mask_type = "type";
168 static constexpr const char* jlabel_negate = "negate";
169 static constexpr const char* jlabel_casesensit = "case-sentitive";
170 static constexpr const char* jlabel_expression = "mask";
171};
172
173#endif
class of object that are pointed/triggered to by others
Definition: actor.hpp:55
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_fieldset implements HTML fieldset feature
Definition: html_form_fieldset.hpp:51
class html_form_input implements HTML input feature
Definition: html_form_input.hpp:57
class html_form_mask_expression provide mean to setup libdar::mask component for filename filtering
Definition: html_form_mask_expression.hpp:87
void clear()
reset object to default
Definition: html_form_mask_expression.cpp:88
virtual void new_css_library_available() override
inherited from body_builder
Definition: html_form_mask_expression.cpp:233
virtual void clear_json() override
inherited from jsoner
Definition: html_form_mask_expression.hpp:129
void manually_set_casesensitivity(bool mode)
manual setup for the case sensitivity (true = case sensitive mask)
Definition: html_form_mask_expression.cpp:217
virtual std::string inherited_get_body_part(const chemin &path, const request &req) override
inherited methods from body_builder
Definition: html_form_mask_expression.cpp:227
virtual bool is_relative() const override
inherited from html_mask
Definition: html_form_mask_expression.hpp:117
virtual void load_json(const json &source) override
inherited from jsoner
Definition: html_form_mask_expression.cpp:148
virtual json save_json() const override
inherited from jsoner
Definition: html_form_mask_expression.cpp:193
virtual void on_event(const std::string &event_name) override
inherited from actor
Definition: html_form_mask_expression.cpp:134
html_form_mask_expression(const std::string &subject)
constructor
Definition: html_form_mask_expression.cpp:46
void manually_set_expression(const std::string &expr)
manual setup for the mask expression
Definition: html_form_mask_expression.cpp:222
void manually_set_negate(bool mode)
manual setup for the mask negation (true = mask negation set)
Definition: html_form_mask_expression.cpp:212
void manually_set_mask_type(const std::string &mtype)
manual setup for the type of mask (see type_glob and type_regex static fields above,...
Definition: html_form_mask_expression.cpp:207
std::unique_ptr< libdar::mask > get_mask() const override
inherited from html_mask
Definition: html_form_mask_expression.cpp:96
class html_form_select implements HTML input of type "select"
Definition: html_form_select.hpp:53
class html_mask defines the interface of all masks
Definition: html_mask.hpp:44
class jsoner
Definition: jsoner.hpp:73
class holding fields of an HTTP request (method, URI, header, cookies, and so on)
Definition: request.hpp:45
defines the event class
defines jsoner class and class exception_json