From b620fcfada9da2c78768feac0250700c6ee4f2f8 Mon Sep 17 00:00:00 2001
From: florian <f.spreckelsen@inidscale.com>
Date: Mon, 2 Aug 2021 10:04:54 +0200
Subject: [PATCH] Revert "Merge branch 'dev' into f-insert"

This reverts commit ec6a936653b9e5541982407ba51fa95c347b4504, reversing
changes made to 91a644eec8ba37ac30f1a663e5a28b3bf662bfa9.
---
 DEPENDENCIES.md                     |  4 +--
 include/caosdb/connection.h         |  3 --
 include/caosdb/entity.h             | 18 ------------
 include/caosdb/exceptions.h         | 26 ++++++++---------
 include/caosdb/log_level.h          |  4 +--
 include/caosdb/logging.h            | 43 ++++-------------------------
 include/caosdb/message_code.h       |  4 ---
 include/caosdb/transaction_status.h | 11 ++------
 include/caosdb/utility.h            | 16 +++++------
 include/ccaosdb.h                   |  4 +--
 src/caosdb/configuration.cpp        |  5 ++--
 src/caosdb/logging.cpp              |  7 -----
 src/ccaosdb.cpp                     |  5 ++--
 13 files changed, 41 insertions(+), 109 deletions(-)

diff --git a/DEPENDENCIES.md b/DEPENDENCIES.md
index 63a0678..7a8c012 100644
--- a/DEPENDENCIES.md
+++ b/DEPENDENCIES.md
@@ -1,7 +1,7 @@
 # GENERAL
 
-* >=conan-1.37.2
-* >=cmake-3.13
+* >=conan-1.37.2 (e.g. with `pip install conan`)
+* >=cmake-3.14
 * >=gcc-10.2.0 | >=clang-11
 
 # OPTIONAL
diff --git a/include/caosdb/connection.h b/include/caosdb/connection.h
index 5d7930a..22bdc6f 100644
--- a/include/caosdb/connection.h
+++ b/include/caosdb/connection.h
@@ -149,9 +149,6 @@ public:
     return ConnectionManager::GetInstance().mGetConnection(name);
   };
 
-  /**
-   * Get the connection marked by the "default" key in the configuration.
-   */
   inline static auto GetDefaultConnection()
     -> const std::shared_ptr<Connection> & {
     return ConnectionManager::GetInstance().mGetDefaultConnection();
diff --git a/include/caosdb/entity.h b/include/caosdb/entity.h
index 8d0b14a..911f621 100644
--- a/include/caosdb/entity.h
+++ b/include/caosdb/entity.h
@@ -258,24 +258,6 @@ public:
   auto Append(const Property &property) -> void;
 
   friend class Entity;
-};
-
-/**
- * Messages convey information about the state and result of transactions.
- *
- * A Message object can be thought of as kinf of a generalized error object in
- * other frameworks. Please have a look at MessageCodes for more details.
- */
-class Message {
-public:
-  explicit inline Message(caosdb::entity::v1alpha1::Message *wrapped)
-    : wrapped(wrapped){};
-  [[nodiscard]] inline auto GetCode() const -> MessageCode {
-    return get_message_code(wrapped->code());
-  }
-  [[nodiscard]] inline auto GetDescription() const -> std::string {
-    return wrapped->description();
-  }
 
 private:
   inline Properties(){};
diff --git a/include/caosdb/exceptions.h b/include/caosdb/exceptions.h
index d60f7a1..6dc44cb 100644
--- a/include/caosdb/exceptions.h
+++ b/include/caosdb/exceptions.h
@@ -32,9 +32,9 @@ using std::runtime_error;
 /**
  * @brief Generic exception class of the caosdb client library.
  */
-class Exception : public runtime_error {
+class GenericException : public runtime_error {
 public:
-  explicit Exception(StatusCode code, const std::string &what_arg)
+  explicit GenericException(StatusCode code, const std::string &what_arg)
     : runtime_error(what_arg), code(code) {}
   [[nodiscard]] inline auto GetCode() const -> StatusCode { return this->code; }
 
@@ -45,32 +45,32 @@ private:
 /**
  * @brief Exception for authentication errors.
  */
-class AuthenticationError : public Exception {
+class AuthenticationError : public GenericException {
 public:
   explicit AuthenticationError(const std::string &what_arg)
-    : Exception(StatusCode::AUTHENTICATION_ERROR, what_arg) {}
+    : GenericException(StatusCode::AUTHENTICATION_ERROR, what_arg) {}
 };
 
 /**
  * @brief The connection to the CaosDB server is down.
  */
-class ConnectionError : public Exception {
+class ConnectionError : public GenericException {
 public:
   explicit ConnectionError(const std::string &what_arg)
-    : Exception(StatusCode::CONNECTION_ERROR, what_arg) {}
+    : GenericException(StatusCode::CONNECTION_ERROR, what_arg) {}
 };
 
 /**
  * @brief The transaction terminated unsuccessfully.
  */
-class TransactionError : public Exception {
+class TransactionError : public GenericException {
 protected:
   TransactionError(StatusCode code, const std::string &what_arg)
-    : Exception(code, what_arg) {}
+    : GenericException(code, what_arg) {}
 
 public:
   explicit TransactionError(const std::string &what_arg)
-    : Exception(StatusCode::GENERIC_TRANSACTION_ERROR, what_arg) {}
+    : GenericException(StatusCode::GENERIC_TRANSACTION_ERROR, what_arg) {}
 };
 
 class TransactionStatusError : public TransactionError {
@@ -83,19 +83,19 @@ public:
  * @brief Exception for errors of the ConfigurationManager or other components
  * of the configuration.
  */
-class ConfigurationError : public Exception {
+class ConfigurationError : public GenericException {
 public:
   explicit ConfigurationError(const std::string &what_arg)
-    : Exception(StatusCode::CONFIGURATION_ERROR, what_arg) {}
+    : GenericException(StatusCode::CONFIGURATION_ERROR, what_arg) {}
 };
 
 /**
  * @brief The connection isn't known to the ConnectionManager under this name.
  */
-class UnknownConnectionError : public Exception {
+class UnknownConnectionError : public GenericException {
 public:
   explicit UnknownConnectionError(const std::string &what_arg)
-    : Exception(StatusCode::UNKNOWN_CONNECTION_ERROR, what_arg) {}
+    : GenericException(StatusCode::UNKNOWN_CONNECTION_ERROR, what_arg) {}
 };
 
 } // namespace caosdb::exceptions
diff --git a/include/caosdb/log_level.h b/include/caosdb/log_level.h
index c2fcb9b..af05d3b 100644
--- a/include/caosdb/log_level.h
+++ b/include/caosdb/log_level.h
@@ -19,8 +19,8 @@
  *
  */
 
-#ifndef CAOSDB_LOG_LEVEL_H
-#define CAOSDB_LOG_LEVEL_H
+#ifndef CAOSDB_LOG_LEVELS_H
+#define CAOSDB_LOG_LEVELS_H
 
 #define CAOSDB_LOG_LEVEL_OFF 1000000
 #define CAOSDB_LOG_LEVEL_FATAL 700
diff --git a/include/caosdb/logging.h b/include/caosdb/logging.h
index fcebc6d..26ec1c8 100644
--- a/include/caosdb/logging.h
+++ b/include/caosdb/logging.h
@@ -43,9 +43,6 @@ typedef boost::log::sources::severity_channel_logger<int, std::string>
 
 BOOST_LOG_INLINE_GLOBAL_LOGGER_DEFAULT(logger, boost_logger_class)
 
-/**
- * This class stores the integer log level.
- */
 class LevelConfiguration {
 public:
   LevelConfiguration(int level) : level(level){};
@@ -57,11 +54,6 @@ private:
 
 class SinkConfiguration;
 
-/**
- * This class stores the logging level and log sinks.
- *
- * Sinks are represented by SinkConfiguration objects.
- */
 class LoggingConfiguration : public LevelConfiguration {
 public:
   virtual ~LoggingConfiguration() = default;
@@ -77,23 +69,6 @@ private:
 auto initialize_logging_defaults() -> int;
 auto initialize_logging(const LoggingConfiguration &configuration) -> void;
 
-/**
- * A logging sink is characterized by a name and destination.
- *
- * Typical inheriting configurations exist for console, files and syslog.
- *
- * When a SinkConfiguration is created from a configuration, the sink
- * configuration must contain a \p destination key which matches one of the
- * keywords for implemented sinks.  At the moment of writing this documentation,
- * valid destinations are:
- *
- * \li \p file
- * \li \p console
- * \li \p syslog
- *
- * A \p level keyword sets the logging level, if it exists at the sink or
- * logging level of the configuration.
- */
 class SinkConfiguration : public LevelConfiguration {
 public:
   virtual ~SinkConfiguration() = default;
@@ -129,12 +104,6 @@ private:
   const std::string destination = "Console";
 };
 
-/**
- * The file name is the destination, the directory can be set separately.
- *
- * If there is a `directory` key in the configuration, that will be used as a
- * default, otherwise it is the current directory.
- */
 class FileSinkConfiguration : public SinkConfiguration {
 public:
   virtual ~FileSinkConfiguration() = default;
@@ -167,27 +136,27 @@ private:
 };
 
 /**
- * Convenience function for the C interface.
+ * Convenience function for the c-interface.
  */
 void caosdb_log_fatal(const char *channel, const char *msg);
 /**
- * Convenience function for the C interface.
+ * Convenience function for the c-interface.
  */
 void caosdb_log_error(const char *channel, const char *msg);
 /**
- * Convenience function for the C interface.
+ * Convenience function for the c-interface.
  */
 void caosdb_log_warn(const char *channel, const char *msg);
 /**
- * Convenience function for the C interface.
+ * Convenience function for the c-interface.
  */
 void caosdb_log_info(const char *channel, const char *msg);
 /**
- * Convenience function for the C interface.
+ * Convenience function for the c-interface.
  */
 void caosdb_log_debug(const char *channel, const char *msg);
 /**
- * Convenience function for the C interface.
+ * Convenience function for the c-interface.
  */
 void caosdb_log_trace(const char *channel, const char *msg);
 
diff --git a/include/caosdb/message_code.h b/include/caosdb/message_code.h
index 2cc3f51..17ec1c1 100644
--- a/include/caosdb/message_code.h
+++ b/include/caosdb/message_code.h
@@ -30,10 +30,6 @@
  * In contrast to the status codes, the message codes are part of the CaosDB
  * API. Messages (and their codes) represent the state of the entities in a
  * transaction or the server.
- *
- * For a specification of the message codes, look at the protobuf documentation.
- * The sources and documentation can be found at
- * https://gitlab.indiscale.com/caosdb/src/caosdb-proto.
  */
 
 namespace caosdb::entity {
diff --git a/include/caosdb/transaction_status.h b/include/caosdb/transaction_status.h
index 6c5b7a6..8645ace 100644
--- a/include/caosdb/transaction_status.h
+++ b/include/caosdb/transaction_status.h
@@ -25,12 +25,7 @@
 /**
  * TransactionStatus indicates the current status of a transaction and, when it
  * has already terminated, whether the transaction has been successful or not.
- *
- * A status code of 0 denotes a generic success state, positive values indicate
- * errors, and negative values indicate other states, such as different stages
- * of a transaction in process.
  */
-
 #include "caosdb/status_code.h"
 #include "caosdb/exceptions.h"
 #include <memory> // for shared_ptr, unique_ptr
@@ -40,7 +35,7 @@ namespace caosdb::transaction {
 using caosdb::StatusCode;
 using caosdb::exceptions::AuthenticationError;
 using caosdb::exceptions::ConnectionError;
-using caosdb::exceptions::Exception;
+using caosdb::exceptions::GenericException;
 using caosdb::exceptions::TransactionError;
 
 /**
@@ -118,7 +113,7 @@ public:
     case StatusCode::GENERIC_TRANSACTION_ERROR:
       throw TransactionError(this->description);
     default:
-      throw Exception(StatusCode::GENERIC_ERROR, this->description);
+      throw GenericException(StatusCode::GENERIC_ERROR, this->description);
     }
   }
 
@@ -135,7 +130,7 @@ public:
   /**
    * Return a description of the erroneous state.
    *
-   * No description yields an empty string.
+   * Returns an empty string if there is no description.
    */
   inline auto GetDescription() const -> const std::string & {
     return this->description;
diff --git a/include/caosdb/utility.h b/include/caosdb/utility.h
index 30e2174..e1e306e 100644
--- a/include/caosdb/utility.h
+++ b/include/caosdb/utility.h
@@ -43,6 +43,8 @@ using boost::json::value;
 
 /**
  * @brief Read a text file into a string and return the file's content.
+ *
+ * TODO use boost-filesystem's "load_string_file"!
  */
 inline auto load_string_file(const path &path) -> std::string {
   std::string result;
@@ -50,13 +52,11 @@ inline auto load_string_file(const path &path) -> std::string {
   return result;
 }
 
-/**
- * @brief Return the environment variable KEY, or FALLBACK if it does not exist.
- */
-inline auto get_env_var(const char *key, const char *fallback) -> const char * {
+inline auto get_env_var(const char *key, const char *fall_back) -> const
+  char * {
   const char *val = getenv(key);
   if (val == nullptr) {
-    return fallback;
+    return fall_back;
   } else {
     return val;
   }
@@ -64,11 +64,11 @@ inline auto get_env_var(const char *key, const char *fallback) -> const char * {
 
 /**
  * @brief Return the value of an environment variable or - if undefined - the
- * fallback value.
+ * fall_back value.
  */
-inline auto get_env_var(const std::string &key, const std::string &fallback)
+inline auto get_env_var(const std::string &key, const std::string &fall_back)
   -> const std::string {
-  const char *val = get_env_var(key.c_str(), fallback.c_str());
+  const char *val = get_env_var(key.c_str(), fall_back.c_str());
 
   auto const result = std::string(val);
   return result;
diff --git a/include/ccaosdb.h b/include/ccaosdb.h
index bb62a51..0df5f0e 100644
--- a/include/ccaosdb.h
+++ b/include/ccaosdb.h
@@ -79,9 +79,9 @@ typedef struct {
 /**
  * Return the environment variable of the given name.
  *
- * If the environment variable is not set, return the fallback instead.
+ * If the environment variable is not set, return the fall_back instead.
  */
-const char *caosdb_utility_get_env_var(const char *name, const char *fallback);
+const char *caosdb_utility_get_env_var(const char *name, const char *fall_back);
 
 /**
  * Return a description of the status code.
diff --git a/src/caosdb/configuration.cpp b/src/caosdb/configuration.cpp
index eb54659..b3934d3 100644
--- a/src/caosdb/configuration.cpp
+++ b/src/caosdb/configuration.cpp
@@ -358,7 +358,7 @@ auto ConfigurationManager::mReset() noexcept -> int {
     mClear();
     InitializeDefaults();
     return StatusCode::SUCCESS;
-  } catch (const caosdb::exceptions::Exception &exc) {
+  } catch (const caosdb::exceptions::GenericException &exc) {
     return exc.GetCode();
   } catch (const std::exception &exc) {
     CAOSDB_LOG_ERROR(logger_name)
@@ -373,7 +373,7 @@ auto ConfigurationManager::mClear() noexcept -> int {
     json_configuration = value(nullptr);
     ConnectionManager::Reset();
     return StatusCode::SUCCESS;
-  } catch (const caosdb::exceptions::Exception &exc) {
+  } catch (const caosdb::exceptions::GenericException &exc) {
     return exc.GetCode();
   } catch (const std::exception &exc) {
     CAOSDB_LOG_ERROR(logger_name)
@@ -511,7 +511,6 @@ auto ConfigurationManager::InitializeDefaults() -> int { // NOLINT
     mLoadSingleJSONConfiguration(*configuration_file_path);
   }
 
-  // Logging in the configuration leads to additional content.
   if (this->json_configuration.is_object() &&
       this->json_configuration.as_object().contains("logging")) {
     LoggingConfiguration logging_configuration =
diff --git a/src/caosdb/logging.cpp b/src/caosdb/logging.cpp
index 3618826..486ab84 100644
--- a/src/caosdb/logging.cpp
+++ b/src/caosdb/logging.cpp
@@ -59,7 +59,6 @@ auto LoggingConfiguration::GetSinks() const
 
 SinkConfiguration::SinkConfiguration(std::string name, int level)
   : LevelConfiguration(level), name(std::move(name)) {}
-
 [[nodiscard]] auto SinkConfiguration::GetName() const -> const std::string & {
   return this->name;
 }
@@ -78,7 +77,6 @@ auto SinkConfiguration::Configure(boost::log::settings &settings) const
 ConsoleSinkConfiguration::ConsoleSinkConfiguration(const std::string &name,
                                                    int level)
   : SinkConfiguration(name, level) {}
-
 [[nodiscard]] auto ConsoleSinkConfiguration::GetDestination() const
   -> const std::string & {
   CAOSDB_LOG_TRACE(logger_name)
@@ -95,14 +93,12 @@ auto ConsoleSinkConfiguration::Configure(boost::log::settings &settings) const
 
 FileSinkConfiguration::FileSinkConfiguration(const std::string &name, int level)
   : SinkConfiguration(name, level) {}
-
 [[nodiscard]] auto FileSinkConfiguration::GetDestination() const
   -> const std::string & {
   CAOSDB_LOG_TRACE(logger_name)
     << "Enter FileSinkConfiguration::GetDestination()";
   return this->destination;
 }
-
 auto FileSinkConfiguration::SetDirectory(const std::string &directory) -> void {
   this->directory = std::string(directory);
 }
@@ -118,13 +114,11 @@ auto FileSinkConfiguration::Configure(boost::log::settings &settings) const
 SyslogSinkConfiguration::SyslogSinkConfiguration(const std::string &name,
                                                  int level)
   : SinkConfiguration(name, level) {}
-
 [[nodiscard]] auto SyslogSinkConfiguration::GetDestination() const
   -> const std::string & {
   return this->destination;
 }
 
-// Called if no custom logging settings are specified.
 auto initialize_logging_defaults() -> int {
   // first: turn everything off
   boost::log::settings off_settings;
@@ -154,7 +148,6 @@ auto initialize_logging_defaults() -> int {
   return 0;
 }
 
-// Called if custom logging settings are specified.
 auto initialize_logging(const LoggingConfiguration &configuration) -> void {
   boost::log::settings new_settings;
 
diff --git a/src/ccaosdb.cpp b/src/ccaosdb.cpp
index 5f89af1..d21b3bd 100644
--- a/src/ccaosdb.cpp
+++ b/src/ccaosdb.cpp
@@ -56,8 +56,9 @@ const char *caosdb_constants_COMPATIBLE_SERVER_VERSION_PRE_RELEASE() {
   return caosdb::COMPATIBLE_SERVER_VERSION_PRE_RELEASE;
 }
 
-const char *caosdb_utility_get_env_var(const char *name, const char *fallback) {
-  return caosdb::utility::get_env_var(name, fallback);
+const char *caosdb_utility_get_env_var(const char *name,
+                                       const char *fall_back) {
+  return caosdb::utility::get_env_var(name, fall_back);
 }
 
 const char *caosdb_get_status_description(int code) {
-- 
GitLab