From a6708e5d31afee9dbc5fd83368f67cf6719b75ea Mon Sep 17 00:00:00 2001 From: tastytea Date: Fri, 2 Aug 2019 13:33:50 +0200 Subject: [PATCH] 2019-08-02 --- docs/annotated.html | 27 ++- docs/classes.html | 27 ++- docs/classxdgcfg-members.html | 41 ++++- docs/classxdgcfg.html | 156 ++++++++++++------ .../dir_68267d1309a1af8e8297ef4c3efbcdba.html | 2 +- .../dir_d44c64559bbebec7f509842c48db8b23.html | 81 +++++++++ docs/example_8cpp-example.html | 29 +++- docs/examples.html | 27 ++- docs/files.html | 29 +++- docs/functions.html | 29 +++- docs/functions_func.html | 29 +++- docs/index.html | 4 +- docs/menudata.js | 11 +- docs/search/all_0.html | 30 ++++ docs/search/all_0.js | 6 + docs/search/all_1.html | 30 ++++ docs/search/all_1.js | 4 + docs/search/all_2.html | 30 ++++ docs/search/all_2.js | 4 + docs/search/all_3.html | 30 ++++ docs/search/all_3.js | 4 + docs/search/all_4.html | 30 ++++ docs/search/all_4.js | 4 + docs/search/classes_0.html | 30 ++++ docs/search/classes_0.js | 4 + docs/search/functions_0.html | 30 ++++ docs/search/functions_0.js | 6 + docs/search/functions_1.html | 30 ++++ docs/search/functions_1.js | 4 + docs/search/functions_2.html | 30 ++++ docs/search/functions_2.js | 4 + docs/search/functions_3.html | 30 ++++ docs/search/functions_3.js | 4 + docs/search/functions_4.html | 30 ++++ docs/search/functions_4.js | 4 + docs/search/searchdata.js | 9 + docs/xdgcfg_8hpp_source.html | 47 ++++-- 37 files changed, 833 insertions(+), 93 deletions(-) create mode 100644 docs/dir_d44c64559bbebec7f509842c48db8b23.html create mode 100644 docs/search/all_0.html create mode 100644 docs/search/all_0.js create mode 100644 docs/search/all_1.html create mode 100644 docs/search/all_1.js create mode 100644 docs/search/all_2.html create mode 100644 docs/search/all_2.js create mode 100644 docs/search/all_3.html create mode 100644 docs/search/all_3.js create mode 100644 docs/search/all_4.html create mode 100644 docs/search/all_4.js create mode 100644 docs/search/classes_0.html create mode 100644 docs/search/classes_0.js create mode 100644 docs/search/functions_0.html create mode 100644 docs/search/functions_0.js create mode 100644 docs/search/functions_1.html create mode 100644 docs/search/functions_1.js create mode 100644 docs/search/functions_2.html create mode 100644 docs/search/functions_2.js create mode 100644 docs/search/functions_3.html create mode 100644 docs/search/functions_3.js create mode 100644 docs/search/functions_4.html create mode 100644 docs/search/functions_4.js diff --git a/docs/annotated.html b/docs/annotated.html index 8517dec..8ec7b8e 100644 --- a/docs/annotated.html +++ b/docs/annotated.html @@ -9,6 +9,9 @@ + + + @@ -19,7 +22,7 @@
xdgcfg -  0.3.1 +  0.4.1
@@ -28,16 +31,36 @@ + + +
+
+ + +
+ +
+
Class List
diff --git a/docs/classes.html b/docs/classes.html index 93dc5b3..50ec5c3 100644 --- a/docs/classes.html +++ b/docs/classes.html @@ -9,6 +9,9 @@ + + + @@ -19,7 +22,7 @@
xdgcfg -  0.3.1 +  0.4.1
@@ -28,16 +31,36 @@
+ + +
+
+ + +
+ +
+
Class Index
diff --git a/docs/classxdgcfg-members.html b/docs/classxdgcfg-members.html index 20eb628..a548967 100644 --- a/docs/classxdgcfg-members.html +++ b/docs/classxdgcfg-members.html @@ -9,6 +9,9 @@ + + + @@ -19,7 +22,7 @@
xdgcfg -  0.3.1 +  0.4.1
@@ -28,15 +31,35 @@
+ + +
+
+ + +
+ +
+
@@ -46,13 +69,13 @@ $(function() {

This is the complete list of members for xdgcfg, including all inherited members.

- - - - - - - + + + + + + +
get_cfg()xdgcfginline
get_filepath() constxdgcfginline
get_verbose() constxdgcfginline
read()xdgcfginline
set_verbose(bool verbose)xdgcfginline
write()xdgcfginline
xdgcfg(const string &filename, const string &subdir="")xdgcfginlineexplicit
get_cfg()xdgcfg
get_filepath() constxdgcfg
get_verbose() constxdgcfg
read()xdgcfg
set_verbose(bool verbose)xdgcfg
write()xdgcfg
xdgcfg(const string &filename, const string &subdir="")xdgcfgexplicit
+ + +
+
+ + +
+ +
+
@@ -58,20 +81,17 @@ Public Member Functions bool write ()  Write the file. More...
  -libconfig::Config & get_cfg () - Returns a reference to the config as libconfig::Config. More...
-  - -const fs::path get_filepath () const - Returns the complete filepath.
+libconfig::Config & get_cfg () + Returns a reference to the config as libconfig::Config. More...
+  +const fs::path get_filepath () const + Returns the complete filepath. More...
  - -void set_verbose (bool verbose) - Sets verbosity.
+void set_verbose (bool verbose) + Sets verbosity. More...
  - -bool get_verbose () const - Returns verbosity.
+bool get_verbose () const + Returns verbosity. More...
 

Detailed Description

@@ -106,7 +126,7 @@ bool  -inlineexplicit +explicit
@@ -119,36 +139,66 @@ bool 
44  : _cfg()
45  , _verbose(false)
46  {
47  xdgHandle xdg;
48  xdgInitHandle(&xdg);
49  _filepath = xdgConfigHome(&xdg);
50  xdgWipeHandle(&xdg);
51 
52  if (!subdir.empty())
53  {
54  _filepath /= subdir;
55  }
56  if (!fs::exists(_filepath))
57  {
58  fs::create_directories(_filepath);
59  }
60  _filepath /= filename;
61  }
+
9 : _cfg()
10 , _verbose(false)
11 {
12  xdgHandle xdg;
13  xdgInitHandle(&xdg);
14  _filepath = xdgConfigHome(&xdg);
15  xdgWipeHandle(&xdg);
16 
17  if (!subdir.empty())
18  {
19  _filepath /= subdir;
20  }
21  if (!fs::exists(_filepath))
22  {
23  fs::create_directories(_filepath);
24  }
25  _filepath /= filename;
26 }

Member Function Documentation

- -

◆ get_cfg()

+ +

◆ get_cfg()

- - - - - -
- +
libconfig::Config& xdgcfg::get_cfg libconfig::Config & xdgcfg::get_cfg ( )
-
-inline

Returns a reference to the config as libconfig::Config.

-

Example:

libconfig::Config &cfg = config.get_cfg();
Examples:
example.cpp.
-
129  {
130  return _cfg;
131  }
+

Example:

libconfig::Config &cfg = config.get_cfg();
Examples:
example.cpp.
+
76 {
77  return _cfg;
78 }
+
+
+ +

◆ get_filepath()

+ +
+
+ + + + + + + +
const fs::path xdgcfg::get_filepath () const
+
+ +

Returns the complete filepath.

+
81 {
82  return _filepath;
83 }
+
+
+ +

◆ get_verbose()

+ +
+
+ + + + + + + +
bool xdgcfg::get_verbose () const
+
+ +

Returns verbosity.

+
91 {
92  return _verbose;
93 }
@@ -156,9 +206,6 @@ bool 
- - - @@ -28,22 +31,42 @@ + + +
+
+ + +
+ +
+
example.cpp
-
#include <iostream>
#include <libconfig.h++>
#include "xdgcfg.hpp"
int main()
{
xdgcfg config("test.cfg", "xdgcfg");
config.set_verbose(true);
if (config.read() != 0)
{
config.write();
}
libconfig::Config &cfg = config.get_cfg();
libconfig::Setting &root = cfg.getRoot();
if (!root.exists("Hello"))
{
root.add("Hello", libconfig::Setting::TypeString) = "World";
}
config.write();
std::cout << "Hello: " << root["Hello"].c_str() << std::endl;
}
+
#include <iostream>
#include <libconfig.h++>
#include "xdgcfg.hpp"
int main()
{
xdgcfg config("test.cfg", // File name.
"xdgcfg"); // Sub directory (optional).
config.set_verbose(true); // Print error messages.
if (config.read() != 0)
{
std::cout << "File not found.\n";
}
// Get a reference to the libconfig::Config object and use it as you would
// normally do.
libconfig::Config &cfg = config.get_cfg();
libconfig::Setting &root = cfg.getRoot();
if (!root.exists("Hello"))
{
root.add("Hello", libconfig::Setting::TypeString) = "World";
}
if (!config.write())
{
std::cerr << "Writing failed.\n";
}
std::cout << "Hello: " << root["Hello"].c_str() << std::endl;
}
@@ -28,16 +31,36 @@ + + +
+
+ + +
+ +
+
Examples
diff --git a/docs/files.html b/docs/files.html index f56b152..2f3c060 100644 --- a/docs/files.html +++ b/docs/files.html @@ -9,6 +9,9 @@ + + + @@ -19,7 +22,7 @@
@@ -28,16 +31,36 @@ + + +
+
+ + +
+ +
+
File List
@@ -45,7 +68,7 @@ $(function() {
Here is a list of all documented files with brief descriptions:
[detail level 12]
@@ -167,17 +214,33 @@ bool  - -
uint_fast8_t xdgcfg::read -inline

Read the file.

Returns
0 on success, 1 on I/O error, 2 on parse error.
Examples:
example.cpp.
-
69  {
70  try
71  {
72  _cfg.readFile(_filepath.c_str());
73  }
74  catch (const libconfig::FileIOException &e)
75  {
76  if (_verbose)
77  {
78  cerr << "I/O error while reading " << _filepath
79  << " - " << e.what() << endl;
80  }
81  return 1;
82  }
83  catch (const libconfig::ParseException &e)
84  {
85  if (_verbose)
86  {
87  cerr << "Parse error at " << e.getFile() << ":" << e.getLine()
88  << " - " << e.getError() << endl;
89  }
90  return 2;
91  }
92 
93  return 0;
94  }
+
29 {
30  try
31  {
32  _cfg.readFile(_filepath.c_str());
33  }
34  catch (const libconfig::FileIOException &e)
35  {
36  if (_verbose)
37  {
38  cerr << "I/O error while reading " << _filepath
39  << " - " << e.what() << endl;
40  }
41  return 1;
42  }
43  catch (const libconfig::ParseException &e)
44  {
45  if (_verbose)
46  {
47  cerr << "Parse error at " << e.getFile() << ":" << e.getLine()
48  << " - " << e.getError() << endl;
49  }
50  return 2;
51  }
52 
53  return 0;
54 }
+
+ + +

◆ set_verbose()

+ +
+
+ + + + + + + + +
void xdgcfg::set_verbose (bool verbose)
+
+ +

Sets verbosity.

+
Examples:
example.cpp.
+
86 {
87  _verbose = verbose;
88 }
@@ -185,9 +248,6 @@ bool 
- - - diff --git a/docs/dir_d44c64559bbebec7f509842c48db8b23.html b/docs/dir_d44c64559bbebec7f509842c48db8b23.html new file mode 100644 index 0000000..4db6eb7 --- /dev/null +++ b/docs/dir_d44c64559bbebec7f509842c48db8b23.html @@ -0,0 +1,81 @@ + + + + + + + +xdgcfg: include Directory Reference + + + + + + + + + +
+
+
@@ -196,21 +256,17 @@ bool  - -
bool xdgcfg::write -inline

Write the file.

Returns
true on success
-
Examples:
example.cpp.
-
102  {
103  try
104  {
105  _cfg.writeFile(_filepath.c_str());
106  }
107  catch (const libconfig::FileIOException &e)
108  {
109  if (_verbose)
110  {
111  cerr << "I/O error while writing " << _filepath
112  << " - " << e.what() << endl;
113  }
114  return false;
115  }
116 
117  return true;
118  }
+
Examples:
example.cpp.
+
57 {
58  try
59  {
60  _cfg.writeFile(_filepath.c_str());
61  }
62  catch (const libconfig::FileIOException &e)
63  {
64  if (_verbose)
65  {
66  cerr << "I/O error while writing " << _filepath
67  << " - " << e.what() << endl;
68  }
69  return false;
70  }
71 
72  return true;
73 }
-
The documentation for this class was generated from the following file:
    -
  • src/xdgcfg.hpp
  • +
    The documentation for this class was generated from the following files: diff --git a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html index 103d60d..1529d44 100644 --- a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html +++ b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html @@ -22,7 +22,7 @@
xdgcfg -  0.4.0 +  0.4.1
+ + + + + +
+
xdgcfg +  0.4.1 +
+
+
+ + + + + + + + +
+
+ + +
+ +
+ +
+ +
+
+
include Directory Reference
+
+
+
+ + + + diff --git a/docs/example_8cpp-example.html b/docs/example_8cpp-example.html index 74fc6cb..4eb630c 100644 --- a/docs/example_8cpp-example.html +++ b/docs/example_8cpp-example.html @@ -9,6 +9,9 @@ + + + @@ -19,7 +22,7 @@
xdgcfg -  0.3.1 +  0.4.1
xdgcfg -  0.3.1 +  0.4.1
xdgcfg -  0.3.1 +  0.4.1
- +
  src
  include
 xdgcfg.hpp
diff --git a/docs/functions.html b/docs/functions.html index dc9c43e..f98ad76 100644 --- a/docs/functions.html +++ b/docs/functions.html @@ -9,6 +9,9 @@ + + + @@ -19,7 +22,7 @@
xdgcfg -  0.3.1 +  0.4.1
@@ -28,20 +31,40 @@ + + +
+
+ + +
+ +
+
Here is a list of all documented class members with links to the class documentation for each member:
  • get_cfg() -: xdgcfg +: xdgcfg
  • get_filepath() : xdgcfg diff --git a/docs/functions_func.html b/docs/functions_func.html index 7387b8c..70516a5 100644 --- a/docs/functions_func.html +++ b/docs/functions_func.html @@ -9,6 +9,9 @@ + + + @@ -19,7 +22,7 @@
    xdgcfg -  0.3.1 +  0.4.1
    @@ -28,20 +31,40 @@
+ + +
+
+ + +
+ +
+
 
  • get_cfg() -: xdgcfg +: xdgcfg
  • get_filepath() : xdgcfg diff --git a/docs/index.html b/docs/index.html index d1ad842..99dccb9 100644 --- a/docs/index.html +++ b/docs/index.html @@ -22,7 +22,7 @@
    xdgcfg -  0.4.0 +  0.4.1
    @@ -68,7 +68,7 @@ $(function() {

    xdgcfg is a very simple wrapper around libconfig written in C++. It reads and writes files in ${XDG_CONFIG_HOME}. It creates subdirectories if necessary.

    Usage

    -

    xdgcfg.hpp has explanatory comments in it and there is an example. The reference is also available at doc.schlomp.space/xdgcfg/.

    +

    xdgcfg.hpp has explanatory comments in it and there is an example. The reference is also available at doc.schlomp.space/xdgcfg/.

    Use it in your CMake project like this:

    find_package(xdgcfg CONFIG REQUIRED)
    target_link_libraries(MyProject xdgcfg::xdgcfg)

    If you don't use CMake, you can get the compile-flags with pkg-config:

    pkg-config --libs --cflags xdgcfg

    Install

    diff --git a/docs/menudata.js b/docs/menudata.js index 03b9351..f3b50f0 100644 --- a/docs/menudata.js +++ b/docs/menudata.js @@ -22,4 +22,13 @@ with this program; if not, write to the Free Software Foundation, Inc., for the JavaScript code in this file */ var menudata={children:[ -{text:"Main Page",url:"index.html"}]} +{text:"Main Page",url:"index.html"}, +{text:"Classes",url:"annotated.html",children:[ +{text:"Class List",url:"annotated.html"}, +{text:"Class Index",url:"classes.html"}, +{text:"Class Members",url:"functions.html",children:[ +{text:"All",url:"functions.html"}, +{text:"Functions",url:"functions_func.html"}]}]}, +{text:"Files",url:"files.html",children:[ +{text:"File List",url:"files.html"}]}, +{text:"Examples",url:"examples.html"}]} diff --git a/docs/search/all_0.html b/docs/search/all_0.html new file mode 100644 index 0000000..5125b94 --- /dev/null +++ b/docs/search/all_0.html @@ -0,0 +1,30 @@ + + + + + + + + + +
    +
    Loading...
    +
    + +
    Searching...
    +
    No Matches
    + +
    + + diff --git a/docs/search/all_0.js b/docs/search/all_0.js new file mode 100644 index 0000000..33f8a8c --- /dev/null +++ b/docs/search/all_0.js @@ -0,0 +1,6 @@ +var searchData= +[ + ['get_5fcfg',['get_cfg',['../classxdgcfg.html#ac07980ed9c75aded9db7d9a56e9e7dbf',1,'xdgcfg']]], + ['get_5ffilepath',['get_filepath',['../classxdgcfg.html#a27f788427081434a6bcbd6724a93e3d1',1,'xdgcfg']]], + ['get_5fverbose',['get_verbose',['../classxdgcfg.html#aa1c726d62d1194036a19bd2b7e79f531',1,'xdgcfg']]] +]; diff --git a/docs/search/all_1.html b/docs/search/all_1.html new file mode 100644 index 0000000..b8ff871 --- /dev/null +++ b/docs/search/all_1.html @@ -0,0 +1,30 @@ + + + + + + + + + +
    +
    Loading...
    +
    + +
    Searching...
    +
    No Matches
    + +
    + + diff --git a/docs/search/all_1.js b/docs/search/all_1.js new file mode 100644 index 0000000..78aa91d --- /dev/null +++ b/docs/search/all_1.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['read',['read',['../classxdgcfg.html#a60584df7badfddce574df3cc1b9fce85',1,'xdgcfg']]] +]; diff --git a/docs/search/all_2.html b/docs/search/all_2.html new file mode 100644 index 0000000..2f17735 --- /dev/null +++ b/docs/search/all_2.html @@ -0,0 +1,30 @@ + + + + + + + + + +
    +
    Loading...
    +
    + +
    Searching...
    +
    No Matches
    + +
    + + diff --git a/docs/search/all_2.js b/docs/search/all_2.js new file mode 100644 index 0000000..d6b0e9f --- /dev/null +++ b/docs/search/all_2.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['set_5fverbose',['set_verbose',['../classxdgcfg.html#a982f773bb644c465bed6144dca44c98f',1,'xdgcfg']]] +]; diff --git a/docs/search/all_3.html b/docs/search/all_3.html new file mode 100644 index 0000000..a3e6f7d --- /dev/null +++ b/docs/search/all_3.html @@ -0,0 +1,30 @@ + + + + + + + + + +
    +
    Loading...
    +
    + +
    Searching...
    +
    No Matches
    + +
    + + diff --git a/docs/search/all_3.js b/docs/search/all_3.js new file mode 100644 index 0000000..cd43de4 --- /dev/null +++ b/docs/search/all_3.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['write',['write',['../classxdgcfg.html#addb7dd29dc725fef54820aab38b42e30',1,'xdgcfg']]] +]; diff --git a/docs/search/all_4.html b/docs/search/all_4.html new file mode 100644 index 0000000..6452295 --- /dev/null +++ b/docs/search/all_4.html @@ -0,0 +1,30 @@ + + + + + + + + + +
    +
    Loading...
    +
    + +
    Searching...
    +
    No Matches
    + +
    + + diff --git a/docs/search/all_4.js b/docs/search/all_4.js new file mode 100644 index 0000000..1c0af6d --- /dev/null +++ b/docs/search/all_4.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['xdgcfg',['xdgcfg',['../classxdgcfg.html',1,'xdgcfg'],['../classxdgcfg.html#ab6fc4f07be696a779d26317a5a7a8b54',1,'xdgcfg::xdgcfg()']]] +]; diff --git a/docs/search/classes_0.html b/docs/search/classes_0.html new file mode 100644 index 0000000..e935fdf --- /dev/null +++ b/docs/search/classes_0.html @@ -0,0 +1,30 @@ + + + + + + + + + +
    +
    Loading...
    +
    + +
    Searching...
    +
    No Matches
    + +
    + + diff --git a/docs/search/classes_0.js b/docs/search/classes_0.js new file mode 100644 index 0000000..c55bcb4 --- /dev/null +++ b/docs/search/classes_0.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['xdgcfg',['xdgcfg',['../classxdgcfg.html',1,'']]] +]; diff --git a/docs/search/functions_0.html b/docs/search/functions_0.html new file mode 100644 index 0000000..0539c8c --- /dev/null +++ b/docs/search/functions_0.html @@ -0,0 +1,30 @@ + + + + + + + + + +
    +
    Loading...
    +
    + +
    Searching...
    +
    No Matches
    + +
    + + diff --git a/docs/search/functions_0.js b/docs/search/functions_0.js new file mode 100644 index 0000000..33f8a8c --- /dev/null +++ b/docs/search/functions_0.js @@ -0,0 +1,6 @@ +var searchData= +[ + ['get_5fcfg',['get_cfg',['../classxdgcfg.html#ac07980ed9c75aded9db7d9a56e9e7dbf',1,'xdgcfg']]], + ['get_5ffilepath',['get_filepath',['../classxdgcfg.html#a27f788427081434a6bcbd6724a93e3d1',1,'xdgcfg']]], + ['get_5fverbose',['get_verbose',['../classxdgcfg.html#aa1c726d62d1194036a19bd2b7e79f531',1,'xdgcfg']]] +]; diff --git a/docs/search/functions_1.html b/docs/search/functions_1.html new file mode 100644 index 0000000..4878b3d --- /dev/null +++ b/docs/search/functions_1.html @@ -0,0 +1,30 @@ + + + + + + + + + +
    +
    Loading...
    +
    + +
    Searching...
    +
    No Matches
    + +
    + + diff --git a/docs/search/functions_1.js b/docs/search/functions_1.js new file mode 100644 index 0000000..78aa91d --- /dev/null +++ b/docs/search/functions_1.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['read',['read',['../classxdgcfg.html#a60584df7badfddce574df3cc1b9fce85',1,'xdgcfg']]] +]; diff --git a/docs/search/functions_2.html b/docs/search/functions_2.html new file mode 100644 index 0000000..67d2a39 --- /dev/null +++ b/docs/search/functions_2.html @@ -0,0 +1,30 @@ + + + + + + + + + +
    +
    Loading...
    +
    + +
    Searching...
    +
    No Matches
    + +
    + + diff --git a/docs/search/functions_2.js b/docs/search/functions_2.js new file mode 100644 index 0000000..d6b0e9f --- /dev/null +++ b/docs/search/functions_2.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['set_5fverbose',['set_verbose',['../classxdgcfg.html#a982f773bb644c465bed6144dca44c98f',1,'xdgcfg']]] +]; diff --git a/docs/search/functions_3.html b/docs/search/functions_3.html new file mode 100644 index 0000000..1f0eedb --- /dev/null +++ b/docs/search/functions_3.html @@ -0,0 +1,30 @@ + + + + + + + + + +
    +
    Loading...
    +
    + +
    Searching...
    +
    No Matches
    + +
    + + diff --git a/docs/search/functions_3.js b/docs/search/functions_3.js new file mode 100644 index 0000000..cd43de4 --- /dev/null +++ b/docs/search/functions_3.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['write',['write',['../classxdgcfg.html#addb7dd29dc725fef54820aab38b42e30',1,'xdgcfg']]] +]; diff --git a/docs/search/functions_4.html b/docs/search/functions_4.html new file mode 100644 index 0000000..c5bf87a --- /dev/null +++ b/docs/search/functions_4.html @@ -0,0 +1,30 @@ + + + + + + + + + +
    +
    Loading...
    +
    + +
    Searching...
    +
    No Matches
    + +
    + + diff --git a/docs/search/functions_4.js b/docs/search/functions_4.js new file mode 100644 index 0000000..1cdce13 --- /dev/null +++ b/docs/search/functions_4.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['xdgcfg',['xdgcfg',['../classxdgcfg.html#ab6fc4f07be696a779d26317a5a7a8b54',1,'xdgcfg']]] +]; diff --git a/docs/search/searchdata.js b/docs/search/searchdata.js index f95870c..f504bca 100644 --- a/docs/search/searchdata.js +++ b/docs/search/searchdata.js @@ -1,12 +1,21 @@ var indexSectionsWithContent = { + 0: "grswx", + 1: "x", + 2: "grswx" }; var indexSectionNames = { + 0: "all", + 1: "classes", + 2: "functions" }; var indexSectionLabels = { + 0: "All", + 1: "Classes", + 2: "Functions" }; diff --git a/docs/xdgcfg_8hpp_source.html b/docs/xdgcfg_8hpp_source.html index 75f4fca..d053efd 100644 --- a/docs/xdgcfg_8hpp_source.html +++ b/docs/xdgcfg_8hpp_source.html @@ -5,10 +5,13 @@ -xdgcfg: src/xdgcfg.hpp Source File +xdgcfg: include/xdgcfg.hpp Source File + + + @@ -19,7 +22,7 @@
    xdgcfg -  0.3.1 +  0.4.1
    @@ -28,18 +31,38 @@
    + + +
    +
    + + +
    + +
    +
@@ -47,14 +70,14 @@ $(function() {
xdgcfg.hpp
-
1 /* Public Domain / CC-0
2  * Author: tastytea <tastytea@tastytea.de>
3  */
4 
5 #ifndef XDGCFG_HPP
6 #define XDGCFG_HPP
7 
8 #if __cplusplus >= 201703L
9  #include <filesystem>
10 #else
11  #include <experimental/filesystem>
12 #endif
13 #include <string>
14 #include <iostream>
15 #include <cstdint>
16 #include <libconfig.h++>
17 #include <basedir.h>
18 
19 #if __cplusplus >= 201703L
20  namespace fs = std::filesystem;
21 #else
22  namespace fs = std::experimental::filesystem;
23 #endif
24 using std::string;
25 using std::uint_fast8_t;
26 using std::cerr;
27 using std::endl;
28 
29 class xdgcfg
30 {
31 public:
43  explicit xdgcfg(const string &filename, const string &subdir = "")
44  : _cfg()
45  , _verbose(false)
46  {
47  xdgHandle xdg;
48  xdgInitHandle(&xdg);
49  _filepath = xdgConfigHome(&xdg);
50  xdgWipeHandle(&xdg);
51 
52  if (!subdir.empty())
53  {
54  _filepath /= subdir;
55  }
56  if (!fs::exists(_filepath))
57  {
58  fs::create_directories(_filepath);
59  }
60  _filepath /= filename;
61  }
62 
68  uint_fast8_t read()
69  {
70  try
71  {
72  _cfg.readFile(_filepath.c_str());
73  }
74  catch (const libconfig::FileIOException &e)
75  {
76  if (_verbose)
77  {
78  cerr << "I/O error while reading " << _filepath
79  << " - " << e.what() << endl;
80  }
81  return 1;
82  }
83  catch (const libconfig::ParseException &e)
84  {
85  if (_verbose)
86  {
87  cerr << "Parse error at " << e.getFile() << ":" << e.getLine()
88  << " - " << e.getError() << endl;
89  }
90  return 2;
91  }
92 
93  return 0;
94  }
95 
101  bool write()
102  {
103  try
104  {
105  _cfg.writeFile(_filepath.c_str());
106  }
107  catch (const libconfig::FileIOException &e)
108  {
109  if (_verbose)
110  {
111  cerr << "I/O error while writing " << _filepath
112  << " - " << e.what() << endl;
113  }
114  return false;
115  }
116 
117  return true;
118  }
119 
128  libconfig::Config &get_cfg()
129  {
130  return _cfg;
131  }
132 
136  const fs::path get_filepath() const
137  {
138  return _filepath;
139  }
140 
144  void set_verbose(bool verbose)
145  {
146  _verbose = verbose;
147  }
148 
152  bool get_verbose() const
153  {
154  return _verbose;
155  }
156 
157 private:
161  libconfig::Config _cfg;
162 
166  fs::path _filepath;
167 
171  bool _verbose;
172 };
173 
178 #endif // XDGCFG_HPP
Definition: xdgcfg.hpp:29
-
libconfig::Config & get_cfg()
Returns a reference to the config as libconfig::Config.
Definition: xdgcfg.hpp:128
-
xdgcfg(const string &filename, const string &subdir="")
Checks if subdir is present, creates it if necessary.
Definition: xdgcfg.hpp:43
-
void set_verbose(bool verbose)
Sets verbosity.
Definition: xdgcfg.hpp:144
-
const fs::path get_filepath() const
Returns the complete filepath.
Definition: xdgcfg.hpp:136
-
uint_fast8_t read()
Read the file.
Definition: xdgcfg.hpp:68
-
bool get_verbose() const
Returns verbosity.
Definition: xdgcfg.hpp:152
-
bool write()
Write the file.
Definition: xdgcfg.hpp:101
+
1 /* Public Domain / CC-0
2  * Author: tastytea <tastytea@tastytea.de>
3  */
4 
5 #ifndef XDGCFG_HPP
6 #define XDGCFG_HPP
7 
8 #if __cplusplus >= 201703L
9  #include <filesystem>
10 #else
11  #include <experimental/filesystem>
12 #endif
13 #include <string>
14 #include <iostream>
15 #include <cstdint>
16 #include <libconfig.h++>
17 
18 #if __cplusplus >= 201703L
19  namespace fs = std::filesystem;
20 #else
21  namespace fs = std::experimental::filesystem;
22 #endif
23 using std::string;
24 using std::uint_fast8_t;
25 using std::cerr;
26 using std::endl;
27 
28 class xdgcfg
29 {
30 public:
42  explicit xdgcfg(const string &filename, const string &subdir = "");
43 
49  uint_fast8_t read();
50 
56  bool write();
57 
66  libconfig::Config &get_cfg();
67 
71  const fs::path get_filepath() const;
72 
76  void set_verbose(bool verbose);
77 
81  bool get_verbose() const;
82 
83 private:
87  libconfig::Config _cfg;
88 
92  fs::path _filepath;
93 
97  bool _verbose;
98 };
99 
104 #endif // XDGCFG_HPP
Definition: xdgcfg.hpp:28
+
xdgcfg(const string &filename, const string &subdir="")
Checks if subdir is present, creates it if necessary.
Definition: xdgcfg.cpp:8
+
libconfig::Config & get_cfg()
Returns a reference to the config as libconfig::Config.
Definition: xdgcfg.cpp:75
+
void set_verbose(bool verbose)
Sets verbosity.
Definition: xdgcfg.cpp:85
+
const fs::path get_filepath() const
Returns the complete filepath.
Definition: xdgcfg.cpp:80
+
uint_fast8_t read()
Read the file.
Definition: xdgcfg.cpp:28
+
bool get_verbose() const
Returns verbosity.
Definition: xdgcfg.cpp:90
+
bool write()
Write the file.
Definition: xdgcfg.cpp:56