Added bracnch doc
This commit is contained in:
parent
762167d00e
commit
2d1ef56df6
8
.gitignore
vendored
8
.gitignore
vendored
|
@ -1,3 +1,5 @@
|
|||
/build/
|
||||
/doc/
|
||||
/update_doc.sh
|
||||
*
|
||||
!.gitignore
|
||||
!index.html
|
||||
!/docs
|
||||
!/docs/**
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
cmake_minimum_required (VERSION 3.7)
|
||||
project(xdgcfg
|
||||
VERSION 0.1.0
|
||||
LANGUAGES CXX
|
||||
)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(LIBXDG_BASEDIR REQUIRED libxdg-basedir)
|
||||
pkg_check_modules(LIBCONFIG REQUIRED libconfig++)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
|
||||
|
||||
include_directories(${LIBXDG_BASEDIR_INCLUDE_DIRS})
|
||||
include_directories(${LIBCONFIG_INCLUDE_DIRS})
|
||||
|
||||
link_directories(${LIBXDG_BASEDIR_LIBRARY_DIRS})
|
||||
link_directories(${LIBCONFIG_LIBRARY_DIRS})
|
||||
|
||||
add_library(xdgcfg SHARED src/xdgcfg.cpp)
|
||||
set_target_properties(xdgcfg PROPERTIES
|
||||
VERSION ${PROJECT_VERSION}
|
||||
SOVERSION ${xdgcfg_VERSION_MAJOR})
|
||||
target_link_libraries(xdgcfg
|
||||
${LIBXDG_BASEDIR_LIBRARIES} ${LIBCONFIG_LIBRARIES}
|
||||
stdc++fs)
|
||||
|
||||
add_library(xdgcfg_static STATIC src/xdgcfg.cpp)
|
||||
set_target_properties(xdgcfg_static PROPERTIES
|
||||
OUTPUT_NAME xdgcfg)
|
||||
|
||||
add_executable(example src/example.cpp)
|
||||
target_link_libraries(example xdgcfg)
|
||||
|
||||
install(TARGETS xdgcfg LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
install(TARGETS xdgcfg_static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
install(FILES src/xdgcfg.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
198
Doxyfile
198
Doxyfile
|
@ -1,198 +0,0 @@
|
|||
DOXYFILE_ENCODING = UTF-8
|
||||
PROJECT_NAME = "xdgcfg"
|
||||
PROJECT_NUMBER = 0.0.0
|
||||
INPUT = README.md src/
|
||||
USE_MDFILE_AS_MAINPAGE = README.md
|
||||
CREATE_SUBDIRS = NO
|
||||
ALLOW_UNICODE_NAMES = YES
|
||||
OUTPUT_LANGUAGE = English
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = YES
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = NO
|
||||
QT_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
INHERIT_DOCS = YES
|
||||
SEPARATE_MEMBER_PAGES = NO
|
||||
TAB_SIZE = 4
|
||||
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
OPTIMIZE_FOR_FORTRAN = NO
|
||||
OPTIMIZE_OUTPUT_VHDL = NO
|
||||
MARKDOWN_SUPPORT = YES
|
||||
AUTOLINK_SUPPORT = YES
|
||||
BUILTIN_STL_SUPPORT = NO
|
||||
CPP_CLI_SUPPORT = NO
|
||||
SIP_SUPPORT = NO
|
||||
IDL_PROPERTY_SUPPORT = YES
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
GROUP_NESTED_COMPOUNDS = NO
|
||||
SUBGROUPING = YES
|
||||
INLINE_GROUPED_CLASSES = NO
|
||||
INLINE_SIMPLE_STRUCTS = NO
|
||||
TYPEDEF_HIDES_STRUCT = NO
|
||||
LOOKUP_CACHE_SIZE = 0
|
||||
EXTRACT_ALL = NO
|
||||
EXTRACT_PRIVATE = NO
|
||||
EXTRACT_PACKAGE = NO
|
||||
EXTRACT_STATIC = NO
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
EXTRACT_LOCAL_METHODS = NO
|
||||
EXTRACT_ANON_NSPACES = NO
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
HIDE_IN_BODY_DOCS = NO
|
||||
INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = YES
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
HIDE_COMPOUND_REFERENCE= NO
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
SHOW_GROUPED_MEMB_INC = NO
|
||||
FORCE_LOCAL_INCLUDES = NO
|
||||
INLINE_INFO = YES
|
||||
SORT_MEMBER_DOCS = YES
|
||||
SORT_BRIEF_DOCS = NO
|
||||
SORT_MEMBERS_CTORS_1ST = NO
|
||||
SORT_GROUP_NAMES = NO
|
||||
SORT_BY_SCOPE_NAME = NO
|
||||
STRICT_PROTO_MATCHING = NO
|
||||
GENERATE_TODOLIST = YES
|
||||
GENERATE_TESTLIST = YES
|
||||
GENERATE_BUGLIST = YES
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = YES
|
||||
SHOW_FILES = YES
|
||||
SHOW_NAMESPACES = YES
|
||||
QUIET = NO
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_NO_PARAMDOC = NO
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
INPUT_ENCODING = UTF-8
|
||||
RECURSIVE = NO
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXAMPLE_PATH = src
|
||||
EXAMPLE_RECURSIVE = YES
|
||||
FILTER_SOURCE_FILES = NO
|
||||
SOURCE_BROWSER = NO
|
||||
INLINE_SOURCES = YES
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = NO
|
||||
REFERENCES_RELATION = NO
|
||||
REFERENCES_LINK_SOURCE = YES
|
||||
SOURCE_TOOLTIPS = YES
|
||||
USE_HTAGS = NO
|
||||
VERBATIM_HEADERS = YES
|
||||
CLANG_ASSISTED_PARSING = NO
|
||||
ALPHABETICAL_INDEX = YES
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
GENERATE_HTML = YES
|
||||
HTML_OUTPUT = doc/html
|
||||
HTML_FILE_EXTENSION = .html
|
||||
HTML_COLORSTYLE_HUE = 220
|
||||
HTML_COLORSTYLE_SAT = 100
|
||||
HTML_COLORSTYLE_GAMMA = 80
|
||||
HTML_TIMESTAMP = NO
|
||||
HTML_DYNAMIC_SECTIONS = NO
|
||||
HTML_INDEX_NUM_ENTRIES = 100
|
||||
GENERATE_DOCSET = NO
|
||||
DOCSET_FEEDNAME = "Doxygen generated docs"
|
||||
DOCSET_BUNDLE_ID = org.doxygen.Project
|
||||
DOCSET_PUBLISHER_ID = org.doxygen.Publisher
|
||||
DOCSET_PUBLISHER_NAME = Publisher
|
||||
GENERATE_HTMLHELP = NO
|
||||
GENERATE_CHI = NO
|
||||
BINARY_TOC = NO
|
||||
TOC_EXPAND = NO
|
||||
GENERATE_QHP = NO
|
||||
QHP_NAMESPACE = org.doxygen.Project
|
||||
QHP_VIRTUAL_FOLDER = doc
|
||||
GENERATE_ECLIPSEHELP = NO
|
||||
ECLIPSE_DOC_ID = org.doxygen.Project
|
||||
DISABLE_INDEX = NO
|
||||
GENERATE_TREEVIEW = NO
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
TREEVIEW_WIDTH = 250
|
||||
EXT_LINKS_IN_WINDOW = NO
|
||||
FORMULA_FONTSIZE = 10
|
||||
FORMULA_TRANSPARENT = YES
|
||||
USE_MATHJAX = NO
|
||||
MATHJAX_FORMAT = HTML-CSS
|
||||
MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
|
||||
SEARCHENGINE = NO
|
||||
SERVER_BASED_SEARCH = NO
|
||||
EXTERNAL_SEARCH = NO
|
||||
SEARCHDATA_FILE = searchdata.xml
|
||||
GENERATE_LATEX = NO
|
||||
LATEX_OUTPUT = latex
|
||||
LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4
|
||||
PDF_HYPERLINKS = YES
|
||||
USE_PDFLATEX = YES
|
||||
LATEX_BATCHMODE = NO
|
||||
LATEX_HIDE_INDICES = NO
|
||||
LATEX_SOURCE_CODE = NO
|
||||
LATEX_BIB_STYLE = plain
|
||||
GENERATE_RTF = NO
|
||||
RTF_OUTPUT = rtf
|
||||
COMPACT_RTF = NO
|
||||
RTF_HYPERLINKS = NO
|
||||
RTF_SOURCE_CODE = NO
|
||||
GENERATE_MAN = NO
|
||||
MAN_OUTPUT = man
|
||||
MAN_EXTENSION = .3
|
||||
MAN_SUBDIR =
|
||||
MAN_LINKS = NO
|
||||
GENERATE_XML = NO
|
||||
XML_OUTPUT = xml
|
||||
XML_PROGRAMLISTING = YES
|
||||
GENERATE_DOCBOOK = NO
|
||||
DOCBOOK_OUTPUT = docbook
|
||||
DOCBOOK_PROGRAMLISTING = NO
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
GENERATE_PERLMOD = NO
|
||||
PERLMOD_LATEX = NO
|
||||
PERLMOD_PRETTY = YES
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = NO
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
SEARCH_INCLUDES = YES
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = YES
|
||||
EXTERNAL_PAGES = YES
|
||||
PERL_PATH = /usr/bin/perl
|
||||
CLASS_DIAGRAMS = YES
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HAVE_DOT = NO
|
||||
DOT_NUM_THREADS = 0
|
||||
DOT_FONTNAME = Helvetica
|
||||
DOT_FONTSIZE = 10
|
||||
CLASS_GRAPH = YES
|
||||
COLLABORATION_GRAPH = YES
|
||||
GROUP_GRAPHS = YES
|
||||
UML_LOOK = NO
|
||||
UML_LIMIT_NUM_FIELDS = 10
|
||||
TEMPLATE_RELATIONS = NO
|
||||
INCLUDE_GRAPH = YES
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
CALL_GRAPH = NO
|
||||
CALLER_GRAPH = NO
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
DIRECTORY_GRAPH = YES
|
||||
DOT_IMAGE_FORMAT = png
|
||||
INTERACTIVE_SVG = NO
|
||||
DOT_GRAPH_MAX_NODES = 50
|
||||
MAX_DOT_GRAPH_DEPTH = 0
|
||||
DOT_TRANSPARENT = NO
|
||||
DOT_MULTI_TARGETS = NO
|
||||
GENERATE_LEGEND = YES
|
||||
DOT_CLEANUP = YES
|
30
README.md
30
README.md
|
@ -1,30 +0,0 @@
|
|||
**xdgcfg** is a very simple wrapper around libconfig written in C++. It reads
|
||||
and writes files into `${XDG_CONFIG_HOME}`. It creates subdirectories if
|
||||
necessary.
|
||||
|
||||
### Dependencies
|
||||
|
||||
* C++ compiler
|
||||
* [cmake](https://cmake.org/)
|
||||
* [pkgconfig](https://pkgconfig.freedesktop.org/wiki/)
|
||||
* [libconfig++](https://github.com/hyperrealm/libconfig)
|
||||
* [libxdg-basedir](http://repo.or.cz/w/libxdg-basedir.git)
|
||||
|
||||
### Usage
|
||||
|
||||
You can create dynamic and static libraries:
|
||||
|
||||
```SH
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
make install
|
||||
```
|
||||
|
||||
Or just copy `xdgcfg.hpp` and `xdgcfg.cpp` into your project folder.
|
||||
|
||||
### Documentation
|
||||
|
||||
`xdgcfg.hpp` has explanatory comments in it and there is an
|
||||
[example](src/example.cpp).
|
|
@ -1,8 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ -f Doxyfile ]; then
|
||||
mkdir -p doc
|
||||
(cat Doxyfile && echo -n "PROJECT_NUMBER = " &&
|
||||
grep -Eo '[0-9]+.[0-9]+.[0-9]+$' CMakeLists.txt) \
|
||||
| doxygen -
|
||||
fi
|
|
@ -1,22 +0,0 @@
|
|||
#include <iostream>
|
||||
#include <libconfig.h++>
|
||||
#include "xdgcfg.hpp"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
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;
|
||||
}
|
108
src/xdgcfg.cpp
108
src/xdgcfg.cpp
|
@ -1,108 +0,0 @@
|
|||
/* Public Domain / CC-0
|
||||
* Author: tastytea <tastytea@tastytea.de>
|
||||
*/
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
#include <filesystem>
|
||||
#else
|
||||
#include <experimental/filesystem>
|
||||
#endif
|
||||
#include <iostream>
|
||||
#include <basedir.h>
|
||||
#include "xdgcfg.hpp"
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
namespace fs = std::filesystem;
|
||||
#else
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#endif
|
||||
|
||||
using std::cerr;
|
||||
using std::endl;
|
||||
|
||||
xdgcfg::xdgcfg(const string &filename, const string &subdir)
|
||||
: _cfg()
|
||||
, _verbose(false)
|
||||
{
|
||||
xdgHandle xdg;
|
||||
xdgInitHandle(&xdg);
|
||||
_filepath = xdgConfigHome(&xdg);
|
||||
xdgWipeHandle(&xdg);
|
||||
|
||||
if (!subdir.empty())
|
||||
{
|
||||
_filepath += '/' + subdir;
|
||||
if (!fs::exists(_filepath))
|
||||
{
|
||||
fs::create_directory(_filepath);
|
||||
}
|
||||
}
|
||||
_filepath += '/' + filename;
|
||||
}
|
||||
|
||||
const uint_fast8_t xdgcfg::read()
|
||||
{
|
||||
try
|
||||
{
|
||||
_cfg.readFile(_filepath.c_str());
|
||||
}
|
||||
catch (const libconfig::FileIOException &e)
|
||||
{
|
||||
if (_verbose)
|
||||
{
|
||||
cerr << "I/O error while reading " << _filepath
|
||||
<< " - " << e.what() << endl;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
catch (const libconfig::ParseException &e)
|
||||
{
|
||||
if (_verbose)
|
||||
{
|
||||
cerr << "Parse error at " << e.getFile() << ":" << e.getLine()
|
||||
<< " - " << e.getError() << endl;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const bool xdgcfg::write()
|
||||
{
|
||||
try
|
||||
{
|
||||
_cfg.writeFile(_filepath.c_str());
|
||||
}
|
||||
catch (const libconfig::FileIOException &e)
|
||||
{
|
||||
if (_verbose)
|
||||
{
|
||||
cerr << "I/O error while writing " << _filepath
|
||||
<< " - " << e.what() << endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
libconfig::Config &xdgcfg::get_cfg()
|
||||
{
|
||||
return _cfg;
|
||||
}
|
||||
|
||||
const string xdgcfg::get_filepath() const
|
||||
{
|
||||
return _filepath;
|
||||
}
|
||||
|
||||
const void xdgcfg::set_verbose(bool verbose)
|
||||
{
|
||||
_verbose = verbose;
|
||||
}
|
||||
|
||||
const bool xdgcfg::get_verbose() const
|
||||
{
|
||||
return _verbose;
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
/* Public Domain / CC-0
|
||||
* Author: tastytea <tastytea@tastytea.de>
|
||||
*/
|
||||
|
||||
#ifndef XDGCFG_HPP
|
||||
#define XDGCFG_HPP
|
||||
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <libconfig.h++>
|
||||
|
||||
using std::string;
|
||||
using std::uint_fast8_t;
|
||||
|
||||
class xdgcfg
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* @brief Checks if subdir is present, creates it if necessary
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* xdgcfg config("test.cfg", "subdirectory");
|
||||
* @endcode
|
||||
*
|
||||
* @param filename The name of the file, including extension
|
||||
* @param subdir The subdir (optional)
|
||||
*/
|
||||
explicit xdgcfg(const string &filename, const string &subdir = "");
|
||||
|
||||
/*!
|
||||
* @brief Read the file
|
||||
*
|
||||
* @return 0 on success, 1 on I/O error, 2 on parse error.
|
||||
*/
|
||||
const uint_fast8_t read();
|
||||
|
||||
/*!
|
||||
* @brief Write the file
|
||||
*
|
||||
* @return `true` on success
|
||||
*/
|
||||
const bool write();
|
||||
|
||||
/*!
|
||||
* @brief Returns a reference to the config as libconfig::Config
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* libconfig::Config &cfg = config.get_cfg();
|
||||
* @endcode
|
||||
*/
|
||||
libconfig::Config &get_cfg();
|
||||
|
||||
/*!
|
||||
* @brief Returns the complete filepath
|
||||
*/
|
||||
const string get_filepath() const;
|
||||
|
||||
/*!
|
||||
* @brief Sets verbosity
|
||||
*/
|
||||
const void set_verbose(bool verbose);
|
||||
|
||||
/*!
|
||||
* @brief Returns verbosity
|
||||
*/
|
||||
const bool get_verbose() const;
|
||||
|
||||
private:
|
||||
/*!
|
||||
* Holds the contents of the CFG file
|
||||
*/
|
||||
libconfig::Config _cfg;
|
||||
|
||||
/*!
|
||||
* Complete filepath
|
||||
*/
|
||||
string _filepath;
|
||||
|
||||
/*!
|
||||
* Print out error messages if true
|
||||
*/
|
||||
bool _verbose;
|
||||
};
|
||||
|
||||
/*!
|
||||
* @example example.cpp
|
||||
*/
|
||||
|
||||
#endif // XDGCFG_HPP
|
Reference in New Issue
Block a user