diff --git a/docs/annotated.html b/docs/annotated.html index c5047db..be822df 100644 --- a/docs/annotated.html +++ b/docs/annotated.html @@ -19,7 +19,7 @@
xdgcfg -  0.1.0 +  0.2.0
diff --git a/docs/classes.html b/docs/classes.html index 2421114..735f39a 100644 --- a/docs/classes.html +++ b/docs/classes.html @@ -19,7 +19,7 @@
xdgcfg -  0.1.0 +  0.2.0
diff --git a/docs/classxdgcfg-members.html b/docs/classxdgcfg-members.html index 2504581..9461233 100644 --- a/docs/classxdgcfg-members.html +++ b/docs/classxdgcfg-members.html @@ -19,7 +19,7 @@
xdgcfg -  0.1.0 +  0.2.0
@@ -47,7 +47,7 @@ $(function() {

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

- + diff --git a/docs/classxdgcfg.html b/docs/classxdgcfg.html index f80efd2..a80fcff 100644 --- a/docs/classxdgcfg.html +++ b/docs/classxdgcfg.html @@ -19,7 +19,7 @@ @@ -61,10 +61,10 @@ Public Member Functions - - - + + + @@ -119,7 +119,7 @@ const bool  diff --git a/docs/example_8cpp-example.html b/docs/example_8cpp-example.html index 72534a1..f5eea0d 100644 --- a/docs/example_8cpp-example.html +++ b/docs/example_8cpp-example.html @@ -19,7 +19,7 @@ diff --git a/docs/examples.html b/docs/examples.html index 98be020..888c097 100644 --- a/docs/examples.html +++ b/docs/examples.html @@ -19,7 +19,7 @@ diff --git a/docs/files.html b/docs/files.html index 90f8398..0eeb359 100644 --- a/docs/files.html +++ b/docs/files.html @@ -19,7 +19,7 @@ diff --git a/docs/functions.html b/docs/functions.html index bc2a318..0a4ad0a 100644 --- a/docs/functions.html +++ b/docs/functions.html @@ -19,7 +19,7 @@ @@ -44,7 +44,7 @@ $(function() { : xdgcfg
  • get_filepath() -: xdgcfg +: xdgcfg
  • get_verbose() : xdgcfg diff --git a/docs/functions_func.html b/docs/functions_func.html index f453b10..ec5c31a 100644 --- a/docs/functions_func.html +++ b/docs/functions_func.html @@ -19,7 +19,7 @@
  • @@ -44,7 +44,7 @@ $(function() { : xdgcfg
  • get_filepath() -: xdgcfg +: xdgcfg
  • get_verbose() : xdgcfg diff --git a/docs/index.html b/docs/index.html index 5ad4d79..471a787 100644 --- a/docs/index.html +++ b/docs/index.html @@ -19,7 +19,7 @@
  • @@ -46,7 +46,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.

    Dependencies

    @@ -47,14 +47,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 #include <string>
    9 #include <cstdint>
    10 #include <libconfig.h++>
    11 
    12 using std::string;
    13 using std::uint_fast8_t;
    14 
    15 class xdgcfg
    16 {
    17 public:
    29  explicit xdgcfg(const string &filename, const string &subdir = "");
    30 
    36  const uint_fast8_t read();
    37 
    43  const bool write();
    44 
    53  libconfig::Config &get_cfg();
    54 
    58  const string get_filepath() const;
    59 
    63  const void set_verbose(bool verbose);
    64 
    68  const bool get_verbose() const;
    69 
    70 private:
    74  libconfig::Config _cfg;
    75 
    79  string _filepath;
    80 
    84  bool _verbose;
    85 };
    86 
    91 #endif // XDGCFG_HPP
    const string get_filepath() const
    Returns the complete filepath.
    Definition: xdgcfg.cpp:95
    -
    const bool write()
    Write the file.
    Definition: xdgcfg.cpp:71
    -
    Definition: xdgcfg.hpp:15
    -
    const void set_verbose(bool verbose)
    Sets verbosity.
    Definition: xdgcfg.cpp:100
    -
    xdgcfg(const string &filename, const string &subdir="")
    Checks if subdir is present, creates it if necessary.
    Definition: xdgcfg.cpp:23
    -
    libconfig::Config & get_cfg()
    Returns a reference to the config as libconfig::Config.
    Definition: xdgcfg.cpp:90
    -
    const uint_fast8_t read()
    Read the file.
    Definition: xdgcfg.cpp:43
    -
    const bool get_verbose() const
    Returns verbosity.
    Definition: xdgcfg.cpp:105
    +
    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 <cstdint>
    15 #include <libconfig.h++>
    16 
    17 #if __cplusplus >= 201703L
    18  namespace fs = std::filesystem;
    19 #else
    20  namespace fs = std::experimental::filesystem;
    21 #endif
    22 using std::string;
    23 using std::uint_fast8_t;
    24 
    25 class xdgcfg
    26 {
    27 public:
    39  explicit xdgcfg(const string &filename, const string &subdir = "");
    40 
    46  const uint_fast8_t read();
    47 
    53  const bool write();
    54 
    63  libconfig::Config &get_cfg();
    64 
    68  const fs::path get_filepath() const;
    69 
    73  const void set_verbose(bool verbose);
    74 
    78  const bool get_verbose() const;
    79 
    80 private:
    84  libconfig::Config _cfg;
    85 
    89  fs::path _filepath;
    90 
    94  bool _verbose;
    95 };
    96 
    101 #endif // XDGCFG_HPP
    const bool write()
    Write the file.
    Definition: xdgcfg.cpp:60
    +
    Definition: xdgcfg.hpp:25
    +
    const void set_verbose(bool verbose)
    Sets verbosity.
    Definition: xdgcfg.cpp:89
    +
    xdgcfg(const string &filename, const string &subdir="")
    Checks if subdir is present, creates it if necessary.
    Definition: xdgcfg.cpp:12
    +
    libconfig::Config & get_cfg()
    Returns a reference to the config as libconfig::Config.
    Definition: xdgcfg.cpp:79
    +
    const uint_fast8_t read()
    Read the file.
    Definition: xdgcfg.cpp:32
    +
    const fs::path get_filepath() const
    Returns the complete filepath.
    Definition: xdgcfg.cpp:84
    +
    const bool get_verbose() const
    Returns verbosity.
    Definition: xdgcfg.cpp:94
    get_cfg()xdgcfg
    get_filepath() constxdgcfg
    get_filepath() constxdgcfg
    get_verbose() constxdgcfg
    read()xdgcfg
    set_verbose(bool verbose)xdgcfg
    xdgcfg -  0.1.0 +  0.2.0
    libconfig::Config & get_cfg ()
     Returns a reference to the config as libconfig::Config. More...
     
    -const string get_filepath () const
     Returns the complete filepath.
     
    +const fs::path get_filepath () const
     Returns the complete filepath.
     
    const void set_verbose (bool verbose)
     Sets verbosity.
    -
    24 : _cfg()
    25 , _verbose(false)
    26 {
    27  xdgHandle xdg;
    28  xdgInitHandle(&xdg);
    29  _filepath = xdgConfigHome(&xdg);
    30  xdgWipeHandle(&xdg);
    31 
    32  if (!subdir.empty())
    33  {
    34  _filepath += '/' + subdir;
    35  if (!fs::exists(_filepath))
    36  {
    37  fs::create_directory(_filepath);
    38  }
    39  }
    40  _filepath += '/' + filename;
    41 }
    +
    13 : _cfg()
    14 , _verbose(false)
    15 {
    16  xdgHandle xdg;
    17  xdgInitHandle(&xdg);
    18  _filepath = xdgConfigHome(&xdg);
    19  xdgWipeHandle(&xdg);
    20 
    21  if (!subdir.empty())
    22  {
    23  _filepath /= subdir;
    24  if (!fs::exists(_filepath))
    25  {
    26  fs::create_directory(_filepath);
    27  }
    28  }
    29  _filepath /= filename;
    30 }

    Member Function Documentation

    @@ -140,7 +140,7 @@ const bool 
    Returns a reference to the config as libconfig::Config.

    Example:

    libconfig::Config &cfg = config.get_cfg();
    Examples:
    example.cpp.
    -
    91 {
    92  return _cfg;
    93 }
    +
    80 {
    81  return _cfg;
    82 }
    @@ -161,7 +161,7 @@ const bool 
    Read the file.

    Returns
    0 on success, 1 on I/O error, 2 on parse error.
    Examples:
    example.cpp.
    -
    44 {
    45  try
    46  {
    47  _cfg.readFile(_filepath.c_str());
    48  }
    49  catch (const libconfig::FileIOException &e)
    50  {
    51  if (_verbose)
    52  {
    53  cerr << "I/O error while reading " << _filepath
    54  << " - " << e.what() << endl;
    55  }
    56  return 1;
    57  }
    58  catch (const libconfig::ParseException &e)
    59  {
    60  if (_verbose)
    61  {
    62  cerr << "Parse error at " << e.getFile() << ":" << e.getLine()
    63  << " - " << e.getError() << endl;
    64  }
    65  return 2;
    66  }
    67 
    68  return 0;
    69 }
    +
    33 {
    34  try
    35  {
    36  _cfg.readFile(_filepath.c_str());
    37  }
    38  catch (const libconfig::FileIOException &e)
    39  {
    40  if (_verbose)
    41  {
    42  cerr << "I/O error while reading " << _filepath
    43  << " - " << e.what() << endl;
    44  }
    45  return 1;
    46  }
    47  catch (const libconfig::ParseException &e)
    48  {
    49  if (_verbose)
    50  {
    51  cerr << "Parse error at " << e.getFile() << ":" << e.getLine()
    52  << " - " << e.getError() << endl;
    53  }
    54  return 2;
    55  }
    56 
    57  return 0;
    58 }
    @@ -182,7 +182,7 @@ const bool 
    Write the file.

    Returns
    true on success
    Examples:
    example.cpp.
    -
    72 {
    73  try
    74  {
    75  _cfg.writeFile(_filepath.c_str());
    76  }
    77  catch (const libconfig::FileIOException &e)
    78  {
    79  if (_verbose)
    80  {
    81  cerr << "I/O error while writing " << _filepath
    82  << " - " << e.what() << endl;
    83  }
    84  return false;
    85  }
    86 
    87  return true;
    88 }
    +
    61 {
    62  try
    63  {
    64  _cfg.writeFile(_filepath.c_str());
    65  }
    66  catch (const libconfig::FileIOException &e)
    67  {
    68  if (_verbose)
    69  {
    70  cerr << "I/O error while writing " << _filepath
    71  << " - " << e.what() << endl;
    72  }
    73  return false;
    74  }
    75 
    76  return true;
    77 }

    The documentation for this class was generated from the following files:
      diff --git a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html index 2016f2c..93ac8ea 100644 --- a/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html +++ b/docs/dir_68267d1309a1af8e8297ef4c3efbcdba.html @@ -19,7 +19,7 @@
    xdgcfg -  0.1.0 +  0.2.0
    xdgcfg -  0.1.0 +  0.2.0
    xdgcfg -  0.1.0 +  0.2.0
    xdgcfg -  0.1.0 +  0.2.0
    xdgcfg -  0.1.0 +  0.2.0
    xdgcfg -  0.1.0 +  0.2.0
    xdgcfg -  0.1.0 +  0.2.0
    xdgcfg -  0.1.0 +  0.2.0