#include <utility>
#include <boost/any.hpp>
+class DisableMoveAnyWrapper : public boost::any
+{
+ public:
+ DisableMoveAnyWrapper() {}
+ DisableMoveAnyWrapper(const DisableMoveAnyWrapper& any)
+ : boost::any(static_cast<const boost::any&>(any)) {};
+ DisableMoveAnyWrapper& operator=(DisableMoveAnyWrapper&& any) = delete;
+ DisableMoveAnyWrapper& operator=(const DisableMoveAnyWrapper& any) {
+ static_cast<boost::any&>(*this) = static_cast<const boost::any&>(any);
+ return *this;
+ }
+};
+
/**
- * Use this macro to declare and register config fields
+ * @ingroup libConfig
*
- * Example:
+ * Use this macro to declare and register config fields.
+ *
+ * Example of fields registration:
+ * @code
* struct Foo {
* std::string bar;
*
* int
* )
* };
+ * @endcode
*
- * Example of valid configuration:
+ * Example of valid configuration:
+ * @code
* 1. {
* "type": "Foo",
* "value": { "bar": "some string" }
* "type": "int",
* "value": 1
* }
+ * @endcode
*
- *
- * Usage:
+ * Usage of existing bindings:
+ * @code
* Config config;
* // ...
* if (config.isSet()) {
* config.set(std::move(foo)); //< copy sic!
* config.set(Foo({"some string"}));
* }
+ * @endcode
*/
-
-class DisbaleMoveAnyWrapper : public boost::any
-{
- public:
- DisbaleMoveAnyWrapper() {}
- DisbaleMoveAnyWrapper(const DisbaleMoveAnyWrapper& any)
- : boost::any(static_cast<const boost::any&>(any)) {};
- DisbaleMoveAnyWrapper& operator=(DisbaleMoveAnyWrapper&& any) = delete;
- DisbaleMoveAnyWrapper& operator=(const DisbaleMoveAnyWrapper& any) {
- static_cast<boost::any&>(*this) = static_cast<const boost::any&>(any);
- return *this;
- }
-};
-
#define CONFIG_DECLARE_UNION(...) \
private: \
- DisbaleMoveAnyWrapper mConfigDeclareField; \
+ DisableMoveAnyWrapper mConfigDeclareField; \
\
template<typename Visitor> \
void visitOption(Visitor& v, const std::string& name) { \
/**
* @file
- * @author Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
- * @brief Macros for registering configuration fields
+ * @author Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
+ * @addtogroup libConfig libConfig
+ * @brief C++ library for handling configurations
*/
#ifndef COMMON_CONFIG_FIELDS_HPP
#endif
/**
- * Use this macro to register config fields.
+ * @ingroup libConfig
+ * Register empty config class
+ */
+#define CONFIG_REGISTER_EMPTY \
+ template<typename Visitor> \
+ static void accept(Visitor ) { \
+ } \
+
+/**
+ * @ingroup libConfig
+ *
+ * Registers config fields within class.
*
* Example:
+ * @code
* struct Foo
* {
* std::string bar;
* sub_a
* )
* };
+ * @endcode
*/
-
-#define CONFIG_REGISTER_EMPTY \
- template<typename Visitor> \
- static void accept(Visitor ) { \
- } \
-
#define CONFIG_REGISTER(...) \
template<typename Visitor> \
void accept(Visitor v) { \
/**
* @file
* @author Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
+ * @defgroup manager Manager
+ * @ingroup libConfig
* @brief Configuration management functions
+ *
+ * Example of various data formats operations:
+ *
+ * @code
+ * #include "config/fields.hpp"
+ * #include "config/manager.hpp"
+ * #include <iostream>
+ * #include <cstdio>
+ *
+ * struct Foo
+ * {
+ * std::string bar = "plain-text";
+ * std::vector<int> tab = std::vector<int>{1, 2, 4, 8};
+ * double number = 3.14;
+ *
+ * CONFIG_REGISTER
+ * (
+ * bar,
+ * tab,
+ * number
+ * )
+ * };
+ *
+ * int main()
+ * {
+ * Foo foo;
+ *
+ * const std::string jsonString = config::saveToJsonString(foo);
+ * config::loadFromJsonString(jsonString, foo);
+ *
+ * const GVariant* gVariantPointer = config::saveToGVariant(foo);
+ * config::loadFromGVariant(gVariantPointer, foo);
+ * g_variant_unref(gVariantPointer);
+ *
+ * constexpr std::string jsonFile = "foo.json";
+ * config::saveToJsonFile(jsonFile, foo);
+ * config::loadFromJsonFile(jsonFile, foo);
+ *
+ * constexpr std::string kvDBPath = "kvdb";
+ * constexpr std::string key = "foo";
+ * config::saveToKVStore(kvDBPath, foo, key);
+ * config::loadFromKVStore(kvDBPath, foo, key);
+ *
+ * config::loadFromKVStoreWithJson(kvDBPath, jsonString, foo, key);
+ * config::loadFromKVStoreWithJsonFile(kvDBPath, jsonFile, foo, key);
+ *
+ * FILE* file = fopen("blob", "wb");
+ * if (!file)
+ * {
+ * return EXIT_FAILURE;
+ * }
+ * const int fd = ::fileno(file);
+ * config::saveToFD(fd, foo);
+ * ::fclose(file);
+ * file = ::fopen("blob", "rb");
+ * if(!file) {
+ * return EXIT_FAILURE;
+ * }
+ * config::loadFromFD(fd, foo);
+ * ::fclose(file);
+ *
+ * return 0;
+ * }
+ * @endcode
*/
#ifndef COMMON_CONFIG_MANAGER_HPP
namespace config {
+/*@{*/
+
/**
* Fills the configuration with data stored in the GVariant
*
} // namespace config
+/*@}*/
+
#endif // COMMON_CONFIG_MANAGER_HPP