-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbasic_storage_backend.cpp
More file actions
74 lines (61 loc) · 2.28 KB
/
basic_storage_backend.cpp
File metadata and controls
74 lines (61 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright (c) 2023-2024 Percona and/or its affiliates.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 2.0,
// as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License, version 2.0, for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "binsrv/basic_storage_backend.hpp"
#include <stdexcept>
#include <string>
#include <string_view>
#include "util/byte_span_fwd.hpp"
#include "util/exception_location_helpers.hpp"
namespace binsrv {
[[nodiscard]] storage_object_name_container
basic_storage_backend::list_objects() {
return do_list_objects();
}
[[nodiscard]] std::string
basic_storage_backend::get_object(std::string_view name) {
return do_get_object(name);
}
void basic_storage_backend::put_object(std::string_view name,
util::const_byte_span content) {
do_put_object(name, content);
}
void basic_storage_backend::open_stream(std::string_view name,
storage_backend_open_stream_mode mode) {
if (stream_open_) {
util::exception_location().raise<std::logic_error>(
"cannot open a new stream as the previous one has not been closed");
}
do_open_stream(name, mode);
stream_open_ = true;
}
void basic_storage_backend::write_data_to_stream(util::const_byte_span data) {
if (!stream_open_) {
util::exception_location().raise<std::logic_error>(
"cannot write to the stream as it has not been opened");
}
do_write_data_to_stream(data);
}
void basic_storage_backend::close_stream() {
if (!stream_open_) {
util::exception_location().raise<std::logic_error>(
"cannot close the stream as it has not been opened");
}
do_close_stream();
stream_open_ = false;
}
[[nodiscard]] std::string basic_storage_backend::get_description() const {
return do_get_description();
}
} // namespace binsrv