1 /* SPDX-License-Identifier: BSL-1.0 OR BSD-3-Clause */
2 
3 #ifndef MPT_IO_READ_FILECURSOR_FILENAME_TRAITS_HPP
4 #define MPT_IO_READ_FILECURSOR_FILENAME_TRAITS_HPP
5 
6 
7 
8 #include "mpt/base/namespace.hpp"
9 
10 #include <memory>
11 #include <optional>
12 
13 
14 
15 namespace mpt {
16 inline namespace MPT_INLINE_NS {
17 
18 
19 
20 namespace IO {
21 
22 
23 
24 class FileCursorFilenameTraitsNone {
25 
26 public:
27 	struct empty_type { };
28 
29 	using filename_type = empty_type;
30 	using shared_filename_type = empty_type;
31 
get_optional_filename(shared_filename_type)32 	static std::optional<filename_type> get_optional_filename(shared_filename_type /* filename */) {
33 		return std::nullopt;
34 	}
35 };
36 
37 template <typename Tpath>
38 class FileCursorFilenameTraits {
39 
40 public:
41 	using filename_type = Tpath;
42 	using shared_filename_type = std::shared_ptr<Tpath>;
43 
get_optional_filename(shared_filename_type filename)44 	static std::optional<filename_type> get_optional_filename(shared_filename_type filename) {
45 		if (!filename) {
46 			return std::nullopt;
47 		}
48 		return *filename;
49 	}
50 };
51 
52 
53 
54 } // namespace IO
55 
56 
57 
58 } // namespace MPT_INLINE_NS
59 } // namespace mpt
60 
61 
62 
63 #endif // MPT_IO_READ_FILECURSOR_FILENAME_TRAITS_HPP
64