diff --git a/inc/kul/asio/log.hpp b/inc/kul/asio/log.hpp index 7174d40..c989dbd 100644 --- a/inc/kul/asio/log.hpp +++ b/inc/kul/asio/log.hpp @@ -97,25 +97,23 @@ class Message { } }; class LogMessage : public Message { - private: - const char *f; - const char *fn; - const uint16_t &l; public: ~LogMessage() { LogMan::INSTANCE().log(f, fn, l, m, ss.str()); } LogMessage(const char *f, const char *fn, const uint16_t &l, const kul::log::mode &m) : Message(m), f(f), fn(fn), l(l) {} + + private: + const char *f, *fn; + const uint16_t &l; }; -class OutMessage : public Message { - public: - ~OutMessage() { LogMan::INSTANCE().out(m, ss.str()); } +struct OutMessage : public Message { OutMessage(const kul::log::mode &m = kul::log::mode::NON) : Message(m) {} + ~OutMessage() { LogMan::INSTANCE().out(m, ss.str()); } }; -class ErrMessage : public Message { - public: - ~ErrMessage() { LogMan::INSTANCE().err(ss.str()); } +struct ErrMessage : public Message { ErrMessage() : Message(kul::log::mode::ERR) {} + ~ErrMessage() { LogMan::INSTANCE().err(ss.str()); } }; #define KASIO_LOG_INF kul::asio::LogMessage(__FILE__, __func__, __LINE__, kul::log::mode::INF) diff --git a/inc/kul/assert.hpp b/inc/kul/assert.hpp index b100675..18ecaa6 100644 --- a/inc/kul/assert.hpp +++ b/inc/kul/assert.hpp @@ -33,31 +33,32 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "kul/signal.hpp" -namespace kul{ -struct Assert{ +namespace kul { +struct Assert { template Assert(T t) { #if !defined(NDEBUG) - if(!(t)) { + if (!(t)) { auto tid = kul::this_thread::id(); KOUT(NON) << tid << " : Stacktrace:"; - for(auto const& s : kul::this_thread::stacktrace()) KOUT(NON) << tid << " : " << s; + for (auto const& s : kul::this_thread::stacktrace()) KOUT(NON) << tid << " : " << s; exit(111); } #endif } }; -} +} // namespace kul #if !defined(KASSERT) -#define KASSERT(b) kul::Assert{(b)} +#define KASSERT(b) \ + kul::Assert { (b) } #endif #if defined(KASSERT_REPLACE_ASSERT) - #ifdef assert - #undef assert - #endif - #define assert(b) KASSERT(b) +#ifdef assert +#undef assert +#endif +#define assert(b) KASSERT(b) #endif #endif /* _KUL_ASSERT_HPP_ */ diff --git a/inc/kul/cli.hpp b/inc/kul/cli.hpp index 22cdc4a..d852ef7 100644 --- a/inc/kul/cli.hpp +++ b/inc/kul/cli.hpp @@ -36,9 +36,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include "kul/env.hpp" +#include "kul/except.hpp" #include "kul/map.hpp" #include "kul/os/cli.hpp" -#include "kul/except.hpp" #include "kul/serial.hpp" #include "kul/string.hpp" @@ -112,21 +112,20 @@ class EnvVar { enum ArgType { FLAG = 0, STRING, MAYBE }; class Arg : public Cmd { - static constexpr char INVALID_CHAR = ' '; + static constexpr char INVALID_CHAR = ' '; public: Arg(const char d, char const *dd, ArgType t, bool m = false) : Cmd(dd), man(m), d(d), t(t) {} Arg(const char d, char const *dd, bool m = false) : Cmd(dd), man(m), d(d) {} Arg(char const *dd, ArgType t, bool m = false) : Cmd(dd), man(m), t(t) {} - Arg(char const *dd, bool m = false) : Cmd(dd), man(m){} + Arg(char const *dd, bool m = false) : Cmd(dd), man(m) {} bool mandatory() const { return man; } char dash() const { return d; } char const *dashdash() const { return command(); } const ArgType &type() const { return t; } - private: bool man; const char d = ' '; @@ -262,6 +261,7 @@ class Args { std::vector cmds; std::vector args; hash::map::S2S vals; + public: #include "kul/serial/cli.arg.end.hpp" }; @@ -283,5 +283,4 @@ inline std::vector asArgs(const std::string &cmd) { #include "kul/serial/cli.bottom.hpp" - #endif /* _KUL_CLI_HPP_ */ diff --git a/inc/kul/cpu.hpp b/inc/kul/cpu.hpp index 8525d98..528736c 100644 --- a/inc/kul/cpu.hpp +++ b/inc/kul/cpu.hpp @@ -33,7 +33,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "kul/defs.hpp" -#if KUL_IS_NIX +#if KUL_IS_NIX #include "kul/os/nix/cpu.hpp" #elif KUL_IS_BSD #include "kul/os/bsd/cpu.hpp" diff --git a/inc/kul/dbg.hpp b/inc/kul/dbg.hpp index 5efb346..0f10d1d 100644 --- a/inc/kul/dbg.hpp +++ b/inc/kul/dbg.hpp @@ -36,19 +36,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace kul { namespace dbg { -class StackTrace{ +class StackTrace { private: - std::vector _stk; + std::vector _stk; + public: - StackTrace() = delete; - StackTrace(const StackTrace &) = delete; - StackTrace &operator=(const StackTrace &) = delete; - StackTrace &operator=(const StackTrace &&) = delete; - StackTrace(const std::string &s) { _stk.emplace_back(s); } - StackTrace(const StackTrace &&that) { - if(this != &that) this->_stk = that._stk; - } - const std::vector &stack() const { return _stk; } + StackTrace() = delete; + StackTrace(const StackTrace &) = delete; + StackTrace &operator=(const StackTrace &) = delete; + StackTrace &operator=(const StackTrace &&) = delete; + StackTrace(const std::string &s) { _stk.emplace_back(s); } + StackTrace(const StackTrace &&that) { + if (this != &that) this->_stk = that._stk; + } + const std::vector &stack() const { return _stk; } }; #if !defined(NDEBUG) || defined(KUL_FORCE_TRACE) @@ -69,10 +70,10 @@ class StackTrace{ #endif // KUL_DBG_FUNC_ENTER #ifndef KUL_DBG_FUNC_ON_ENTER -#define KUL_DBG_FUNC_ON_ENTER \ +#define KUL_DBG_FUNC_ON_ENTER \ KOUT(TRC) << kul::LogMan::INSTANCE().str(m_fi, m_fu, m_li, kul::log::mode::TRC, "", \ "[%M]: %T - %D : %F:%L fn(%N)") \ - << " - ENTERED"; + << " - ENTERED"; #endif // KUL_DBG_FUNC_ON_ENTER #ifndef KUL_DBG_FUNC_ON_EXIT diff --git a/inc/kul/defs.hpp b/inc/kul/defs.hpp index df3bcb7..7f35c65 100644 --- a/inc/kul/defs.hpp +++ b/inc/kul/defs.hpp @@ -65,7 +65,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define KUL_PRIVATE #endif -#if defined(__APPLE__) || defined(__NetBSD__) || defined(__FreeBSD__) +#if defined(__APPLE__) || defined(__NetBSD__) || defined(__FreeBSD__) #define KUL_IS_BSD 1 #endif diff --git a/inc/kul/env.hpp b/inc/kul/env.hpp index fe4dd84..29ae306 100644 --- a/inc/kul/env.hpp +++ b/inc/kul/env.hpp @@ -42,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace kul { namespace env { -class Var { +class Var { public: enum Mode { APPE = 0, PREP, REPL }; diff --git a/inc/kul/except.hpp b/inc/kul/except.hpp index 43d46fc..22282ab 100644 --- a/inc/kul/except.hpp +++ b/inc/kul/except.hpp @@ -31,8 +31,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef _KUL_EXCEPT_HPP_ #define _KUL_EXCEPT_HPP_ -#include #include +#include #include #include "kul/defs.hpp" @@ -61,11 +61,9 @@ class Exception : public std::runtime_error { Exception(const char *f, const uint16_t &l, const std::string &s = "") : std::runtime_error(s), _f(f), _l(l), _ep(std::current_exception()), err(s) {} Exception(Exception const &e) - : std::runtime_error(e), _f(e.file()), _l(e.line()), _ep(e._ep), err(e.err) { - } + : std::runtime_error(e), _f(e.file()), _l(e.line()), _ep(e._ep), err(e.err) {} Exception(Exception const &&e) - : std::runtime_error(e), _f(e.file()), _l(e.line()), _ep(e._ep), err(e.err) { - } + : std::runtime_error(e), _f(e.file()), _l(e.line()), _ep(e._ep), err(e.err) {} virtual ~Exception() KNOTHROW {} std::string debug() const { @@ -74,12 +72,8 @@ class Exception : public std::runtime_error { return ss.str(); } - const char* what() const noexcept override { - return err.c_str(); - } - std::string str() const noexcept { - return err; - } + const char *what() const noexcept override { return err.c_str(); } + std::string str() const noexcept { return err; } const char *file() const { return _f; } const uint16_t &line() const { return _l; } @@ -107,6 +101,7 @@ class Exception : public std::runtime_error { err += msg.str(); return *this; } + protected: const char *_f; const uint16_t _l; diff --git a/inc/kul/for.hpp b/inc/kul/for.hpp index debdeed..9f809bd 100644 --- a/inc/kul/for.hpp +++ b/inc/kul/for.hpp @@ -37,19 +37,17 @@ namespace kul { /* struct Apply { template - decltype(auto) operator()(){} + constexpr decltype(auto) operator()(){} };*/ -template -constexpr decltype(auto) for_N(Apply& f, std::integer_sequence const&) -{ - if constexpr (!std::is_same_v()), void>) - return std::make_tuple(f.template operator()()...); - (f.template operator()(), ...); +template +constexpr decltype(auto) for_N(Apply& f, std::integer_sequence const&) { + if constexpr (!std::is_same_v()), void>) + return std::make_tuple(f.template operator()()...); + (f.template operator()(), ...); } -template -constexpr decltype(auto) for_N(Apply&& f) -{ - return for_N(f, std::make_integer_sequence{}); +template +constexpr decltype(auto) for_N(Apply&& f) { + return for_N(f, std::make_integer_sequence{}); } } // namespace kul diff --git a/inc/kul/io.hpp b/inc/kul/io.hpp index e1e80bf..4dd11bb 100644 --- a/inc/kul/io.hpp +++ b/inc/kul/io.hpp @@ -96,7 +96,7 @@ class AReader { std::vector v; v.resize(l); _f.read(&v[0], l); - v.resize((size_t) _f.gcount()); + v.resize((size_t)_f.gcount()); s1 = std::string(v.begin(), v.end()); std::strcpy(c, s1.c_str()); return s1.size(); diff --git a/inc/kul/log.hpp b/inc/kul/log.hpp index 4f89517..5996543 100644 --- a/inc/kul/log.hpp +++ b/inc/kul/log.hpp @@ -192,15 +192,35 @@ class Message { } }; class LogMessage : public Message { + public: + LogMessage(const char *_f, const char *_fn, const uint16_t &_l, const log::mode &_m) + : Message(_m), f(_f), fn(_fn), l(_l) {} + ~LogMessage() { LogMan::INSTANCE().log(f, fn, l, m, ss.str()); } + private: - const char *f; - const char *fn; + const char *f, *fn; const uint16_t &l; - +}; +class DBgMessage : public Message { public: - ~LogMessage() { LogMan::INSTANCE().log(f, fn, l, m, ss.str()); } - LogMessage(const char *_f, const char *_fn, const uint16_t &_l, const log::mode &_m) + ~DBgMessage() { +#if !defined(NDEBUG) + LogMan::INSTANCE().log(f, fn, l, m, ss.str()); +#endif + } + DBgMessage(const char *_f, const char *_fn, const uint16_t &_l, const log::mode &_m) : Message(_m), f(_f), fn(_fn), l(_l) {} + template + DBgMessage &operator<<(const T &s) { +#if !defined(NDEBUG) + ss << s; +#endif + return *this; + } + + private: + const char *f, *fn; + const uint16_t &l; }; class OutMessage : public Message { public: @@ -212,21 +232,37 @@ class ErrMessage : public Message { ~ErrMessage() { LogMan::INSTANCE().err(ss.str()); } ErrMessage() : Message(log::mode::ERR) {} }; +class DBoMessage : public Message { + public: + ~DBoMessage() { +#if !defined(NDEBUG) + LogMan::INSTANCE().out(m, ss.str()); +#endif + } + DBoMessage(const log::mode &_m = kul::log::mode::NON) : Message(_m) {} + template + DBoMessage &operator<<(const T &s) { +#if !defined(NDEBUG) + ss << s; +#endif + return *this; + } +}; #define KLOG_NON kul::LogMessage(__FILE__, __func__, __LINE__, kul::log::mode::NON) #define KLOG_INF kul::LogMessage(__FILE__, __func__, __LINE__, kul::log::mode::INF) #define KLOG_ERR kul::LogMessage(__FILE__, __func__, __LINE__, kul::log::mode::ERR) -#define KLOG_DBG kul::LogMessage(__FILE__, __func__, __LINE__, kul::log::mode::DBG) -#define KLOG_OTH kul::LogMessage(__FILE__, __func__, __LINE__, kul::log::mode::OTH) -#define KLOG_TRC kul::LogMessage(__FILE__, __func__, __LINE__, kul::log::mode::TRC) +#define KLOG_DBG kul::DBgMessage(__FILE__, __func__, __LINE__, kul::log::mode::DBG) +#define KLOG_OTH kul::DBgMessage(__FILE__, __func__, __LINE__, kul::log::mode::OTH) +#define KLOG_TRC kul::DBgMessage(__FILE__, __func__, __LINE__, kul::log::mode::TRC) #define KLOG(sev) KLOG_##sev #define KOUT_NON kul::OutMessage() #define KOUT_INF kul::OutMessage(kul::log::mode::INF) #define KOUT_ERR kul::OutMessage(kul::log::mode::ERR) -#define KOUT_DBG kul::OutMessage(kul::log::mode::DBG) -#define KOUT_OTH kul::OutMessage(kul::log::mode::OTH) -#define KOUT_TRC kul::OutMessage(kul::log::mode::TRC) +#define KOUT_DBG kul::DBoMessage(kul::log::mode::DBG) +#define KOUT_OTH kul::DBoMessage(kul::log::mode::OTH) +#define KOUT_TRC kul::DBoMessage(kul::log::mode::TRC) #define KOUT(sev) KOUT_##sev #define KERR kul::ErrMessage() diff --git a/inc/kul/math/blas.hpp b/inc/kul/math/blas.hpp index 36023d6..2ca9ee8 100644 --- a/inc/kul/math/blas.hpp +++ b/inc/kul/math/blas.hpp @@ -4,49 +4,57 @@ namespace kul { namespace math { -template static inline -typename std::enable_if::value>::type -mult_incr(const uint64_t n, const K alpha, const Y *x, T *y) { +template +static inline typename std::enable_if::value>::type mult_incr( + const uint64_t n, const K alpha, const Y *x, T *y) { cblas_saxpy(n, alpha, x, 1, y, 1); } -template static inline -typename std::enable_if::value>::type -mult_incr(const uint64_t n, const K alpha, const Y *x, T *y) { +template +static inline typename std::enable_if::value>::type mult_incr( + const uint64_t n, const K alpha, const Y *x, T *y) { cblas_daxpy(n, alpha, x, 1, y, 1); } -template static inline -typename std::enable_if::value && - !std::is_same>::value && - !std::is_same>::value, K>::type +template +static inline typename std::enable_if::value && + !std::is_same>::value && + !std::is_same>::value, + K>::type dot(const size_t n, const T *x, const K *y) { return cblas_sdot(n, x, 1, y, 1); } -template static inline -typename std::enable_if::value && - !std::is_same>::value && - !std::is_same>::value, K>::type +template +static inline typename std::enable_if::value && + !std::is_same>::value && + !std::is_same>::value, + K>::type dot(const size_t n, const T *x, const K *y) { return cblas_ddot(n, x, 1, y, 1); } -template static inline -typename std::enable_if::value>::type -scale(const size_t n, const std::atomic alpha, T *x) { +template +static inline typename std::enable_if::value>::type scale( + const size_t n, const std::atomic alpha, T *x) { cblas_sscal(n, alpha.load(), x, 1); } -template static inline -typename std::enable_if::value>::type -scale(const size_t n, const K alpha, T *x) { cblas_sscal(n, alpha, x, 1); } +template +static inline typename std::enable_if::value>::type scale(const size_t n, + const K alpha, + T *x) { + cblas_sscal(n, alpha, x, 1); +} -template static inline -typename std::enable_if::value>::type -scale(const size_t n, const std::atomic alpha, T *x) { +template +static inline typename std::enable_if::value>::type scale( + const size_t n, const std::atomic alpha, T *x) { cblas_dscal(n, alpha.load(), x, 1); } -template static inline -typename std::enable_if::value>::type -scale(const size_t n, const K alpha, T *x) { cblas_dscal(n, alpha, x, 1); } +template +static inline typename std::enable_if::value>::type scale(const size_t n, + const K alpha, + T *x) { + cblas_dscal(n, alpha, x, 1); +} } // namespace math } // namespace kul #endif // KUL_MATH_BLAS_HPP_ diff --git a/inc/kul/math/noblas.hpp b/inc/kul/math/noblas.hpp index dccaabf..2fd2627 100644 --- a/inc/kul/math/noblas.hpp +++ b/inc/kul/math/noblas.hpp @@ -4,29 +4,34 @@ namespace kul { namespace math { -template static inline -typename std::enable_if::value || std::is_same::value>::type -mult_incr(const uint64_t n, const K alpha, const Y *x, T *y) { +template +static inline + typename std::enable_if::value || std::is_same::value>::type + mult_incr(const uint64_t n, const K alpha, const Y *x, T *y) { detail::mult_incr(n, alpha, x, y); } -template static inline -typename std::enable_if<(std::is_same::value || std::is_same::value) && - !std::is_same>::value && - !std::is_same>::value, K>::type -dot(const size_t n, const T *x, const K *y) { +template +static inline + typename std::enable_if<(std::is_same::value || std::is_same::value) && + !std::is_same>::value && + !std::is_same>::value, + K>::type + dot(const size_t n, const T *x, const K *y) { return detail::dot(n, x, y); } -template static inline -typename std::enable_if::value || std::is_same::value>::type -scale(const size_t n, const std::atomic alpha, T *x) { +template +static inline + typename std::enable_if::value || std::is_same::value>::type + scale(const size_t n, const std::atomic alpha, T *x) { detail::scale(n, alpha.load(), x); } -template static inline -typename std::enable_if::value || std::is_same::value>::type -scale(const size_t n, const K alpha, T *x) { +template +static inline + typename std::enable_if::value || std::is_same::value>::type + scale(const size_t n, const K alpha, T *x) { detail::scale(n, alpha, x); } diff --git a/inc/kul/math/noop.hpp b/inc/kul/math/noop.hpp index 4849f90..ce5459b 100644 --- a/inc/kul/math/noop.hpp +++ b/inc/kul/math/noop.hpp @@ -2,7 +2,8 @@ #ifndef KUL_MATH_NOOP_HPP_ #define KUL_MATH_NOOP_HPP_ -// This macro ensures that the corresponding optimized blas function is used if available +// This macro ensures that the corresponding optimized blas function is used if +// available #if !defined(NDEBUG) && defined(_KUL_USE_CBLAS) // x and y are two pointers #define CHECK_BLAS_OPTIMIZATION_PP(x, y, func_name) \ @@ -57,33 +58,33 @@ T dot(const size_t n, const T *x, const std::atomic *y) { } } // namespace detail template -typename std::enable_if< - (!std::is_same::value && !std::is_same::value) && - std::is_same>::value, T>::type +typename std::enable_if<(!std::is_same::value && !std::is_same::value) && + std::is_same>::value, + T>::type dot(const size_t n, const T *x, const K *y) { return detail::dot(n, y, x); } template -typename std::enable_if< - (!std::is_same::value && !std::is_same::value) && - std::is_same>::value, K>::type +typename std::enable_if<(!std::is_same::value && !std::is_same::value) && + std::is_same>::value, + K>::type dot(const size_t n, const K *x, const T *y) { return detail::dot(n, x, y); } template -typename std::enable_if< - (!std::is_same::value && !std::is_same::value) && - !std::is_same>::value, T>::type +typename std::enable_if<(!std::is_same::value && !std::is_same::value) && + !std::is_same>::value, + T>::type dot(const size_t n, const T *x, const K *y) { CHECK_BLAS_OPTIMIZATION_PP(x, y, "dot prod"); return detail::dot(n, x, y); } template -typename std::enable_if< - !(std::is_same::value || std::is_same::value) && - std::is_same>::value && !std::is_same>::value>::type +typename std::enable_if::value || std::is_same::value) && + std::is_same>::value && + !std::is_same>::value>::type mult_incr(const uint64_t n, const K alpha, const Y *x, T *y) { for (uint64_t i = 0; i < n; ++i) { K y_i = y[i].load(); @@ -93,9 +94,9 @@ mult_incr(const uint64_t n, const K alpha, const Y *x, T *y) { } template -typename std::enable_if< - !(std::is_same::value || std::is_same::value) && - std::is_same>::value && !std::is_same>::value>::type +typename std::enable_if::value || std::is_same::value) && + std::is_same>::value && + !std::is_same>::value>::type mult_incr(const uint64_t n, const K alpha, const Y *x, T *y) { for (uint64_t i = 0; i < n; ++i) { K y_i = y[i]; @@ -104,9 +105,9 @@ mult_incr(const uint64_t n, const K alpha, const Y *x, T *y) { } } template -typename std::enable_if< - !(std::is_same::value || std::is_same::value) && - std::is_same>::value && std::is_same>::value>::type +typename std::enable_if::value || std::is_same::value) && + std::is_same>::value && + std::is_same>::value>::type mult_incr(const uint64_t n, const K alpha, const Y *x, T *y) { for (uint64_t i = 0; i < n; ++i) { K y_i = y[i].load(); @@ -115,22 +116,20 @@ mult_incr(const uint64_t n, const K alpha, const Y *x, T *y) { } } template -typename std::enable_if< - !(std::is_same::value || std::is_same::value)>::type +typename std::enable_if::value || std::is_same::value)>::type mult_incr(const uint64_t n, const K alpha, const Y *x, T *y) { CHECK_BLAS_OPTIMIZATION_PP(x, y, "mult_incr"); return detail::mult_incr(n, alpha, x, y); } - template -typename std::enable_if>::value>::type -set(const size_t n, const K alpha, T *x) { +typename std::enable_if>::value>::type set(const size_t n, + const K alpha, T *x) { for (uint64_t i = 0; i < n; ++i) x[i].store(alpha); } template -typename std::enable_if>::value>::type -set(const size_t n, const K alpha, T *x) { +typename std::enable_if>::value>::type set(const size_t n, + const K alpha, T *x) { for (uint64_t i = 0; i < n; ++i) x[i] = alpha; } @@ -140,9 +139,8 @@ K sum(const size_t n, const T *x) { } template -typename std::enable_if< - !(std::is_same::value || std::is_same::value) && - std::is_same>::value>::type +typename std::enable_if::value || std::is_same::value) && + std::is_same>::value>::type scale(const size_t n, const K alpha, T *x) { for (uint64_t i = 0; i < n; ++i) { K x_i = x[i].load(); @@ -151,18 +149,16 @@ scale(const size_t n, const K alpha, T *x) { } } template -typename std::enable_if< - !(std::is_same::value || std::is_same::value) && - !std::is_same>::value>::type +typename std::enable_if::value || std::is_same::value) && + !std::is_same>::value>::type scale(const size_t n, const K alpha, T *x) { CHECK_BLAS_OPTIMIZATION_PS(x, alpha, "scale"); detail::scale(n, alpha, x); } template -typename std::enable_if>::value>::type -dot_matrix_vector_incr(const size_t m, const size_t n, const K alpha, const T *a, const T *x, - const T beta, T *y) { +typename std::enable_if>::value>::type dot_matrix_vector_incr( + const size_t m, const size_t n, const K alpha, const T *a, const T *x, const T beta, T *y) { for (size_t i = 0; i < m; ++i) { K y_i = beta * y[i]; for (size_t j = 0; j < n; ++j) y_i += alpha * a[i * n + j] * x[j].load(); @@ -171,10 +167,8 @@ dot_matrix_vector_incr(const size_t m, const size_t n, const K alpha, const T *a } template -typename std::enable_if>::value>::type -dot_matrix_vector_incr( - const size_t m, const size_t n, const K alpha, const T *a, const T *x, - const T beta, T *y) { +typename std::enable_if>::value>::type dot_matrix_vector_incr( + const size_t m, const size_t n, const K alpha, const T *a, const T *x, const T beta, T *y) { for (size_t i = 0; i < m; ++i) { y[i] = beta * y[i]; for (size_t j = 0; j < n; ++j) y[i] += alpha * a[i * n + j] * x[j]; @@ -182,8 +176,8 @@ dot_matrix_vector_incr( } template -typename std::enable_if>::value>::type -dot_matrix_vector(const size_t m, const size_t n, const K alpha, const T *a, const T *x, T *y) { +typename std::enable_if>::value>::type dot_matrix_vector( + const size_t m, const size_t n, const K alpha, const T *a, const T *x, T *y) { for (size_t i = 0; i < m; ++i) { K y_i = 0; for (size_t j = 0; j < n; ++j) y_i += alpha * a[i * n + j] * x[j].load(); @@ -192,8 +186,8 @@ dot_matrix_vector(const size_t m, const size_t n, const K alpha, const T *a, con } template -typename std::enable_if>::value>::type -dot_matrix_vector( const size_t m, const size_t n, const K alpha, const T *a, const T *x, T *y) { +typename std::enable_if>::value>::type dot_matrix_vector( + const size_t m, const size_t n, const K alpha, const T *a, const T *x, T *y) { for (size_t i = 0; i < m; ++i) { y[i] = 0; for (size_t j = 0; j < n; ++j) y[i] += alpha * a[i * n + j] * x[j]; diff --git a/inc/kul/os.hpp b/inc/kul/os.hpp index 70645b5..09617cd 100644 --- a/inc/kul/os.hpp +++ b/inc/kul/os.hpp @@ -33,8 +33,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include "kul/env.hpp" #include "kul/cpu.hpp" +#include "kul/env.hpp" #include "kul/except.hpp" #include "kul/string.hpp" @@ -78,7 +78,6 @@ class Item { }; } // namespace fs - class Dir : public fs::Item { private: std::string _p; @@ -292,8 +291,6 @@ inline std::ostream &operator<<(std::ostream &s, const File &d) { return s << d. } // namespace kul - - namespace kul { namespace os { @@ -330,11 +327,9 @@ inline std::string WHERE(const char *c) { return ""; } -inline bool WHICH(const char *c) { - return WHERE(c).size(); -} -} // namespace env -} // namespace kul +inline bool WHICH(const char *c) { return WHERE(c).size(); } +} // namespace env +} // namespace kul #if KUL_IS_WIN #include "kul/os/win/os.bot.hpp" diff --git a/inc/kul/os/bsd/proc.os.hpp b/inc/kul/os/bsd/proc.os.hpp index e787675..c09bd7b 100644 --- a/inc/kul/os/bsd/proc.os.hpp +++ b/inc/kul/os/bsd/proc.os.hpp @@ -44,7 +44,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #endif - namespace kul { namespace this_proc { class MemGetter { diff --git a/inc/kul/os/def.hpp b/inc/kul/os/def.hpp index 516dbf4..9ab62ba 100644 --- a/inc/kul/os/def.hpp +++ b/inc/kul/os/def.hpp @@ -31,7 +31,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef _KUL_OS_DEF_HPP_ #define _KUL_OS_DEF_HPP_ -#if KUL_IS_NIX +#if KUL_IS_NIX #include "kul/os/nix/def.hpp" #elif KUL_IS_BSD #include "kul/os/bsd/def.hpp" @@ -42,5 +42,3 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endif #endif // _KUL_OS_DEF_HPP_ - - diff --git a/inc/kul/os/nix/proc.os.hpp b/inc/kul/os/nix/proc.os.hpp index 2ca4e11..51579b4 100644 --- a/inc/kul/os/nix/proc.os.hpp +++ b/inc/kul/os/nix/proc.os.hpp @@ -40,7 +40,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include - namespace kul { namespace this_proc { @@ -77,8 +76,8 @@ inline uint16_t cpuLoad() { return 0; } #ifndef _KUL_COMPILED_LIB_ #include "kul/os/nix/src/proc//xparse_line.ipp" -#include "kul/os/nix/src/proc//xvirtual.ipp" #include "kul/os/nix/src/proc//xphysical.ipp" +#include "kul/os/nix/src/proc//xvirtual.ipp" #endif #endif /* _KUL_OS_NIX_PROC_OS_HPP_ */ diff --git a/inc/kul/os/nixish/env.hpp b/inc/kul/os/nixish/env.hpp index 540376d..c9da754 100644 --- a/inc/kul/os/nixish/env.hpp +++ b/inc/kul/os/nixish/env.hpp @@ -47,17 +47,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace kul { namespace env { -inline std::string EOL() { - return "\r\n"; -} +inline std::string EOL() { return "\r\n"; } -#if defined(_KUL_MAX_PATH_) +#if defined(_KUL_MAX_PATH_) constexpr size_t KUL_MAX_PATH = _KUL_MAX_PATH_; #elif defined(PATH_MAX) constexpr size_t KUL_MAX_PATH = PATH_MAX; #else -#error // could not set KUL_MAX_PATH -#endif /*_KUL_MAX_PATH_*/ +#error // could not set KUL_MAX_PATH +#endif /*_KUL_MAX_PATH_*/ inline bool EXISTS(const char *c) { return getenv(c); } inline std::string GET(const char *c) { diff --git a/inc/kul/os/nixish/os.bot.hpp b/inc/kul/os/nixish/os.bot.hpp index 1506d94..17dab08 100644 --- a/inc/kul/os/nixish/os.bot.hpp +++ b/inc/kul/os/nixish/os.bot.hpp @@ -62,11 +62,10 @@ bool kul::Dir::mk() const { } bool kul::Dir::root() const { return is() && real().size() == 1; } - bool kul::File::is() const { if (name().empty()) return false; struct stat buffer; - if(stat(_d.join(_n).c_str(), &buffer) == 0) return S_ISREG(buffer.st_mode); + if (stat(_d.join(_n).c_str(), &buffer) == 0) return S_ISREG(buffer.st_mode); return 0; } bool kul::File::rm() const { @@ -119,9 +118,9 @@ inline bool CWD(const kul::Dir &d) { return chdir(d.path().c_str()) != -1; } } // namespace kul #ifndef _KUL_COMPILED_LIB_ -#include "kul/os/nixish/src/os/dir/real.ipp" #include "kul/os/nixish/src/os/dir/dirs.ipp" #include "kul/os/nixish/src/os/dir/files.ipp" +#include "kul/os/nixish/src/os/dir/real.ipp" #endif //_KUL_COMPILED_LIB_ #endif /* _KUL_OS_NIXISH_OS_BOT_HPP_ */ diff --git a/inc/kul/os/nixish/proc.hpp b/inc/kul/os/nixish/proc.hpp index 3292b07..bd881f0 100644 --- a/inc/kul/os/nixish/proc.hpp +++ b/inc/kul/os/nixish/proc.hpp @@ -31,15 +31,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef _KUL_OS_NIXISH_PROC_HPP_ #define _KUL_OS_NIXISH_PROC_HPP_ -#include #include -#include +#include #include +#include -#include "kul/os.hpp" #include "kul/log.hpp" +#include "kul/os.hpp" -#if KUL_IS_NIX +#if KUL_IS_NIX #include "kul/os/nix/proc.os.hpp" #elif KUL_IS_BSD #include "kul/os/bsd/proc.os.hpp" @@ -47,7 +47,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #error unresolved #endif - #ifndef __KUL_PROC_DUP_RETRY__ #define __KUL_PROC_DUP_RETRY__ 3 #endif //__KUL_PROC_DUP_RETRY__ @@ -99,14 +98,13 @@ class Process : public kul::AProcess { }; } // namespace kul - #ifndef _KUL_COMPILED_LIB_ #include "kul/os/nixish/src/proc/child.ipp" #include "kul/os/nixish/src/proc/expand.ipp" -#include "kul/os/nixish/src/proc/waitForStatus.ipp" -#include "kul/os/nixish/src/proc/waitExit.ipp" -#include "kul/os/nixish/src/proc/tearDown.ipp" #include "kul/os/nixish/src/proc/run.ipp" +#include "kul/os/nixish/src/proc/tearDown.ipp" +#include "kul/os/nixish/src/proc/waitExit.ipp" +#include "kul/os/nixish/src/proc/waitForStatus.ipp" #endif #endif /* _KUL_OS_NIXISH_PROC_HPP_ */ diff --git a/inc/kul/os/nixish/signal.hpp b/inc/kul/os/nixish/signal.hpp index 916bb72..a6eaa73 100644 --- a/inc/kul/os/nixish/signal.hpp +++ b/inc/kul/os/nixish/signal.hpp @@ -39,11 +39,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include +#include +#include #include #include -#include -#include - #ifndef __USE_GNU #define __USE_GNU @@ -69,14 +68,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. inline void kul_sig_handler(int s, siginfo_t *info, void *v); namespace kul { -namespace this_thread{ +namespace this_thread { #include "kul/os/nixish/src/signal/stacktrace.ipp" -void print_stacktrace(){ - for(auto const& s : stacktrace()) std::cout << s << std::endl; -} +void print_stacktrace() { + for (auto const &s : stacktrace()) std::cout << s << std::endl; } - +} // namespace this_thread class Signal; class SignalStatic { diff --git a/inc/kul/os/nixish/sys.hpp b/inc/kul/os/nixish/sys.hpp index d5a38f3..f9fe313 100644 --- a/inc/kul/os/nixish/sys.hpp +++ b/inc/kul/os/nixish/sys.hpp @@ -75,7 +75,7 @@ class SharedFunction { SharedLibrary &_lib; public: - SharedFunction(SharedLibrary &lib, std::string const& f) KTHROW(Exception) : _lib(lib) { + SharedFunction(SharedLibrary &lib, std::string const &f) KTHROW(Exception) : _lib(lib) { _funcP = (F *)dlsym(_lib._handle, f.c_str()); const char *dlsym_error = dlerror(); if (dlsym_error) KEXCEPSTREAM << "Cannot load symbol create " << dlsym_error; diff --git a/inc/kul/os/nixish/threads.os.hpp b/inc/kul/os/nixish/threads.os.hpp index 4ff0de2..16f7969 100644 --- a/inc/kul/os/nixish/threads.os.hpp +++ b/inc/kul/os/nixish/threads.os.hpp @@ -31,8 +31,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef _KUL_OS_NIXISH_THREADS_OS_HPP_ #define _KUL_OS_NIXISH_THREADS_OS_HPP_ - - #include #include #include diff --git a/inc/kul/os/threads.hpp b/inc/kul/os/threads.hpp index 0181de4..3fef7e6 100644 --- a/inc/kul/os/threads.hpp +++ b/inc/kul/os/threads.hpp @@ -92,7 +92,6 @@ class AThread { } // namespace threading } // namespace kul - #if defined(_WIN32) #include "kul/os/win/threads.os.hpp" #else diff --git a/inc/kul/os/win/env.hpp b/inc/kul/os/win/env.hpp index abd84d6..83af23c 100644 --- a/inc/kul/os/win/env.hpp +++ b/inc/kul/os/win/env.hpp @@ -42,17 +42,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include - namespace kul { namespace env { -#if defined(_KUL_MAX_PATH_) +#if defined(_KUL_MAX_PATH_) constexpr size_t KUL_MAX_PATH = _KUL_MAX_PATH_; #elif defined(_MAX_PATH) constexpr size_t KUL_MAX_PATH = _MAX_PATH; #else -#error // could not set KUL_MAX_PATH -#endif /*_KUL_MAX_PATH_*/ +#error // could not set KUL_MAX_PATH +#endif /*_KUL_MAX_PATH_*/ inline std::string EOL() { #if (_MSC_VER >= 1800) @@ -89,7 +88,6 @@ inline void SET(const char *var, const char *val) { inline char SEP() { return ';'; } - inline std::string CWD() { char c[KUL_MAX_PATH]; _getcwd(c, KUL_MAX_PATH); diff --git a/inc/kul/os/win/os.bot.hpp b/inc/kul/os/win/os.bot.hpp index 382a162..0bd4bab 100644 --- a/inc/kul/os/win/os.bot.hpp +++ b/inc/kul/os/win/os.bot.hpp @@ -44,7 +44,6 @@ std::string kul::Dir::ESC(std::string s) { return s; } - std::string kul::Dir::LOCL(std::string s) { kul::String::REPLACE_ALL(s, "/", "\\"); return s; @@ -63,7 +62,6 @@ bool kul::Dir::mk() const { } bool kul::Dir::root() const { return is() && real().size() == 3; } - bool kul::File::is() const { return !name().empty() && (bool)std::ifstream(_d.join(_n).c_str()); } bool kul::File::rm() const { if (is()) { @@ -110,7 +108,7 @@ inline std::string EOL() { return "\n"; #else return "\r\n"; -#endif // _MSC_VER +#endif // _MSC_VER } } // namespace os @@ -126,16 +124,15 @@ inline kul::Dir home(const std::string &app) { return kul::Dir(home().join(app)) } // namespace user - namespace env { inline bool CWD(const kul::Dir &d) { return _chdir(d.path().c_str()) != -1; } } // namespace env } // namespace kul #ifndef _KUL_COMPILED_LIB_ -#include "kul/os/win/src/os/dir/real.ipp" #include "kul/os/win/src/os/dir/dirs.ipp" #include "kul/os/win/src/os/dir/files.ipp" +#include "kul/os/win/src/os/dir/real.ipp" #endif //_KUL_COMPILED_LIB_ #endif /* _KUL_OS_WIN_OS_BOT_HPP_ */ diff --git a/inc/kul/os/win/proc.hpp b/inc/kul/os/win/proc.hpp index 03e285d..5065a21 100644 --- a/inc/kul/os/win/proc.hpp +++ b/inc/kul/os/win/proc.hpp @@ -44,7 +44,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "kul/os.hpp" #include "kul/string.hpp" - // extern char **environ; namespace kul { diff --git a/inc/kul/os/win/signal.hpp b/inc/kul/os/win/signal.hpp index 21f1156..3c3d3ff 100644 --- a/inc/kul/os/win/signal.hpp +++ b/inc/kul/os/win/signal.hpp @@ -65,16 +65,16 @@ BOOL WINAPI kul_sigint_function(DWORD d) { } namespace kul { -namespace this_thread{ -std::vector stacktrace(){ -// #include "kul/os/win/src/signal/stacktrace.ipp" +namespace this_thread { +std::vector stacktrace() { + // #include "kul/os/win/src/signal/stacktrace.ipp" return std::vector{}; } -void print_stacktrace(){ - for(auto const& s : stacktrace()) std::cout << s << std::endl; -} +void print_stacktrace() { + for (auto const &s : stacktrace()) std::cout << s << std::endl; } +} // namespace this_thread class Signal; diff --git a/inc/kul/os/win/src/proc/run.cpp b/inc/kul/os/win/src/proc/run.cpp index 320732a..7bcebbd 100644 --- a/inc/kul/os/win/src/proc/run.cpp +++ b/inc/kul/os/win/src/proc/run.cpp @@ -34,7 +34,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // void kul::Process::run() KTHROW(kul::proc::Exception){ - SECURITY_ATTRIBUTES sa; ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES)); // Set the bInheritHandle flag so pipe handles are inherited. @@ -136,8 +135,8 @@ if (vars().size()) { newEnv.push_back('\0'); } // may not work - bSuccess = CreateProcess(NULL, szCmdline, NULL, NULL, TRUE, flags, (LPVOID) newEnv.c_str(), dir, &siStartInfo, - &piProcInfo); + bSuccess = CreateProcess(NULL, szCmdline, NULL, NULL, TRUE, flags, (LPVOID)newEnv.c_str(), dir, + &siStartInfo, &piProcInfo); } else bSuccess = CreateProcess(NULL, szCmdline, NULL, NULL, TRUE, flags, NULL, dir, &siStartInfo, &piProcInfo); @@ -206,5 +205,4 @@ if (this->waitForExit()) { CloseHandle(piProcInfo.hThread); CloseHandle(piProcInfo.hProcess); - // } \ No newline at end of file diff --git a/inc/kul/os/win/threads.os.hpp b/inc/kul/os/win/threads.os.hpp index 0dc0e24..260ad5c 100644 --- a/inc/kul/os/win/threads.os.hpp +++ b/inc/kul/os/win/threads.os.hpp @@ -87,9 +87,11 @@ class Thread : public threading::AThread { template Thread(const T &t) : func(std::bind((void (T::*)()) & T::operator(), t)) {} template - Thread(const std::reference_wrapper &r) : func(std::bind((void (T::*)()) & T::operator(), r)) {} + Thread(const std::reference_wrapper &r) + : func(std::bind((void (T::*)()) & T::operator(), r)) {} template - Thread(const std::reference_wrapper &r) : func(std::bind((void (T::*)() const) & T::operator(), r)) {} + Thread(const std::reference_wrapper &r) + : func(std::bind((void (T::*)() const) & T::operator(), r)) {} virtual ~Thread() {} void join() { if (!s) run(); diff --git a/inc/kul/proc.hpp b/inc/kul/proc.hpp index 4f737d6..14297f2 100644 --- a/inc/kul/proc.hpp +++ b/inc/kul/proc.hpp @@ -171,8 +171,8 @@ class AProcess { evs[n] = v; return *this; } - AProcess &set(std::vector const& in) { - for(auto const& ev: in) evs[ev.name()] = ev.toString(); + AProcess &set(std::vector const &in) { + for (auto const &ev : in) evs[ev.name()] = ev.toString(); return *this; } @@ -215,13 +215,11 @@ class ProcessCapture { }; } // namespace kul - #ifndef _KUL_COMPILED_LIB_ #include "kul/src/proc.base/start.ipp" #include "kul/src/proc.base/toString.ipp" #endif - #if defined(_WIN32) #include "kul/os/win/proc.hpp" #else diff --git a/inc/kul/scm.hpp b/inc/kul/scm.hpp index b093c32..d3d60bd 100644 --- a/inc/kul/scm.hpp +++ b/inc/kul/scm.hpp @@ -170,7 +170,7 @@ class Git : public SCM { kul::Process p("git", d); try { p << "status"; - if(!full) p << "--short"; + if (!full) p << "--short"; p.start(); } catch (const kul::proc::ExitException &e) { KEXCEPT(Exception, "SCM ERROR " + std::string(e.what())); @@ -189,48 +189,42 @@ class Git : public SCM { /* class Svn : public SCM { public: - const std::string co(const std::string &d, const std::string &r, const std::string &v) const - KTHROW(Exception) { - Dir dr(d, true); - kul::Process p("svn", d); - p.arg("checkout").arg(kul::env::GET("KUL_SVN_CO")); - if (v.empty()) - p.arg(r); + const std::string co(const std::string &d, const std::string &r, const +std::string &v) const KTHROW(Exception) { Dir dr(d, true); kul::Process p("svn", +d); p.arg("checkout").arg(kul::env::GET("KUL_SVN_CO")); if (v.empty()) p.arg(r); else p.arg(r + "/" + v); try { p.arg(".").start(); } catch (const kul::proc::ExitException &e) { dr.rm(); - KEXCEPT(Exception, "SCM ERROR - Check remote dependency location / version"); + KEXCEPT(Exception, "SCM ERROR - Check remote dependency location / +version"); } return p.toString(); } - void up(const std::string &d, const std::string &r, const std::string &v) const - KTHROW(Exception) { - if (!Dir(d).is()) - co(d, r, v); - else - KEXCEPT(Exception, "SCM ERROR - SVN NOT IMPLEMENTED"); + void up(const std::string &d, const std::string &r, const std::string &v) +const KTHROW(Exception) { if (!Dir(d).is()) co(d, r, v); else KEXCEPT(Exception, +"SCM ERROR - SVN NOT IMPLEMENTED"); } // svn info . | lines | split | ifeq "Repository Root" go | // http://svnbook.red-bean.com/en/1.6/svn.ref.svn.c.info.html const std::string origin(const std::string &d) const { KEXCEPT(Exception, "SCM ERROR - SVN NOT IMPLEMENTED"); } - const std::string localVersion(const std::string &d, const std::string &b) const { - KEXCEPT(Exception, "SCM ERROR - SVN NOT IMPLEMENTED"); + const std::string localVersion(const std::string &d, const std::string &b) +const { KEXCEPT(Exception, "SCM ERROR - SVN NOT IMPLEMENTED"); } - const std::string remoteVersion(const std::string &url, const std::string &b) const - KTHROW(Exception) { - KEXCEPT(Exception, "SCM ERROR - SVN NOT IMPLEMENTED"); + const std::string remoteVersion(const std::string &url, const std::string &b) +const KTHROW(Exception) { KEXCEPT(Exception, "SCM ERROR - SVN NOT IMPLEMENTED"); } bool hasChanges(const std::string &d) const { KEXCEPT(Exception, "SCM ERROR - SVN NOT IMPLEMENTED"); } - void status(const std::string &d, bool full) const { KEXCEPT(Exception, "SCM ERROR - SVN NOT IMPLEMENTED"); } - void diff(const std::string &d) const { KEXCEPT(Exception, "SCM ERROR - SVN NOT IMPLEMENTED"); } + void status(const std::string &d, bool full) const { KEXCEPT(Exception, "SCM +ERROR - SVN NOT IMPLEMENTED"); } void diff(const std::string &d) const { +KEXCEPT(Exception, "SCM ERROR - SVN NOT IMPLEMENTED"); } }; */ diff --git a/inc/kul/string.hpp b/inc/kul/string.hpp index 8ea4987..bc61ff9 100644 --- a/inc/kul/string.hpp +++ b/inc/kul/string.hpp @@ -31,13 +31,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef _KUL_STRING_HPP_ #define _KUL_STRING_HPP_ -#include -#include -#include #include -#include #include +#include +#include +#include #include +#include #include "kul/except.hpp" diff --git a/inc/kul/threads.base.hpp b/inc/kul/threads.base.hpp index ec84394..de69d50 100644 --- a/inc/kul/threads.base.hpp +++ b/inc/kul/threads.base.hpp @@ -60,11 +60,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // namespace threading { // class Exception : public kul::Exception { // public: -// Exception(const char *f, const uint16_t &l, const std::string &s) : kul::Exception(f, l, s) {} +// Exception(const char *f, const uint16_t &l, const std::string &s) : +// kul::Exception(f, l, s) {} // }; // class InterruptionException : public Exception { // public: -// InterruptionException(const char *f, const uint16_t &l, const std::string &s) +// InterruptionException(const char *f, const uint16_t &l, const std::string +// &s) // : Exception(f, l, s) {} // }; diff --git a/inc/kul/tuple.hpp b/inc/kul/tuple.hpp index a5a76b1..900c193 100644 --- a/inc/kul/tuple.hpp +++ b/inc/kul/tuple.hpp @@ -35,59 +35,57 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace kul { -template +template struct Pointer { static constexpr size_t INDEX = N; - T* p = nullptr; + T* p = nullptr; }; -template +template struct Pointers { - Pointers(T const * p_, SIZE s_) : p{p_}, s{s_}{} - T const * p = nullptr; - SIZE s = 0; + Pointers(T const* p_, SIZE s_) : p{p_}, s{s_} {} + T const* p = nullptr; + SIZE s = 0; auto& operator[](SIZE i) const { return p[i]; } auto& begin() const { return p; } - auto end() const { return p + s; } - auto& size() const { return s; } + auto end() const { return p + s; } + auto& size() const { return s; } }; -template +template struct PointersApply { - PointersApply(Tuple& t) : tuple{t}{} - - template - decltype(auto) operator()() - { - auto t = std::get(tuple); - using T = decltype(t); - if constexpr (std::is_pointer::value) - return Pointer>>{t}; - else - return Pointer>{&t}; + PointersApply(Tuple& t) : tuple{t} {} + + template + decltype(auto) operator()() { + auto t = std::get(tuple); + using T = decltype(t); + if constexpr (std::is_pointer::value) + return Pointer>>{t}; + else + return Pointer>{&t}; } Tuple& tuple; }; -template -struct PointerContainer : public Pointer...{ - PointerContainer(Pointer&... args) : Pointer(std::forward(args))...{} +template +struct PointerContainer : public Pointer... { + PointerContainer(Pointer&... args) : Pointer(std::forward(args))... {} }; -template -decltype(auto) _make_pointer_container(std::tuple&& t){ - return std::make_from_tuple>(t); +template +decltype(auto) _make_pointer_container(std::tuple&& t) { + return std::make_from_tuple>(t); } -template -decltype(auto) make_pointer_container(Refs&&... args){ +template +decltype(auto) make_pointer_container(Refs&&... args) { auto tuple = std::forward_as_tuple(args...); constexpr size_t size = std::tuple_size::value; return _make_pointer_container(for_N(PointersApply{tuple})); } - } // namespace kul #endif /* _KUL_TUPLE_HPP_ */ diff --git a/inc/kul/yaml.hpp b/inc/kul/yaml.hpp index aa529d4..028bc3a 100644 --- a/inc/kul/yaml.hpp +++ b/inc/kul/yaml.hpp @@ -81,7 +81,7 @@ class Item { friend class Validator; protected: - YAML::Node r; // root + YAML::Node r; // root Item() {} Item(const YAML::Node &r) : r(r) {} @@ -177,8 +177,7 @@ class File : public Item { File(const std::string &f) KTHROW(Exception) : f(f) { reload(); } private: - const std::string f; // file - + const std::string f; // file }; } // namespace yaml } // namespace kul diff --git a/mkn.yaml b/mkn.yaml index 3bb123d..fd67a39 100644 --- a/mkn.yaml +++ b/mkn.yaml @@ -45,9 +45,5 @@ profile: main: usage.cpp - name: format - mod: - - name: clang.format - init: - style: file - types: cpp:cxx:cc:h:hpp - paths: . + mod: | + clang.format{init{style: file, paths: .}} diff --git a/src/os/nix/proc.os.cpp b/src/os/nix/proc.os.cpp index bb8b3d0..4c515cc 100644 --- a/src/os/nix/proc.os.cpp +++ b/src/os/nix/proc.os.cpp @@ -31,5 +31,5 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "kul/proc.hpp" #include "kul/os/nix/src/proc/xparse_line.ipp" -#include "kul/os/nix/src/proc/xvirtual.ipp" #include "kul/os/nix/src/proc/xphysical.ipp" +#include "kul/os/nix/src/proc/xvirtual.ipp" diff --git a/src/os/nixish/cli.os.cpp b/src/os/nixish/cli.os.cpp index 9e2c896..e480393 100644 --- a/src/os/nixish/cli.os.cpp +++ b/src/os/nixish/cli.os.cpp @@ -28,8 +28,8 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "kul/cli.hpp" #include +#include "kul/cli.hpp" std::string kul::cli::hidden(const std::string &t) { #include "kul/os/nixish/src/cli/hidden.ipp" diff --git a/src/os/nixish/os.cpp b/src/os/nixish/os.cpp index 4eb5167..50bed9e 100644 --- a/src/os/nixish/os.cpp +++ b/src/os/nixish/os.cpp @@ -30,11 +30,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "kul/os.hpp" -// std::vector kul::Dir::dirs(bool incHidden) const KTHROW(kul::fs::Exception){ +// std::vector kul::Dir::dirs(bool incHidden) const +// KTHROW(kul::fs::Exception){ #include "kul/os/nixish/src/os/dir/dirs.ipp" // } -// std::vector kul::Dir::files(bool recursive) const KTHROW(kul::fs::Exception){ +// std::vector kul::Dir::files(bool recursive) const +// KTHROW(kul::fs::Exception){ #include "kul/os/nixish/src/os/dir/files.ipp" // } diff --git a/src/os/win/os.cpp b/src/os/win/os.cpp index 4a13da1..f9af52f 100644 --- a/src/os/win/os.cpp +++ b/src/os/win/os.cpp @@ -30,11 +30,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "kul/os.hpp" -// std::vector kul::Dir::dirs(bool incHidden) const KTHROW(kul::fs::Exception){ +// std::vector kul::Dir::dirs(bool incHidden) const +// KTHROW(kul::fs::Exception){ #include "kul/os/win/src/os/dir/dirs.ipp" // } -// std::vector kul::Dir::files(bool recursive) const KTHROW(kul::fs::Exception){ +// std::vector kul::Dir::files(bool recursive) const +// KTHROW(kul::fs::Exception){ #include "kul/os/win/src/os/dir/files.ipp" // } diff --git a/test.cpp b/test.cpp index 99a79c1..ab6611f 100644 --- a/test.cpp +++ b/test.cpp @@ -56,11 +56,11 @@ auto tryCatch = [](std::vector> funcs, bool katch) { }; #include "test/cli.ipp" +#include "test/except.ipp" #include "test/io.ipp" #include "test/math.ipp" #include "test/os.ipp" #include "test/proc.ipp" -#include "test/except.ipp" #include "test/string.ipp" int main(int argc, char *argv[]) { diff --git a/usage.cpp b/usage.cpp index f40e0ee..bab314f 100644 --- a/usage.cpp +++ b/usage.cpp @@ -30,23 +30,22 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #define KUL_FORCE_TRACE - #include -#include "kul/io.hpp" -#include "kul/dbg.hpp" +#include "kul/asio/log.hpp" +#include "kul/assert.hpp" #include "kul/cli.hpp" +#include "kul/dbg.hpp" +#include "kul/io.hpp" #include "kul/ipc.hpp" #include "kul/log.hpp" #include "kul/math.hpp" #include "kul/os.hpp" #include "kul/proc.hpp" -#include "kul/assert.hpp" #include "kul/signal.hpp" #include "kul/string.hpp" #include "kul/threads.hpp" #include "kul/time.hpp" #include "kul/wstring.hpp" -#include "kul/asio/log.hpp" namespace kul { @@ -158,7 +157,7 @@ class Test { // before exiting - // CAUTION! KEEP // SIMPLE! - // Allows lamda notation + // Allows lamda notation sig.segv([this](int16_t) { KOUT(NON) << s; }); KERR << "KERR"; // KOUT/KLOG are controlled via env/var KLOG