platformdirs 0.1.0
📂 Python's platformdirs module for C++
Loading...
Searching...
No Matches
api.h
Go to the documentation of this file.
1#pragma once
2#include <filesystem>
3#include <optional>
4#include <string>
5#include <variant>
6#include <vector>
7
8namespace platformdirs {
9namespace api {
10
12public:
13 std::optional<std::string> appname;
14 std::variant<std::string, std::nullopt_t, bool> appauthor;
15 std::optional<std::string> version;
16 bool roaming;
18 bool opinion;
20
21 platform_dirs_abc(const std::optional<std::string> &appname = std::nullopt,
22 const std::variant<std::string, std::nullopt_t, bool>
23 &appauthor = std::nullopt,
24 const std::optional<std::string> &version = std::nullopt,
25 bool roaming = false, bool multipath = false,
26 bool opinion = true, bool ensure_exists = false);
27
28protected:
29 auto append_app_name_and_version(const std::vector<std::string> &base) const
30 -> std::string;
31 auto optionally_create_directory(const std::string &path) const -> void;
32
33public:
34 virtual std::string user_data_dir() const = 0;
35
36 virtual std::string site_data_dir() const = 0;
37
38 virtual std::string user_config_dir() const = 0;
39
40 virtual std::string site_config_dir() const = 0;
41
42 virtual std::string user_cache_dir() const = 0;
43
44 virtual std::string site_cache_dir() const = 0;
45
46 virtual std::string user_state_dir() const = 0;
47
48 virtual std::string user_log_dir() const = 0;
49
50 virtual std::string user_documents_dir() const = 0;
51
52 virtual std::string user_downloads_dir() const = 0;
53
54 virtual std::string user_pictures_dir() const = 0;
55
56 virtual std::string user_videos_dir() const = 0;
57
58 virtual std::string user_music_dir() const = 0;
59
60 virtual std::string user_desktop_dir() const = 0;
61
62 virtual std::string user_runtime_dir() const = 0;
63
64 virtual std::string site_runtime_dir() const = 0;
65
66 virtual std::filesystem::path user_data_path() const;
67
68 virtual std::filesystem::path site_data_path() const;
69
70 virtual std::filesystem::path user_config_path() const;
71
72 virtual std::filesystem::path site_config_path() const;
73
74 virtual std::filesystem::path user_cache_path() const;
75
76 virtual std::filesystem::path site_cache_path() const;
77
78 virtual std::filesystem::path user_state_path() const;
79
80 virtual std::filesystem::path user_log_path() const;
81
82 virtual std::filesystem::path user_documents_path() const;
83
84 virtual std::filesystem::path user_downloads_path() const;
85
86 virtual std::filesystem::path user_pictures_path() const;
87
88 virtual std::filesystem::path user_videos_path() const;
89
90 virtual std::filesystem::path user_music_path() const;
91
92 virtual std::filesystem::path user_desktop_path() const;
93
94 virtual std::filesystem::path user_runtime_path() const;
95
96 virtual std::filesystem::path site_runtime_path() const;
97};
98
99} // namespace api
100} // namespace platformdirs
virtual std::filesystem::path user_desktop_path() const
Definition api.cpp:92
std::optional< std::string > version
Definition api.h:15
virtual std::string user_downloads_dir() const =0
virtual std::filesystem::path site_runtime_path() const
Definition api.cpp:102
virtual std::filesystem::path site_data_path() const
Definition api.cpp:32
virtual std::string site_runtime_dir() const =0
virtual std::string site_data_dir() const =0
virtual std::filesystem::path user_runtime_path() const
Definition api.cpp:97
virtual std::string user_music_dir() const =0
virtual std::filesystem::path site_cache_path() const
Definition api.cpp:52
virtual std::filesystem::path user_videos_path() const
Definition api.cpp:82
virtual std::filesystem::path user_cache_path() const
Definition api.cpp:47
bool multipath
Definition api.h:17
virtual std::filesystem::path user_log_path() const
Definition api.cpp:62
auto optionally_create_directory(const std::string &path) const -> void
Definition api.cpp:123
std::variant< std::string, std::nullopt_t, bool > appauthor
Definition api.h:14
virtual std::string user_pictures_dir() const =0
bool ensure_exists
Definition api.h:19
virtual std::string site_config_dir() const =0
virtual std::filesystem::path user_downloads_path() const
Definition api.cpp:72
virtual std::filesystem::path user_music_path() const
Definition api.cpp:87
virtual std::string user_documents_dir() const =0
virtual std::filesystem::path user_config_path() const
Definition api.cpp:37
virtual std::string user_state_dir() const =0
virtual std::string user_videos_dir() const =0
virtual std::filesystem::path user_data_path() const
Definition api.cpp:27
bool roaming
Definition api.h:16
bool opinion
Definition api.h:18
std::optional< std::string > appname
Definition api.h:13
virtual std::filesystem::path site_config_path() const
Definition api.cpp:42
virtual std::string site_cache_dir() const =0
virtual std::string user_log_dir() const =0
virtual std::string user_runtime_dir() const =0
virtual std::filesystem::path user_state_path() const
Definition api.cpp:57
virtual std::string user_cache_dir() const =0
virtual std::string user_data_dir() const =0
virtual std::string user_desktop_dir() const =0
virtual std::filesystem::path user_documents_path() const
Definition api.cpp:67
auto append_app_name_and_version(const std::vector< std::string > &base) const -> std::string
Definition api.cpp:106
virtual std::string user_config_dir() const =0
virtual std::filesystem::path user_pictures_path() const
Definition api.cpp:77
Definition platformdirs.h:27
platformdirs::api::platform_dirs_abc platform_dirs_abc
Definition platformdirs.h:243