Mercurial > code
comparison C++/modules/Xdg/Xdg.h @ 334:0b576ee64d45
* Create brand new hierarchy
* Rename DynLib to Dynlib
* Remove some warnings
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 08 Mar 2015 14:26:33 +0100 |
parents | C++/Xdg.h@f6d9fdb5eeeb |
children | eb7723d8627a |
comparison
equal
deleted
inserted
replaced
333:412ca7a5e1ea | 334:0b576ee64d45 |
---|---|
1 /* | |
2 * Xdg.h -- XDG directory specifications | |
3 * | |
4 * Copyright (c) 2013, 2014 David Demelier <markand@malikania.fr> | |
5 * | |
6 * Permission to use, copy, modify, and/or distribute this software for any | |
7 * purpose with or without fee is hereby granted, provided that the above | |
8 * copyright notice and this permission notice appear in all copies. | |
9 * | |
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
17 */ | |
18 | |
19 #ifndef _XDG_H_ | |
20 #define _XDG_H_ | |
21 | |
22 #include <vector> | |
23 #include <string> | |
24 | |
25 #if defined(_WIN32) | |
26 # if defined(BUILDING_DLL) | |
27 # define EXPORT __declspec(dllexport) | |
28 # else | |
29 # define EXPORT __declspec(dllimport) | |
30 # endif | |
31 #else | |
32 # define EXPORT | |
33 #endif | |
34 | |
35 /** | |
36 * @class Xdg | |
37 * @brief XDG specifications | |
38 * | |
39 * Read and get XDG directories. This file contains exports thingies so it can | |
40 * compiles successfully on Windows but its usage is discouraged. | |
41 */ | |
42 class EXPORT Xdg { | |
43 public: | |
44 using List = std::vector<std::string>; | |
45 | |
46 private: | |
47 std::string m_configHome; | |
48 std::string m_dataHome; | |
49 std::string m_cacheHome; | |
50 std::string m_runtimeDir; | |
51 List m_configDirs; | |
52 List m_dataDirs; | |
53 | |
54 public: | |
55 /** | |
56 * Open an xdg instance and load directories. | |
57 * | |
58 * @throw std::runtime_error on failures | |
59 */ | |
60 Xdg(); | |
61 | |
62 /** | |
63 * Get the config directory. ${XDG_CONFIG_HOME} or ${HOME}/.config | |
64 * | |
65 * @return the config directory | |
66 */ | |
67 const std::string &configHome() const noexcept; | |
68 | |
69 /** | |
70 * Get the data directory. ${XDG_DATA_HOME} or ${HOME}/.local/share | |
71 * | |
72 * @return the data directory | |
73 */ | |
74 const std::string &dataHome() const noexcept; | |
75 | |
76 /** | |
77 * Get the cache directory. ${XDG_CACHE_HOME} or ${HOME}/.cache | |
78 * | |
79 * @return the cache directory | |
80 */ | |
81 const std::string &cacheHome() const noexcept; | |
82 | |
83 /** | |
84 * Get the runtime directory. ${XDG_RUNTIME_DIR} must be set, | |
85 * if not, it throws an exception. | |
86 * | |
87 * The XDG standard says that application should handle XDG_RUNTIME_DIR by | |
88 * themselves. | |
89 * | |
90 * @return the runtime directory | |
91 * @throw std::runtime_error on error | |
92 */ | |
93 const std::string &runtimeDir() const; | |
94 | |
95 /** | |
96 * Get the standard config directories. ${XDG_CONFIG_DIRS} or { "/etc/xdg" } | |
97 * | |
98 * @return the list of config directories | |
99 */ | |
100 const List &configDirs() const noexcept; | |
101 | |
102 /** | |
103 * Get the data directories. ${XDG_DATA_DIRS} or { "/usr/local/share", "/usr/share" } | |
104 * | |
105 * @return the list of data directories | |
106 */ | |
107 const List &dataDirs() const noexcept; | |
108 }; | |
109 | |
110 #endif // !_XDG_H_ |