Webdar 1.0.0
Web user interface to libdar
static_object.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 STATIC_OBJECT_HPP
25#define STATIC_OBJECT_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 "answer.hpp"
39
42{
43public:
44 static_object() = default;
45 static_object(const static_object & ref) = default;
46 static_object(static_object && ref) noexcept = default;
47 static_object & operator = (const static_object & ref) = default;
48 static_object & operator = (static_object && ref) noexcept = default;
49 virtual ~static_object() {};
50
51 virtual answer give_answer() const = 0;
52};
53
54
56
58{
59public:
60 static_object_text(const char *text) { data = text; };
61 static_object_text(const static_object_text & ref) = default;
62 static_object_text(static_object_text && ref) noexcept = default;
63 static_object_text & operator = (const static_object_text & ref) = default;
64 static_object_text & operator = (static_object_text && ref) noexcept = default;
65 ~static_object_text() = default;
66
68 virtual answer give_answer() const override;
69
70private:
71 const char *data;
72};
73
75
77{
78public:
79 static_object_jpeg(const char *base_64);
80 static_object_jpeg(const static_object_jpeg & ref) = default;
81 static_object_jpeg(static_object_jpeg && ref) noexcept = default;
82 static_object_jpeg & operator = (const static_object_jpeg & ref) = default;
83 static_object_jpeg & operator = (static_object_jpeg && ref) noexcept = default;
84 ~static_object_jpeg() = default;
85
87 virtual answer give_answer() const override;
88
89private:
90 std::string data;
91};
92
93#endif
class answer provides easy means to set an HTTP answer and means to sent it back to a proto_connexion...
Definition: answer.hpp:49
static_object to return base64 encoded jpegs
Definition: static_object.hpp:77
virtual answer give_answer() const override
inherited from static_object
Definition: static_object.cpp:76
static_object to return plain text as an answer
Definition: static_object.hpp:58
virtual answer give_answer() const override
inherited from static_object
Definition: static_object.cpp:43
common ancestor to all static object, this makes easier to add new object type in the future
Definition: static_object.hpp:42