From 855d1ed61c1161b1cdf8b6e8f878ede0c0c03089 Mon Sep 17 00:00:00 2001
From: Daniel <d.hornung@indiscale.com>
Date: Tue, 3 Aug 2021 09:59:10 +0200
Subject: [PATCH] STY: Fixing style problems.

---
 .miss_hit                 |  2 +-
 src/Caosdb.m              | 41 ++++++++++++++++++++++++++++++++++-----
 src/caosdbClass.m         | 29 ---------------------------
 src/lib/maoxdb.cpp        |  8 +++++---
 src/lib/maoxdb.hpp        | 23 ++++++++++++----------
 src/lib/test.cpp          |  2 +-
 src/private/maox_info.cpp |  2 +-
 7 files changed, 57 insertions(+), 50 deletions(-)
 delete mode 100644 src/caosdbClass.m

diff --git a/.miss_hit b/.miss_hit
index 1ec1ed2..025b96a 100644
--- a/.miss_hit
+++ b/.miss_hit
@@ -2,6 +2,6 @@
 # See https://florianschanda.github.io/miss_hit/style_checker.html
 
 line_length: 100
-regex_function_name: "[_a-z]+(_[a-z]+)*"
+# regex_function_name: "[a-z]+(_[a-z]+)*"
 suppress_rule: "whitespace_comments"
 tab_width: 2
diff --git a/src/Caosdb.m b/src/Caosdb.m
index 7345ca2..484759b 100644
--- a/src/Caosdb.m
+++ b/src/Caosdb.m
@@ -1,8 +1,8 @@
-% (C) Copyright 2021 IndiScale GmbH <info@indiscale.com>
-% (C) Copyright 2021 Timm FItschen <t.fitschen@indiscale.com>
-%
 % This file is a part of the CaosDB Project.
 %
+% Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
+% Copyright (C) 2021 Daniel Hornung <d.hornung@indiscale.com>
+%
 % This program is free software: you can redistribute it and/or modify
 % it under the terms of the GNU Affero General Public License as
 % published by the Free Software Foundation, either version 3 of the
@@ -17,8 +17,8 @@
 % along with this program. If not, see <https://www.gnu.org/licenses/>.
 
 % -*- texinfo -*-
-% @deftypefn {Loadable Function} {} caosdb ([@var{OPTIONS}])
-% This is the main function of the CaosDB client for Octave.
+% @deftypefn {Class} {} Caosdb ()
+% This is the main class of the CaosDB client for Octave.
 %
 % Print usage help and return:
 % @example
@@ -40,3 +40,34 @@
 %!demo
 %! ## Print Help:
 %! caosdb --help;
+classdef Caosdb < handle
+  properties
+    connection = ""             % Will use the default connection
+  end
+
+  methods
+
+    function obj = Caosdb(connection)
+      if nargin == 0
+        connection = "";
+      end
+      obj.connection = connection;
+    end
+
+    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+    %                                     info                                    %
+    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+    function res = info(obj)
+      disp(["connection: >", obj.connection, "<"]);
+      try
+        info_result = maox_info(obj.connection);
+        res = info_result;
+      catch
+        disp("some error!");
+        disp(lasterror());
+        res = NA;
+      end
+    end
+
+  end
+end
diff --git a/src/caosdbClass.m b/src/caosdbClass.m
deleted file mode 100644
index 869845e..0000000
--- a/src/caosdbClass.m
+++ /dev/null
@@ -1,29 +0,0 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%                                    Hello                                    %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-classdef caosdbClass < handle
-  properties
-    connection;             % Will use the default connection
-  endproperties
-
-  methods
-    function obj = caosdbClass(connection="")
-      obj.connection = connection;
-    endfunction
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%                                     info                                    %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-    function res = info(obj)
-      disp(["connection: >", obj.connection, "<"]);
-      try
-        info_result = maox_info(obj.connection);
-        res = info_result;
-      catch
-        disp("some error!")
-        disp(lasterror())
-        res = NA;
-      end_try_catch
-    endfunction
-  endmethods
-endclassdef
diff --git a/src/lib/maoxdb.cpp b/src/lib/maoxdb.cpp
index edb040d..0e6dfa1 100644
--- a/src/lib/maoxdb.cpp
+++ b/src/lib/maoxdb.cpp
@@ -34,10 +34,12 @@ using std::string;
 /**
  * Extract useful strings from an Exception: ID and description.
  */
-std::pair<string, string> exceptionToMessage(const caosdb::exceptions::Exception &exc) {
+std::pair<string, string>
+exceptionToMessage(const caosdb::exceptions::Exception &exc) {
 
   string id = std::to_string(exc.GetCode());
-  string text = caosdb::get_status_description(exc.GetCode()) + "\n" + exc.what();
+  string text =
+    caosdb::get_status_description(exc.GetCode()) + "\n" + exc.what();
 
   return std::pair<string, string>(id, text);
 }
@@ -50,4 +52,4 @@ void throwOctException(const caosdb::exceptions::Exception &exc) {
   mexErrMsgIdAndTxt(excContent.first.c_str(), excContent.second.c_str());
 }
 
-}
+} // namespace maoxdb
diff --git a/src/lib/maoxdb.hpp b/src/lib/maoxdb.hpp
index b3d98be..46ff817 100644
--- a/src/lib/maoxdb.hpp
+++ b/src/lib/maoxdb.hpp
@@ -42,24 +42,27 @@ void test();
 /**
  * @brief Handle a CaosDB Exception and transform into error code and message.
  *
- * @details This function does all the processing to transform the information in an Exception
- * object into a form that can conveniently be handled by Octave via the mexErrMsgIdAndTxt function.
+ * @details This function does all the processing to transform the information
+ * in an Exception object into a form that can conveniently be handled by Octave
+ * via the mexErrMsgIdAndTxt function.
  *
  * @param exc The Exception object.
  *
- * @return pair<string msgId, string msgText> The message ID and message text which can be passed to
- * Octave.
+ * @return pair<string msgId, string msgText> The message ID and message text
+ * which can be passed to Octave.
  *
- * @note Additional utility functions should be easy to implement when the libcaosdb error handling
- * changes.
+ * @note Additional utility functions should be easy to implement when the
+ * libcaosdb error handling changes.
  */
-std::pair<string, string> exceptionToMessage(const caosdb::exceptions::Exception &exc);
+std::pair<string, string>
+exceptionToMessage(const caosdb::exceptions::Exception &exc);
 
 /**
  * @brief Throw a CaosDB Exception inside Octave.
  *
- * @details This function does all the processing to transform the information in an Exception
- * object into a form that is accepted by Octave's error handling.d
+ * @details This function does all the processing to transform the information
+ * in an Exception object into a form that is accepted by Octave's error
+ * handling.d
  *
  * Internally, this function uses the exceptionToMessage function.
  *
@@ -67,6 +70,6 @@ std::pair<string, string> exceptionToMessage(const caosdb::exceptions::Exception
  */
 void throwOctException(const caosdb::exceptions::Exception &exc);
 
-}  // maoxdb
+} // namespace maoxdb
 
 #endif /* MAOXDB_H */
diff --git a/src/lib/test.cpp b/src/lib/test.cpp
index 41d1bb7..6b871ff 100644
--- a/src/lib/test.cpp
+++ b/src/lib/test.cpp
@@ -9,4 +9,4 @@ void test() {
   auto *mx_str = mxCreateString("Hello World!");
 }
 
-}  // maoxdb
+} // namespace maoxdb
diff --git a/src/private/maox_info.cpp b/src/private/maox_info.cpp
index de36999..9009e3d 100644
--- a/src/private/maox_info.cpp
+++ b/src/private/maox_info.cpp
@@ -7,7 +7,7 @@
 #include <cstring>             // for strcmp
 #include <memory>              // for unique_ptr, __shared_ptr_access, shar...
 #include <string>              // for allocator, char_traits, operator+
-#include "maoxdb.hpp"              // caosDB utils for mex files
+#include "maoxdb.hpp"          // caosDB utils for mex files
 
 using caosdb::connection::Connection;
 using caosdb::connection::ConnectionManager;
-- 
GitLab