opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
file_dialog_response.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <cstddef>
6#include <filesystem>
7#include <string_view>
8#include <vector>
9
10namespace osc
11{
12 // Represents a response from a file dialog (Open, Save, Save As, etc.), where
13 // the response can be either:
14 //
15 // - An error (e.g. an OS error that prevents the dialog from working).
16 // - A list of paths that the user selected, or no paths if the user cancelled out
17 // of the dialog.
19 public:
20 // Constructs a `FileDialogResponse` that represents an error.
21 explicit FileDialogResponse(std::string_view error) :
22 error_{error}
23 {}
24
25 // Constructs a `FileDialogResponse` that represents a user selection of `filelist`.
26 explicit FileDialogResponse(std::vector<std::filesystem::path> filelist) :
27 filelist_{std::move(filelist)}
28 {}
29
30 bool has_error() const { return not error_.empty(); }
31 CStringView error() const { return error_; }
32 [[nodiscard]] bool empty() const { return filelist_.empty(); }
33 size_t size() const { return filelist_.size(); }
34 auto begin() const { return filelist_.begin(); }
35 auto end() const { return filelist_.end(); }
36 const std::filesystem::path& front() const { return *begin(); }
37 private:
38 std::string error_;
39 std::vector<std::filesystem::path> filelist_;
40 };
41}
Definition c_string_view.h:12
Definition file_dialog_response.h:18
CStringView error() const
Definition file_dialog_response.h:31
size_t size() const
Definition file_dialog_response.h:33
const std::filesystem::path & front() const
Definition file_dialog_response.h:36
FileDialogResponse(std::vector< std::filesystem::path > filelist)
Definition file_dialog_response.h:26
FileDialogResponse(std::string_view error)
Definition file_dialog_response.h:21
auto end() const
Definition file_dialog_response.h:35
bool has_error() const
Definition file_dialog_response.h:30
auto begin() const
Definition file_dialog_response.h:34
bool empty() const
Definition file_dialog_response.h:32
Definition custom_decoration_generator.h:5
constexpr U to(T &&value)
Definition conversion.h:56