From ae3d01dec3207e712aafafe6d4bff42885e081b2 Mon Sep 17 00:00:00 2001 From: dekken Date: Sun, 17 Oct 2021 17:12:44 +0200 Subject: [PATCH] kul -> mkn::kul --- .github/workflows/build_nix.yml | 13 +- .github/workflows/build_osx.yml | 13 +- .github/workflows/build_win.yml | 9 +- .travis.yml | 2 +- README.noformat | 28 ++- inc/{ => mkn}/kul/all.hpp | 8 +- inc/{ => mkn}/kul/asio/log.hpp | 58 +++--- inc/{ => mkn}/kul/assert.hpp | 16 +- inc/{ => mkn}/kul/bon.hpp | 24 ++- inc/{ => mkn}/kul/byte.hpp | 8 +- inc/{ => mkn}/kul/cli.hpp | 44 ++-- inc/{ => mkn}/kul/cpu.hpp | 14 +- inc/{ => mkn}/kul/dbg.hpp | 28 +-- inc/{ => mkn}/kul/decltype.hpp | 8 +- inc/{ => mkn}/kul/defs.hpp | 8 +- inc/{ => mkn}/kul/env.hpp | 22 +- inc/{ => mkn}/kul/except.hpp | 19 +- inc/{ => mkn}/kul/for.hpp | 8 +- inc/{ => mkn}/kul/hash.hpp | 8 +- inc/{ => mkn}/kul/io.hpp | 22 +- inc/{ => mkn}/kul/ipc.hpp | 12 +- inc/{ => mkn}/kul/log.hpp | 105 +++++----- inc/{ => mkn}/kul/map.hpp | 10 +- inc/{ => mkn}/kul/math.hpp | 26 +-- inc/{ => mkn}/kul/math/blas.hpp | 2 + inc/{ => mkn}/kul/math/noblas.hpp | 2 + inc/{ => mkn}/kul/math/noop.hpp | 8 +- inc/{ => mkn}/kul/os.hpp | 66 +++--- inc/{ => mkn}/kul/os/bsd/cpu.hpp | 10 +- inc/{ => mkn}/kul/os/bsd/def.hpp | 22 +- inc/{ => mkn}/kul/os/bsd/proc.os.hpp | 10 +- inc/{ => mkn}/kul/os/cli.hpp | 14 +- inc/{ => mkn}/kul/os/def.hpp | 14 +- inc/{ => mkn}/kul/os/nix/cpu.hpp | 10 +- inc/{ => mkn}/kul/os/nix/def.hpp | 22 +- inc/{ => mkn}/kul/os/nix/proc.os.hpp | 18 +- .../kul/os/nix/src/proc/xparse_line.ipp | 4 +- .../kul/os/nix/src/proc/xphysical.ipp | 4 +- .../kul/os/nix/src/proc/xvirtual.ipp | 4 +- inc/{ => mkn}/kul/os/nixish/cli.os.hpp | 14 +- inc/{ => mkn}/kul/os/nixish/env.hpp | 16 +- inc/{ => mkn}/kul/os/nixish/ipc.hpp | 40 ++-- inc/{ => mkn}/kul/os/nixish/os.bot.hpp | 50 ++--- inc/{ => mkn}/kul/os/nixish/os.top.hpp | 12 +- inc/{ => mkn}/kul/os/nixish/proc.hpp | 56 +++--- inc/{ => mkn}/kul/os/nixish/signal.hpp | 36 ++-- .../kul/os/nixish/src/cli/hidden.ipp | 4 +- inc/{ => mkn}/kul/os/nixish/src/cli/show.ipp | 4 +- .../kul/os/nixish/src/os/dir/dirs.ipp | 6 +- .../kul/os/nixish/src/os/dir/files.ipp | 10 +- .../kul/os/nixish/src/os/dir/real.ipp | 4 +- .../kul/os/nixish/src/proc/child.ipp | 6 +- .../kul/os/nixish/src/proc/expand.ipp | 12 +- inc/{ => mkn}/kul/os/nixish/src/proc/run.ipp | 14 +- .../kul/os/nixish/src/proc/tearDown.ipp | 4 +- .../kul/os/nixish/src/proc/waitExit.ipp | 4 +- .../kul/os/nixish/src/proc/waitForStatus.ipp | 4 +- .../kul/os/nixish/src/signal/handler.ipp | 16 +- .../kul/os/nixish/src/signal/stacktrace.ipp | 10 +- inc/{ => mkn}/kul/os/nixish/sys.hpp | 28 +-- inc/{ => mkn}/kul/os/nixish/threads.os.hpp | 14 +- inc/{ => mkn}/kul/os/threads.hpp | 29 +-- inc/{ => mkn}/kul/os/win/cli.os.hpp | 14 +- inc/{ => mkn}/kul/os/win/cpu.hpp | 8 +- inc/{ => mkn}/kul/os/win/def.hpp | 38 ++-- inc/{ => mkn}/kul/os/win/env.hpp | 14 +- inc/{ => mkn}/kul/os/win/ipc.hpp | 40 ++-- inc/{ => mkn}/kul/os/win/os.bot.hpp | 52 ++--- inc/{ => mkn}/kul/os/win/os.top.hpp | 12 +- inc/{ => mkn}/kul/os/win/proc.hpp | 40 ++-- inc/{ => mkn}/kul/os/win/signal.hpp | 28 +-- inc/{ => mkn}/kul/os/win/src/cli/hidden.cpp | 2 +- inc/{ => mkn}/kul/os/win/src/cli/show.cpp | 2 +- inc/{ => mkn}/kul/os/win/src/os/dir/dirs.ipp | 4 +- inc/{ => mkn}/kul/os/win/src/os/dir/files.ipp | 4 +- inc/{ => mkn}/kul/os/win/src/os/dir/real.ipp | 2 +- inc/{ => mkn}/kul/os/win/src/proc/expand.cpp | 10 +- inc/{ => mkn}/kul/os/win/src/proc/run.cpp | 18 +- .../kul/os/win/src/proc/tearDown.cpp | 2 +- .../kul/os/win/src/signal/se_handler.cpp | 4 +- inc/{ => mkn}/kul/os/win/src/thread/main.cpp | 4 +- inc/{ => mkn}/kul/os/win/sys.hpp | 19 +- inc/{ => mkn}/kul/os/win/threads.os.hpp | 14 +- inc/{ => mkn}/kul/proc.hpp | 64 +++--- inc/{ => mkn}/kul/scm.hpp | 112 ++++++----- inc/{ => mkn}/kul/scm/man.hpp | 10 +- inc/{ => mkn}/kul/serial.hpp | 6 +- inc/{ => mkn}/kul/serial/cli.arg.end.hpp | 16 +- inc/{ => mkn}/kul/serial/cli.bottom.hpp | 8 +- inc/{ => mkn}/kul/signal.hpp | 12 +- inc/{ => mkn}/kul/span.hpp | 10 +- inc/{ => mkn}/kul/src/cli/asArgs.ipp | 4 +- inc/{ => mkn}/kul/src/proc.base/start.ipp | 10 +- inc/{ => mkn}/kul/src/proc.base/toString.ipp | 4 +- inc/{ => mkn}/kul/string.hpp | 14 +- inc/{ => mkn}/kul/sys.hpp | 18 +- inc/{ => mkn}/kul/threads.hpp | 94 ++++----- inc/{ => mkn}/kul/time.hpp | 16 +- inc/{ => mkn}/kul/tuple.hpp | 10 +- inc/{ => mkn}/kul/wstring.hpp | 8 +- inc/{ => mkn}/kul/yaml.hpp | 24 ++- mkn.yaml | 2 +- src/all/asArgs.cpp | 4 +- src/all/proc.base.cpp | 6 +- src/os/nix/proc.os.cpp | 8 +- src/os/nixish/cli.os.cpp | 6 +- src/os/nixish/os.cpp | 8 +- src/os/nixish/proc.cpp | 14 +- src/os/nixish/signal.cpp | 4 +- src/os/win/cli.os.cpp | 10 +- src/os/win/os.cpp | 18 +- src/os/win/proc.cpp | 14 +- src/os/win/signal.cpp | 4 +- src/os/win/thread.os.cpp | 6 +- test/bench.cpp | 22 +- test/test.cpp | 22 +- test/test/cli.ipp | 2 +- test/test/except.ipp | 2 +- test/test/io.ipp | 12 +- test/test/math.ipp | 14 +- test/test/os.ipp | 10 +- test/test/proc.ipp | 8 +- test/test/span.ipp | 10 +- test/test/string.ipp | 66 +++--- test/usage.cpp | 189 +++++++++--------- 125 files changed, 1230 insertions(+), 1118 deletions(-) rename inc/{ => mkn}/kul/all.hpp (97%) rename inc/{ => mkn}/kul/asio/log.hpp (63%) rename inc/{ => mkn}/kul/assert.hpp (85%) rename inc/{ => mkn}/kul/bon.hpp (90%) rename inc/{ => mkn}/kul/byte.hpp (96%) rename inc/{ => mkn}/kul/cli.hpp (91%) rename inc/{ => mkn}/kul/cpu.hpp (88%) rename inc/{ => mkn}/kul/dbg.hpp (81%) rename inc/{ => mkn}/kul/decltype.hpp (92%) rename inc/{ => mkn}/kul/defs.hpp (95%) rename inc/{ => mkn}/kul/env.hpp (85%) rename inc/{ => mkn}/kul/except.hpp (94%) rename inc/{ => mkn}/kul/for.hpp (95%) rename inc/{ => mkn}/kul/hash.hpp (94%) rename inc/{ => mkn}/kul/io.hpp (94%) rename inc/{ => mkn}/kul/ipc.hpp (89%) rename inc/{ => mkn}/kul/log.hpp (69%) rename inc/{ => mkn}/kul/map.hpp (98%) rename inc/{ => mkn}/kul/math.hpp (84%) rename inc/{ => mkn}/kul/math/blas.hpp (98%) rename inc/{ => mkn}/kul/math/noblas.hpp (97%) rename inc/{ => mkn}/kul/math/noop.hpp (96%) rename inc/{ => mkn}/kul/os.hpp (87%) rename inc/{ => mkn}/kul/os/bsd/cpu.hpp (92%) rename inc/{ => mkn}/kul/os/bsd/def.hpp (83%) rename inc/{ => mkn}/kul/os/bsd/proc.os.hpp (93%) rename inc/{ => mkn}/kul/os/cli.hpp (86%) rename inc/{ => mkn}/kul/os/def.hpp (86%) rename inc/{ => mkn}/kul/os/nix/cpu.hpp (90%) rename inc/{ => mkn}/kul/os/nix/def.hpp (79%) rename inc/{ => mkn}/kul/os/nix/proc.os.hpp (86%) rename inc/{ => mkn}/kul/os/nix/src/proc/xparse_line.ipp (93%) rename inc/{ => mkn}/kul/os/nix/src/proc/xphysical.ipp (93%) rename inc/{ => mkn}/kul/os/nix/src/proc/xvirtual.ipp (93%) rename inc/{ => mkn}/kul/os/nixish/cli.os.hpp (85%) rename inc/{ => mkn}/kul/os/nixish/env.hpp (88%) rename inc/{ => mkn}/kul/os/nixish/ipc.hpp (78%) rename inc/{ => mkn}/kul/os/nixish/os.bot.hpp (70%) rename inc/{ => mkn}/kul/os/nixish/os.top.hpp (89%) rename inc/{ => mkn}/kul/os/nixish/proc.hpp (65%) rename inc/{ => mkn}/kul/os/nixish/signal.hpp (80%) rename inc/{ => mkn}/kul/os/nixish/src/cli/hidden.ipp (94%) rename inc/{ => mkn}/kul/os/nixish/src/cli/show.ipp (95%) rename inc/{ => mkn}/kul/os/nixish/src/os/dir/dirs.ipp (90%) rename inc/{ => mkn}/kul/os/nixish/src/os/dir/files.ipp (84%) rename inc/{ => mkn}/kul/os/nixish/src/os/dir/real.ipp (93%) rename inc/{ => mkn}/kul/os/nixish/src/proc/child.ipp (91%) rename inc/{ => mkn}/kul/os/nixish/src/proc/expand.ipp (87%) rename inc/{ => mkn}/kul/os/nixish/src/proc/run.ipp (92%) rename inc/{ => mkn}/kul/os/nixish/src/proc/tearDown.ipp (95%) rename inc/{ => mkn}/kul/os/nixish/src/proc/waitExit.ipp (92%) rename inc/{ => mkn}/kul/os/nixish/src/proc/waitForStatus.ipp (94%) rename inc/{ => mkn}/kul/os/nixish/src/signal/handler.ipp (76%) rename inc/{ => mkn}/kul/os/nixish/src/signal/stacktrace.ipp (95%) rename inc/{ => mkn}/kul/os/nixish/sys.hpp (83%) rename inc/{ => mkn}/kul/os/nixish/threads.os.hpp (91%) rename inc/{ => mkn}/kul/os/threads.hpp (83%) rename inc/{ => mkn}/kul/os/win/cli.os.hpp (87%) rename inc/{ => mkn}/kul/os/win/cpu.hpp (92%) rename inc/{ => mkn}/kul/os/win/def.hpp (74%) rename inc/{ => mkn}/kul/os/win/env.hpp (91%) rename inc/{ => mkn}/kul/os/win/ipc.hpp (82%) rename inc/{ => mkn}/kul/os/win/os.bot.hpp (69%) rename inc/{ => mkn}/kul/os/win/os.top.hpp (92%) rename inc/{ => mkn}/kul/os/win/proc.hpp (79%) rename inc/{ => mkn}/kul/os/win/signal.hpp (85%) rename inc/{ => mkn}/kul/os/win/src/cli/hidden.cpp (96%) rename inc/{ => mkn}/kul/os/win/src/cli/show.cpp (98%) rename inc/{ => mkn}/kul/os/win/src/os/dir/dirs.ipp (95%) rename inc/{ => mkn}/kul/os/win/src/os/dir/files.ipp (93%) rename inc/{ => mkn}/kul/os/win/src/os/dir/real.ipp (95%) rename inc/{ => mkn}/kul/os/win/src/proc/expand.cpp (90%) rename inc/{ => mkn}/kul/os/win/src/proc/run.cpp (90%) rename inc/{ => mkn}/kul/os/win/src/proc/tearDown.cpp (97%) rename inc/{ => mkn}/kul/os/win/src/signal/se_handler.cpp (97%) rename inc/{ => mkn}/kul/os/win/src/thread/main.cpp (95%) rename inc/{ => mkn}/kul/os/win/sys.hpp (88%) rename inc/{ => mkn}/kul/os/win/threads.os.hpp (91%) rename inc/{ => mkn}/kul/proc.hpp (79%) rename inc/{ => mkn}/kul/scm.hpp (73%) rename inc/{ => mkn}/kul/scm/man.hpp (93%) rename inc/{ => mkn}/kul/serial.hpp (95%) rename inc/{ => mkn}/kul/serial/cli.arg.end.hpp (80%) rename inc/{ => mkn}/kul/serial/cli.bottom.hpp (87%) rename inc/{ => mkn}/kul/signal.hpp (88%) rename inc/{ => mkn}/kul/span.hpp (96%) rename inc/{ => mkn}/kul/src/cli/asArgs.ipp (95%) rename inc/{ => mkn}/kul/src/proc.base/start.ipp (84%) rename inc/{ => mkn}/kul/src/proc.base/toString.ipp (93%) rename inc/{ => mkn}/kul/string.hpp (97%) rename inc/{ => mkn}/kul/sys.hpp (84%) rename inc/{ => mkn}/kul/threads.hpp (85%) rename inc/{ => mkn}/kul/time.hpp (91%) rename inc/{ => mkn}/kul/tuple.hpp (95%) rename inc/{ => mkn}/kul/wstring.hpp (96%) rename inc/{ => mkn}/kul/yaml.hpp (92%) diff --git a/.github/workflows/build_nix.yml b/.github/workflows/build_nix.yml index 4fcd063..6ec13d7 100644 --- a/.github/workflows/build_nix.yml +++ b/.github/workflows/build_nix.yml @@ -12,15 +12,8 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Get mkn - uses: dawidd6/action-download-artifact@v2 - with: - name: mkn - branch: master - workflow: build_nix.yml - repo: mkn/maiken - - name: "Build/Test" # contains slash so use quotes otherwise UB run: | - chmod +x mkn - KLOG=3 ./mkn clean build run -dtOp test -a "-std=c++17 -fPIC" + wget https://github.com/PhilipDeegan/mkn/releases/download/latest/mkn_nix + chmod +x mkn_nix + KLOG=3 ./mkn_nix clean build run -dtOp test -a "-std=c++17 -fPIC" diff --git a/.github/workflows/build_osx.yml b/.github/workflows/build_osx.yml index c0c0e14..99fa92e 100644 --- a/.github/workflows/build_osx.yml +++ b/.github/workflows/build_osx.yml @@ -12,15 +12,8 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Get mkn - uses: dawidd6/action-download-artifact@v2 - with: - name: mkn - branch: master - workflow: build_osx.yml - repo: mkn/maiken - - name: "Build/Test" # contains slash so use quotes otherwise UB run: | - chmod +x mkn - KLOG=3 ./mkn clean build run -dtOp test -a "-std=c++17 -fPIC" + wget https://github.com/PhilipDeegan/mkn/releases/download/latest/mkn_osx + chmod +x mkn_osx + KLOG=3 ./mkn_osx clean build run -dtOp test -a "-std=c++17 -fPIC" diff --git a/.github/workflows/build_win.yml b/.github/workflows/build_win.yml index 01f85b6..13bbaa2 100644 --- a/.github/workflows/build_win.yml +++ b/.github/workflows/build_win.yml @@ -12,19 +12,12 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Get mkn - uses: dawidd6/action-download-artifact@v2 - with: - name: mkn - branch: master - workflow: build_win.yml - repo: mkn/maiken - - name: "Build/Test" # contains slash so use quotes otherwise UB shell: cmd env: MKN_CL_PREFERRED: 1 run: | # /bin/link interferes with cl/link.exe bash -c "rm /bin/link" + bash -c "curl -Lo mkn.exe https://github.com/PhilipDeegan/mkn/releases/download/latest/mkn.exe" call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat" bash -c 'KLOG=3 ./mkn clean build run -dtKOp test -a "-EHsc -std:c++17"' diff --git a/.travis.yml b/.travis.yml index 02a93e1..fb23a7f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,5 +34,5 @@ script: eval "${MATRIX_EVAL}" export CC CXX make nix -C maiken && cp maiken/mkn . - ./mkn build -dtKa "-D_KUL_USE_CBLAS -O2 -std=c++17 -fPIC" -l "-pthread -ldl -lblas" -p test run + ./mkn build -dtKa "-D_MKN_KUL_USE_CBLAS -O2 -std=c++17 -fPIC" -l "-pthread -ldl -lblas" -p test run fi diff --git a/README.noformat b/README.noformat index b08a5a8..6554d7a 100644 --- a/README.noformat +++ b/README.noformat @@ -52,14 +52,20 @@ Description - Add string to svn checkout as arguments Switches - OSX is considered BSD for swiches unless otherwise noted -Key _KUL_MAX_PATH_ +Key _MKN_KUL_DISABLE_KLOG_DEF_ +Type bool +Default undefined +OS all +Description if defined, or set to 1, do not register KLOG* macros + +Key _MKN_KUL_MAX_PATH_ Type size_t Default MAX_PATH/PATH_MAX - or 1024 if not found OS all Description Max array length for filesystem interactions -Key __KUL_LOG_FRMT__ +Key __MKN_KUL_LOG_FRMT__ Type string Default "[%M]: %T - %D : %F fn(%N)#%L - %S" OS all @@ -67,13 +73,13 @@ Description Logging format in format view: %M = Mode - INF/ERR/DBG %T = Thread ID - %D = DateTime - uses __KUL_LOG_DATE_FRMT__ + %D = DateTime - uses __MKN_KUL_LOG_DATE_FRMT__ %F = File %N = Function %L = Line %S = String -Key __KUL_LOG_DATE_FRMT__ +Key __MKN_KUL_LOG_DATE_FRMT__ Type string Default "%Y-%m-%d-%H:%M:%S:%i" OS all @@ -81,7 +87,7 @@ Description Logging DateTime format, reference: http://en.cppreference.com/w/cpp/chrono/c/strftime "%i" is custom for milliseconds, method strftime is used for all other -Key __KUL_THREAD_SPAWN_WAIT__ +Key __MKN_KUL_THREAD_SPAWN_WAIT__ Type number Default nix/bsd 5000000 @@ -90,7 +96,7 @@ OS all Description Used in thread queues. The amount of time in nanoseconds waited after launching a thread. Threads launched too quickly can cause issues on nix platforms, bsd assumed similar. -Key __KUL_PROC_BLOCK_ERR__ +Key __MKN_KUL_PROC_BLOCK_ERR__ Type flag Default disabled OS nix/bsd @@ -99,21 +105,21 @@ Turns on error checking for creating new processes when running - fcntl(fd, F_SETFL, O_NONBLOCK); Can be an issue being on when running many processes rapidly. -Key __KUL_PROC_DUP_RETRY__ +Key __MKN_KUL_PROC_DUP_RETRY__ Type number Default 3 OS nix/bsd Description Allows N retries for "dup(fileDescriptor") calls in forked process. -Key __KUL_SYS_DLOPEN__ +Key __MKN_KUL_SYS_DLOPEN__ Type text Default RTLD_NOW|RTLD_GLOBAL OS nix/bsd Description Flags for dlopen, see https://linux.die.net/man/3/dlopen -Key _KUL_PROC_LOOP_NSLEEP_ +Key _MKN_KUL_PROC_LOOP_NSLEEP_ Type number Default undefined OS nix/bsd @@ -121,7 +127,7 @@ Description Nanosecond sleep while reading running processes pipe output, if defined and greater than 0 -Key _KUL_COMPILED_LIB_ +Key _MKN_KUL_COMPILED_LIB_ Type flag Default disabled OS all @@ -141,5 +147,5 @@ With options 1. google.sparsehash - Uses google.sparsehash for kul::hash::set and kul::hash::map classes + Uses google.sparsehash for mkn::kul::hash::set and mkn::kul::hash::map classes diff --git a/inc/kul/all.hpp b/inc/mkn/kul/all.hpp similarity index 97% rename from inc/kul/all.hpp rename to inc/mkn/kul/all.hpp index b28bad5..24acd29 100644 --- a/inc/kul/all.hpp +++ b/inc/mkn/kul/all.hpp @@ -28,14 +28,15 @@ 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. */ -#ifndef _KUL_TUPLE_HPP_ -#define _KUL_TUPLE_HPP_ +#ifndef _MKN_KUL_TUPLE_HPP_ +#define _MKN_KUL_TUPLE_HPP_ #include #include #include #include +namespace mkn { namespace kul { #define PRINT_LINE() std::cout << __LINE__ << std::endl @@ -172,5 +173,6 @@ class All { }; } // namespace kul +} // namespace mkn -#endif /* _KUL_TUPLE_HPP_ */ +#endif /* _MKN_KUL_TUPLE_HPP_ */ diff --git a/inc/kul/asio/log.hpp b/inc/mkn/kul/asio/log.hpp similarity index 63% rename from inc/kul/asio/log.hpp rename to inc/mkn/kul/asio/log.hpp index d582c47..d9ff0ef 100644 --- a/inc/kul/asio/log.hpp +++ b/inc/mkn/kul/asio/log.hpp @@ -28,35 +28,36 @@ 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. */ -#ifndef _KUL_ASIO_LOG_HPP_ -#define _KUL_ASIO_LOG_HPP_ +#ifndef _MKN_KUL_ASIO_LOG_HPP_ +#define _MKN_KUL_ASIO_LOG_HPP_ -#include "kul/log.hpp" -#include "kul/threads.hpp" +#include "mkn/kul/log.hpp" +#include "mkn/kul/threads.hpp" +namespace mkn { namespace kul { namespace asio { namespace log { -class Exception : public kul::Exception { +class Exception : public mkn::kul::Exception { public: - Exception(char const *f, uint16_t const &l, std::string const &s) : kul::Exception(f, l, s) {} + Exception(char const *f, uint16_t const &l, std::string const &s) : mkn::kul::Exception(f, l, s) {} }; } // namespace log class LogMan; -class Logger : public kul::Logger { +class Logger : public mkn::kul::Logger { friend class LogMan; private: - kul::ChroncurrentThreadPool<> ctp; + mkn::kul::ChroncurrentThreadPool<> ctp; std::function defE, defO; public: Logger() : ctp(1, 1), - defE([&](std::string const &s) { kul::Logger::err(s); }), - defO([&](std::string const &s) { kul::Logger::out(s); }) {} + defE([&](std::string const &s) { mkn::kul::Logger::err(s); }), + defO([&](std::string const &s) { mkn::kul::Logger::out(s); }) {} void err(std::string const &s) override { if (e) ctp.async(std::bind(e, s)); @@ -71,9 +72,9 @@ class Logger : public kul::Logger { } }; -class LogMan : public kul::ALogMan { +class LogMan : public mkn::kul::ALogMan { protected: - LogMan() : ALogMan(new kul::asio::Logger()) {} + LogMan() : ALogMan(new mkn::kul::asio::Logger()) {} public: static LogMan &INSTANCE() { @@ -85,9 +86,9 @@ class LogMan : public kul::ALogMan { class Message { protected: std::stringstream ss; - const kul::log::mode &m; + const mkn::kul::log::mode &m; - Message(const kul::log::mode &_m) : m(_m) {} + Message(const mkn::kul::log::mode &_m) : m(_m) {} public: template @@ -99,7 +100,7 @@ class Message { class LogMessage : public Message { public: ~LogMessage() { LogMan::INSTANCE().log(f, fn, l, m, ss.str()); } - LogMessage(char const *_f, char const *_fn, uint16_t const &_l, const kul::log::mode &_m) + LogMessage(char const *_f, char const *_fn, uint16_t const &_l, const mkn::kul::log::mode &_m) : Message(_m), f(_f), fn(_fn), l(_l) {} private: @@ -107,29 +108,30 @@ class LogMessage : public Message { uint16_t const &l; }; struct OutMessage : public Message { - OutMessage(const kul::log::mode &_m = kul::log::mode::NON) : Message(_m) {} + OutMessage(const mkn::kul::log::mode &_m = mkn::kul::log::mode::NON) : Message(_m) {} ~OutMessage() { LogMan::INSTANCE().out(m, ss.str()); } }; struct ErrMessage : public Message { - ErrMessage() : Message(kul::log::mode::ERR) {} + ErrMessage() : Message(mkn::kul::log::mode::ERR) {} ~ErrMessage() { LogMan::INSTANCE().err(ss.str()); } }; -#define KASIO_LOG_INF kul::asio::LogMessage(__FILE__, __func__, __LINE__, kul::log::mode::INF) -#define KASIO_LOG_ERR kul::asio::LogMessage(__FILE__, __func__, __LINE__, kul::log::mode::ERR) -#define KASIO_LOG_DBG kul::asio::LogMessage(__FILE__, __func__, __LINE__, kul::log::mode::DBG) -#define KASIO_LOG_TRC kul::asio::LogMessage(__FILE__, __func__, __LINE__, kul::log::mode::TRC) +#define KASIO_LOG_INF mkn::kul::asio::LogMessage(__FILE__, __func__, __LINE__, mkn::kul::log::mode::INF) +#define KASIO_LOG_ERR mkn::kul::asio::LogMessage(__FILE__, __func__, __LINE__, mkn::kul::log::mode::ERR) +#define KASIO_LOG_DBG mkn::kul::asio::LogMessage(__FILE__, __func__, __LINE__, mkn::kul::log::mode::DBG) +#define KASIO_LOG_TRC mkn::kul::asio::LogMessage(__FILE__, __func__, __LINE__, mkn::kul::log::mode::TRC) #define KASIO_LOG(sev) KLOG_##sev -#define KASIO_OUT_NON kul::asio::OutMessage() -#define KASIO_OUT_INF kul::asio::OutMessage(kul::log::mode::INF) -#define KASIO_OUT_ERR kul::asio::OutMessage(kul::log::mode::ERR) -#define KASIO_OUT_DBG kul::asio::OutMessage(kul::log::mode::DBG) -#define KASIO_OUT_TRC kul::asio::OutMessage(kul::log::mode::TRC) +#define KASIO_OUT_NON mkn::kul::asio::OutMessage() +#define KASIO_OUT_INF mkn::kul::asio::OutMessage(mkn::kul::log::mode::INF) +#define KASIO_OUT_ERR mkn::kul::asio::OutMessage(mkn::kul::log::mode::ERR) +#define KASIO_OUT_DBG mkn::kul::asio::OutMessage(mkn::kul::log::mode::DBG) +#define KASIO_OUT_TRC mkn::kul::asio::OutMessage(mkn::kul::log::mode::TRC) #define KASIO_OUT(sev) KASIO_OUT_##sev -#define KASIO_ERR kul::ErrMessage() +#define KASIO_ERR mkn::kul::ErrMessage() } // namespace asio } // namespace kul -#endif /* _KUL_LOG_HPP_ */ +} // namespace mkn +#endif /* _MKN_KUL_LOG_HPP_ */ diff --git a/inc/kul/assert.hpp b/inc/mkn/kul/assert.hpp similarity index 85% rename from inc/kul/assert.hpp rename to inc/mkn/kul/assert.hpp index 18ecaa6..d9f458d 100644 --- a/inc/kul/assert.hpp +++ b/inc/mkn/kul/assert.hpp @@ -28,30 +28,32 @@ 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. */ -#ifndef _KUL_ASSERT_HPP_ -#define _KUL_ASSERT_HPP_ +#ifndef _MKN_KUL_ASSERT_HPP_ +#define _MKN_KUL_ASSERT_HPP_ -#include "kul/signal.hpp" +#include "mkn/kul/signal.hpp" +namespace mkn { namespace kul { struct Assert { template Assert(T t) { #if !defined(NDEBUG) if (!(t)) { - auto tid = kul::this_thread::id(); + auto tid = mkn::kul::this_thread::id(); KOUT(NON) << tid << " : Stacktrace:"; - for (auto const& s : kul::this_thread::stacktrace()) KOUT(NON) << tid << " : " << s; + for (auto const& s : mkn::kul::this_thread::stacktrace()) KOUT(NON) << tid << " : " << s; exit(111); } #endif } }; } // namespace kul +} // namespace mkn #if !defined(KASSERT) #define KASSERT(b) \ - kul::Assert { (b) } + mkn::kul::Assert { (b) } #endif #if defined(KASSERT_REPLACE_ASSERT) @@ -61,4 +63,4 @@ struct Assert { #define assert(b) KASSERT(b) #endif -#endif /* _KUL_ASSERT_HPP_ */ +#endif /* _MKN_KUL_ASSERT_HPP_ */ diff --git a/inc/kul/bon.hpp b/inc/mkn/kul/bon.hpp similarity index 90% rename from inc/kul/bon.hpp rename to inc/mkn/kul/bon.hpp index 6c215c6..c6a9f59 100644 --- a/inc/kul/bon.hpp +++ b/inc/mkn/kul/bon.hpp @@ -28,17 +28,18 @@ 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. */ -#ifndef _KUL_BON_HPP_ -#define _KUL_BON_HPP_ +#ifndef _MKN_KUL_BON_HPP_ +#define _MKN_KUL_BON_HPP_ -#include "kul/cli.hpp" -#include "kul/yaml.hpp" +#include "mkn/kul/cli.hpp" +#include "mkn/kul/yaml.hpp" +namespace mkn { namespace kul { namespace bon { -class Exception : public kul::Exception { +class Exception : public mkn::kul::Exception { public: - Exception(char const *f, const size_t &l, std::string const &s) : kul::Exception(f, l, s) {} + Exception(char const *f, const size_t &l, std::string const &s) : mkn::kul::Exception(f, l, s) {} }; enum class TYPE { OBJ = 0, STR, INT }; @@ -91,19 +92,19 @@ class ob { if (o.a.empty() && o.v.empty() && o.c.empty()) return; if (o.a.empty()) { - auto p = kul::String::ESC_SPLIT(o.v, ':'); + auto p = mkn::kul::String::ESC_SPLIT(o.v, ':'); if (p.size() == 2) keys.emplace_back(p[0]); auto val = get_with_keys(); val = p[1]; } else if (o.c.empty()) { keys.emplace_back(o.v); auto val = get_with_keys(); - auto vals = kul::String::ESC_SPLIT(o.a, ','); + auto vals = mkn::kul::String::ESC_SPLIT(o.a, ','); if (vals.empty()) val = o.a; for (const auto &v : vals) { - auto p = kul::String::ESC_SPLIT(v, ':'); + auto p = mkn::kul::String::ESC_SPLIT(v, ':'); if (p.size() == 2) { - kul::String::TRIM(p); + mkn::kul::String::TRIM(p); val[p[0]] = p[1]; } else KEXCEPTION("FAIL"); @@ -149,5 +150,6 @@ YAML::Node from(std::string s) { } // namespace bon } // namespace kul +} // namespace mkn -#endif // _KUL_BON_HPP_ +#endif // _MKN_KUL_BON_HPP_ diff --git a/inc/kul/byte.hpp b/inc/mkn/kul/byte.hpp similarity index 96% rename from inc/kul/byte.hpp rename to inc/mkn/kul/byte.hpp index d95bc3c..f7abd1e 100644 --- a/inc/kul/byte.hpp +++ b/inc/mkn/kul/byte.hpp @@ -28,11 +28,12 @@ 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. */ -#ifndef _KUL_BYTE_HPP_ -#define _KUL_BYTE_HPP_ +#ifndef _MKN_KUL_BYTE_HPP_ +#define _MKN_KUL_BYTE_HPP_ #include +namespace mkn { namespace kul { namespace byte { @@ -94,5 +95,6 @@ class LittleEndian { }; } // namespace byte } // namespace kul +} // namespace mkn -#endif /* _KUL_BYTE_HPP_ */ +#endif /* _MKN_KUL_BYTE_HPP_ */ diff --git a/inc/kul/cli.hpp b/inc/mkn/kul/cli.hpp similarity index 91% rename from inc/kul/cli.hpp rename to inc/mkn/kul/cli.hpp index 442c718..78dc8c2 100644 --- a/inc/kul/cli.hpp +++ b/inc/mkn/kul/cli.hpp @@ -28,20 +28,21 @@ 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. */ -#ifndef _KUL_CLI_HPP_ -#define _KUL_CLI_HPP_ +#ifndef _MKN_KUL_CLI_HPP_ +#define _MKN_KUL_CLI_HPP_ #include #include #include -#include "kul/env.hpp" -#include "kul/except.hpp" -#include "kul/map.hpp" -#include "kul/os/cli.hpp" -#include "kul/serial.hpp" -#include "kul/string.hpp" +#include "mkn/kul/env.hpp" +#include "mkn/kul/except.hpp" +#include "mkn/kul/map.hpp" +#include "mkn/kul/os/cli.hpp" +#include "mkn/kul/serial.hpp" +#include "mkn/kul/string.hpp" +namespace mkn { namespace kul { namespace cli { @@ -52,9 +53,9 @@ inline const std::string receive(std::string const &t = "") { return s; } -class Exception : public kul::Exception { +class Exception : public mkn::kul::Exception { public: - Exception(char const *f, uint16_t const &l, std::string const &s) : kul::Exception(f, l, s) {} + Exception(char const *f, uint16_t const &l, std::string const &s) : mkn::kul::Exception(f, l, s) {} }; class ArgNotFoundException : public Exception { @@ -72,10 +73,10 @@ class Cmd { char const *command() const { return c; } }; -// deprecated : use kul::env::Var::Mode +// deprecated : use mkn::kul::env::Var::Mode enum EnvVarMode { APPE = 0, PREP, REPL }; -// deprecated : use kul::env::Var +// deprecated : use mkn::kul::env::Var class EnvVar { public: EnvVar(const std::string _n, const std::string _v, const EnvVarMode _m) : n(_n), v(_v), m(_m) {} @@ -85,14 +86,14 @@ class EnvVar { EnvVarMode mode() const { return m; } const std::string toString() const { std::string var(value()); - kul::String::REPLACE_ALL(var, kul::env::EOL(), ""); - kul::String::TRIM(var); + mkn::kul::String::REPLACE_ALL(var, mkn::kul::env::EOL(), ""); + mkn::kul::String::TRIM(var); const std::string ev(env::GET(name())); if (!ev.empty()) { if (mode() == EnvVarMode::PREP) - var = var + kul::env::SEP() + ev; + var = var + mkn::kul::env::SEP() + ev; else if (mode() == EnvVarMode::APPE) - var = ev + kul::env::SEP() + var; + var = ev + mkn::kul::env::SEP() + var; } return var; } @@ -263,7 +264,7 @@ class Args { hash::map::S2S vals; public: -#include "kul/serial/cli.arg.end.hpp" +#include "mkn/kul/serial/cli.arg.end.hpp" }; inline void asArgs(std::string const &cmd, std::vector &args); @@ -276,11 +277,12 @@ inline std::vector asArgs(std::string const &cmd) { } // namespace cli } // namespace kul +} // namespace mkn -#ifndef _KUL_COMPILED_LIB_ -#include "kul/src/cli/asArgs.ipp" +#ifndef _MKN_KUL_COMPILED_LIB_ +#include "mkn/kul/src/cli/asArgs.ipp" #endif -#include "kul/serial/cli.bottom.hpp" +#include "mkn/kul/serial/cli.bottom.hpp" -#endif /* _KUL_CLI_HPP_ */ +#endif /* _MKN_KUL_CLI_HPP_ */ diff --git a/inc/kul/cpu.hpp b/inc/mkn/kul/cpu.hpp similarity index 88% rename from inc/kul/cpu.hpp rename to inc/mkn/kul/cpu.hpp index 528736c..5398d28 100644 --- a/inc/kul/cpu.hpp +++ b/inc/mkn/kul/cpu.hpp @@ -28,19 +28,19 @@ 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. */ -#ifndef _KUL_CPU_HPP_ -#define _KUL_CPU_HPP_ +#ifndef _MKN_KUL_CPU_HPP_ +#define _MKN_KUL_CPU_HPP_ -#include "kul/defs.hpp" +#include "mkn/kul/defs.hpp" #if KUL_IS_NIX -#include "kul/os/nix/cpu.hpp" +#include "mkn/kul/os/nix/cpu.hpp" #elif KUL_IS_BSD -#include "kul/os/bsd/cpu.hpp" +#include "mkn/kul/os/bsd/cpu.hpp" #elif KUL_IS_WIN -#include "kul/os/win/cpu.hpp" +#include "mkn/kul/os/win/cpu.hpp" #else #error unresolved #endif -#endif // _KUL_CPU_HPP_ \ No newline at end of file +#endif // _MKN_KUL_CPU_HPP_ diff --git a/inc/kul/dbg.hpp b/inc/mkn/kul/dbg.hpp similarity index 81% rename from inc/kul/dbg.hpp rename to inc/mkn/kul/dbg.hpp index efd5622..03fe007 100644 --- a/inc/kul/dbg.hpp +++ b/inc/mkn/kul/dbg.hpp @@ -28,11 +28,12 @@ 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. */ -#ifndef _KUL_DBG_HPP_ -#define _KUL_DBG_HPP_ +#ifndef _MKN_KUL_DBG_HPP_ +#define _MKN_KUL_DBG_HPP_ -#include "kul/log.hpp" +#include "mkn/kul/log.hpp" +namespace mkn { namespace kul { namespace dbg { @@ -54,38 +55,38 @@ class StackTrace { #if !defined(NDEBUG) || defined(KUL_FORCE_TRACE) -#define __KUL_TRACE__ 1 +#define __MKN_KUL_TRACE__ 1 #ifndef KUL_TRACE_OR_VOID -#define KUL_TRACE_OR_VOID kul::dbg::StackTrace +#define KUL_TRACE_OR_VOID mkn::kul::dbg::StackTrace #endif // KUL_TRACE_OR_VOID #ifndef KUL_STACK_TRACE -#define KUL_STACK_TRACE return kul::dbg::StackTrace(__PRETTY_FUNCTION__); +#define KUL_STACK_TRACE return mkn::kul::dbg::StackTrace(__PRETTY_FUNCTION__); #endif // KUL_STACK_TRACE #ifndef KUL_DBG_FUNC_ENTER #define KUL_DBG_FUNC_ENTER \ - kul::dbg::FunctionScope s_dbg_functionScopeDBG(__FILE__, __func__, __LINE__); + mkn::kul::dbg::FunctionScope s_dbg_functionScopeDBG(__FILE__, __func__, __LINE__); #endif // KUL_DBG_FUNC_ENTER #ifndef 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, "", \ + KOUT(TRC) << mkn::kul::LogMan::INSTANCE().str(m_fi, m_fu, m_li, mkn::kul::log::mode::TRC, "", \ "[%M]: %T - %D : %F:%L fn(%N)") \ << " - ENTERED"; #endif // KUL_DBG_FUNC_ON_ENTER #ifndef KUL_DBG_FUNC_ON_EXIT #define KUL_DBG_FUNC_ON_EXIT \ - KOUT(TRC) << kul::LogMan::INSTANCE().str(m_fi, m_fu, m_li, kul::log::mode::TRC, "", \ + KOUT(TRC) << mkn::kul::LogMan::INSTANCE().str(m_fi, m_fu, m_li, mkn::kul::log::mode::TRC, "", \ "[%M]: %T - %D : %F:%L fn(%N)") \ - << " - Function time: " << (kul::Now::MICROS() - m_start) << " μs"; + << " - Function time: " << (mkn::kul::Now::MICROS() - m_start) << " μs"; #endif // KUL_DBG_FUNC_ON_EXIT #else // -#define __KUL_TRACE__ 0 +#define __MKN_KUL_TRACE__ 0 #define KUL_TRACE_OR_VOID void #define KUL_STACK_TRACE #define KUL_DBG_FUNC_ENTER @@ -103,7 +104,7 @@ class FunctionScope { public: #if defined(KUL_FORCE_TRACE) || !defined(NDEBUG) FunctionScope(char const *fi, char const *fu, uint16_t const &li) - : m_start(kul::Now::MICROS()), m_li(li), m_fi(fi), m_fu(fu) { + : m_start(mkn::kul::Now::MICROS()), m_li(li), m_fi(fi), m_fu(fu) { KUL_DBG_FUNC_ON_ENTER } #endif // defined(KUL_FORCE_TRACE) || !defined(NDEBUG) @@ -111,5 +112,6 @@ class FunctionScope { }; } // namespace dbg } // namespace kul +} // namespace mkn -#endif /* _KUL_DBG_HPP_ */ +#endif /* _MKN_KUL_DBG_HPP_ */ diff --git a/inc/kul/decltype.hpp b/inc/mkn/kul/decltype.hpp similarity index 92% rename from inc/kul/decltype.hpp rename to inc/mkn/kul/decltype.hpp index 906d199..09a3a86 100644 --- a/inc/kul/decltype.hpp +++ b/inc/mkn/kul/decltype.hpp @@ -28,9 +28,10 @@ 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. */ -#ifndef _KUL_DECLTYPE_HPP_ -#define _KUL_DECLTYPE_HPP_ +#ifndef _MKN_KUL_DECLTYPE_HPP_ +#define _MKN_KUL_DECLTYPE_HPP_ +namespace mkn { namespace kul { namespace func { @@ -39,5 +40,6 @@ using check = void; } } // namespace kul +} // namespace mkn -#endif /* _KUL_DECLTYPE_HPP_ */ +#endif /* _MKN_KUL_DECLTYPE_HPP_ */ diff --git a/inc/kul/defs.hpp b/inc/mkn/kul/defs.hpp similarity index 95% rename from inc/kul/defs.hpp rename to inc/mkn/kul/defs.hpp index 4c00c18..204243d 100644 --- a/inc/kul/defs.hpp +++ b/inc/mkn/kul/defs.hpp @@ -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. */ -#ifndef _KUL_DEFS_HPP_ -#define _KUL_DEFS_HPP_ +#ifndef _MKN_KUL_DEFS_HPP_ +#define _MKN_KUL_DEFS_HPP_ #define KSTRINGIFY(x) #x #define KTOSTRING(x) KSTRINGIFY(x) @@ -97,6 +97,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define KUL_DEBUG_DO_ELSE(...) __VA_ARGS__ #endif -#include "kul/os/def.hpp" +#include "mkn/kul/os/def.hpp" -#endif /* _KUL_DEFS_HPP_ */ +#endif /* _MKN_KUL_DEFS_HPP_ */ diff --git a/inc/kul/env.hpp b/inc/mkn/kul/env.hpp similarity index 85% rename from inc/kul/env.hpp rename to inc/mkn/kul/env.hpp index 3c213f8..49f4a01 100644 --- a/inc/kul/env.hpp +++ b/inc/mkn/kul/env.hpp @@ -28,17 +28,18 @@ 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. */ -#ifndef _KUL_ENV_HPP_ -#define _KUL_ENV_HPP_ +#ifndef _MKN_KUL_ENV_HPP_ +#define _MKN_KUL_ENV_HPP_ -#include "kul/string.hpp" +#include "mkn/kul/string.hpp" #if KUL_IS_WIN -#include "kul/os/win/env.hpp" +#include "mkn/kul/os/win/env.hpp" #else -#include "kul/os/nixish/env.hpp" +#include "mkn/kul/os/nixish/env.hpp" #endif /*KUL_IS_WIN*/ +namespace mkn { namespace kul { namespace env { @@ -53,14 +54,14 @@ class Var { Mode mode() const { return m; } const std::string toString() const { std::string var(value()); - kul::String::REPLACE_ALL(var, EOL(), ""); - kul::String::TRIM(var); + mkn::kul::String::REPLACE_ALL(var, EOL(), ""); + mkn::kul::String::TRIM(var); const std::string ev(env::GET(name())); if (!ev.empty()) { if (mode() == Mode::PREP) - var = var + kul::env::SEP() + ev; + var = var + mkn::kul::env::SEP() + ev; else if (mode() == Mode::APPE) - var = ev + kul::env::SEP() + var; + var = ev + mkn::kul::env::SEP() + var; } return var; } @@ -79,5 +80,6 @@ class Var { } // namespace env } // namespace kul +} // namespace mkn -#endif /* _KUL_ENV_HPP_ */ +#endif /* _MKN_KUL_ENV_HPP_ */ diff --git a/inc/kul/except.hpp b/inc/mkn/kul/except.hpp similarity index 94% rename from inc/kul/except.hpp rename to inc/mkn/kul/except.hpp index 02d4a95..2485178 100644 --- a/inc/kul/except.hpp +++ b/inc/mkn/kul/except.hpp @@ -28,15 +28,16 @@ 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. */ -#ifndef _KUL_EXCEPT_HPP_ -#define _KUL_EXCEPT_HPP_ +#ifndef _MKN_KUL_EXCEPT_HPP_ +#define _MKN_KUL_EXCEPT_HPP_ #include #include #include -#include "kul/defs.hpp" +#include "mkn/kul/defs.hpp" +namespace mkn { namespace kul { // For function signatures @@ -83,7 +84,7 @@ class Exception : public std::runtime_error { if (_ep) { try { std::rethrow_exception(_ep); - } catch (const kul::Exception &e) { + } catch (const mkn::kul::Exception &e) { ss << e.stack() << std::endl; } catch (const std::exception &e) { ss << e.what() << std::endl; @@ -138,12 +139,16 @@ class Exit : public Exception { Exit &operator=(const Exit &&e) = delete; }; +} // namespace kul +} // namespace mkn + + + #define KEXCEPT(e, m) throw e(__FILE__, __LINE__, m) #define KEXCEPTSTR(e) throw e(__FILE__, __LINE__, "") #define KEXCEPTION(m) throw Exception(__FILE__, __LINE__, m) #define KEXCEPSTREAM throw Exception(__FILE__, __LINE__, "") -#define KEXIT(e, m) throw kul::Exit(__FILE__, __LINE__, m, e) +#define KEXIT(e, m) throw mkn::kul::Exit(__FILE__, __LINE__, m, e) -} // namespace kul -#endif /* _KUL_EXCEPT_HPP_ */ +#endif /* _MKN_KUL_EXCEPT_HPP_ */ diff --git a/inc/kul/for.hpp b/inc/mkn/kul/for.hpp similarity index 95% rename from inc/kul/for.hpp rename to inc/mkn/kul/for.hpp index 44990ee..5913317 100644 --- a/inc/kul/for.hpp +++ b/inc/mkn/kul/for.hpp @@ -28,11 +28,12 @@ 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. */ -#ifndef _KUL_FOR_HPP_ -#define _KUL_FOR_HPP_ +#ifndef _MKN_KUL_FOR_HPP_ +#define _MKN_KUL_FOR_HPP_ #include +namespace mkn { namespace kul { template @@ -67,5 +68,6 @@ constexpr void for_N(Fn&& fn) { } // namespace kul +} // namespace mkn -#endif /* _KUL_FOR_HPP_ */ +#endif /* _MKN_KUL_FOR_HPP_ */ diff --git a/inc/kul/hash.hpp b/inc/mkn/kul/hash.hpp similarity index 94% rename from inc/kul/hash.hpp rename to inc/mkn/kul/hash.hpp index e4fb1ef..2995d05 100644 --- a/inc/kul/hash.hpp +++ b/inc/mkn/kul/hash.hpp @@ -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. */ -#ifndef _KUL_HASH_HPP_ -#define _KUL_HASH_HPP_ +#ifndef _MKN_KUL_HASH_HPP_ +#define _MKN_KUL_HASH_HPP_ /* * REQUIRES libcrypto @@ -38,6 +38,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include "openssl/sha.h" +namespace mkn { namespace kul { namespace hash { @@ -57,4 +58,5 @@ class SHA { }; } // namespace hash } // namespace kul -#endif /* _KUL_HASH_HPP_ */ +} // namespace mkn +#endif /* _MKN_KUL_HASH_HPP_ */ diff --git a/inc/kul/io.hpp b/inc/mkn/kul/io.hpp similarity index 94% rename from inc/kul/io.hpp rename to inc/mkn/kul/io.hpp index d642dc9..0737263 100644 --- a/inc/kul/io.hpp +++ b/inc/mkn/kul/io.hpp @@ -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. */ -#ifndef _KUL_IO_HPP_ -#define _KUL_IO_HPP_ +#ifndef _MKN_KUL_IO_HPP_ +#define _MKN_KUL_IO_HPP_ #include #include @@ -37,17 +37,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include "kul/except.hpp" -#include "kul/log.hpp" -#include "kul/os.hpp" -#include "kul/string.hpp" +#include "mkn/kul/except.hpp" +#include "mkn/kul/log.hpp" +#include "mkn/kul/os.hpp" +#include "mkn/kul/string.hpp" +namespace mkn { namespace kul { namespace io { -class Exception : public kul::Exception { +class Exception : public mkn::kul::Exception { public: - Exception(char const *f, const size_t &l, std::string const &s) : kul::Exception(f, l, s) {} + Exception(char const *f, const size_t &l, std::string const &s) : mkn::kul::Exception(f, l, s) {} }; class AReader { @@ -161,7 +162,7 @@ class AWriter { AWriter &write(char const *c, bool nl = false) { if (nl) - f << c << kul::os::EOL(); + f << c << mkn::kul::os::EOL(); else f << c; return *this; @@ -219,4 +220,5 @@ class BinaryWriter : public AWriter { }; } // namespace io } // namespace kul -#endif /* _KUL_IO_HPP_ */ +} // namespace mkn +#endif /* _MKN_KUL_IO_HPP_ */ diff --git a/inc/kul/ipc.hpp b/inc/mkn/kul/ipc.hpp similarity index 89% rename from inc/kul/ipc.hpp rename to inc/mkn/kul/ipc.hpp index 0e8b582..5ef0053 100644 --- a/inc/kul/ipc.hpp +++ b/inc/mkn/kul/ipc.hpp @@ -28,15 +28,15 @@ 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. */ -#ifndef _KUL_IPC_HPP_ -#define _KUL_IPC_HPP_ +#ifndef _MKN_KUL_IPC_HPP_ +#define _MKN_KUL_IPC_HPP_ -#include "kul/defs.hpp" +#include "mkn/kul/defs.hpp" #if defined(_WIN32) -#include "kul/os/win/ipc.hpp" +#include "mkn/kul/os/win/ipc.hpp" #else -#include "kul/os/nixish/ipc.hpp" +#include "mkn/kul/os/nixish/ipc.hpp" #endif -#endif // _KUL_IPC_HPP_ \ No newline at end of file +#endif // _MKN_KUL_IPC_HPP_ \ No newline at end of file diff --git a/inc/kul/log.hpp b/inc/mkn/kul/log.hpp similarity index 69% rename from inc/kul/log.hpp rename to inc/mkn/kul/log.hpp index 4029c8a..2852f66 100644 --- a/inc/kul/log.hpp +++ b/inc/mkn/kul/log.hpp @@ -28,33 +28,34 @@ 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. */ -#ifndef _KUL_LOG_HPP_ -#define _KUL_LOG_HPP_ +#ifndef _MKN_KUL_LOG_HPP_ +#define _MKN_KUL_LOG_HPP_ #include #include #include -#include "kul/os.hpp" -#include "kul/os/threads.hpp" -#include "kul/time.hpp" +#include "mkn/kul/os.hpp" +#include "mkn/kul/os/threads.hpp" +#include "mkn/kul/time.hpp" -#ifndef __KUL_LOG_TIME_FRMT__ -#define __KUL_LOG_TIME_FRMT__ "%Y-%m-%d-%H:%M:%S:%i" +#ifndef __MKN_KUL_LOG_TIME_FRMT__ +#define __MKN_KUL_LOG_TIME_FRMT__ "%Y-%m-%d-%H:%M:%S:%i" #endif -#ifndef __KUL_LOG_FRMT__ -#define __KUL_LOG_FRMT__ "[%M]: %T - %D : %F fn(%N)#%L - %S" +#ifndef __MKN_KUL_LOG_FRMT__ +#define __MKN_KUL_LOG_FRMT__ "[%M]: %T - %D : %F fn(%N)#%L - %S" #endif +namespace mkn { namespace kul { namespace log { enum mode { OFF = -1, NON = 0, INF, ERR, DBG, OTH, TRC }; -class Exception : public kul::Exception { +class Exception : public mkn::kul::Exception { public: - Exception(char const *f, uint16_t const &l, std::string const &s) : kul::Exception(f, l, s) {} + Exception(char const *f, uint16_t const &l, std::string const &s) : mkn::kul::Exception(f, l, s) {} }; } // namespace log @@ -83,13 +84,13 @@ class Logger { virtual ~Logger() {} void str(char const *f, char const *fn, uint16_t const &l, std::string const &s, const log::mode &m, std::string &str) { - kul::String::REPLACE(str, "%M", modeTxt(m)); - kul::String::REPLACE(str, "%T", kul::this_thread::id()); - kul::String::REPLACE(str, "%D", kul::DateTime::NOW(__KUL_LOG_TIME_FRMT__)); - kul::String::REPLACE(str, "%F", f); - kul::String::REPLACE(str, "%N", fn); - kul::String::REPLACE(str, "%L", std::to_string(l)); - kul::String::REPLACE(str, "%S", s); + mkn::kul::String::REPLACE(str, "%M", modeTxt(m)); + mkn::kul::String::REPLACE(str, "%T", mkn::kul::this_thread::id()); + mkn::kul::String::REPLACE(str, "%D", mkn::kul::DateTime::NOW(__MKN_KUL_LOG_TIME_FRMT__)); + mkn::kul::String::REPLACE(str, "%F", f); + mkn::kul::String::REPLACE(str, "%N", fn); + mkn::kul::String::REPLACE(str, "%L", std::to_string(l)); + mkn::kul::String::REPLACE(str, "%S", s); } virtual void err(std::string const &s) { if (e) @@ -105,9 +106,9 @@ class Logger { } void log(char const *f, char const *fn, uint16_t const &l, std::string const &s, const log::mode &m) { - std::string st(__KUL_LOG_FRMT__); + std::string st(__MKN_KUL_LOG_FRMT__); str(f, fn, l, s, m, st); - out(st + kul::os::EOL()); + out(st + mkn::kul::os::EOL()); } void setOut(std::function _o) { this->o = _o; } void setErr(std::function _e) { this->e = _e; } @@ -117,10 +118,10 @@ class ALogMan { protected: log::mode m; mutable std::unique_ptr logger; - ALogMan(Logger *_logger) : m(kul::log::mode::NON), logger(_logger) { - std::string s(kul::env::GET("KLOG")); + ALogMan(Logger *_logger) : m(mkn::kul::log::mode::NON), logger(_logger) { + std::string s(mkn::kul::env::GET("KLOG")); if (s.size()) { - kul::String::TRIM(s); + mkn::kul::String::TRIM(s); if (s == "-1" || s == "OFF") m = log::mode::OFF; else if (s == "0" || s == "NON") @@ -153,11 +154,11 @@ class ALogMan { if (this->m >= _m) logger->log(f, fn, l, s, _m); } void out(const log::mode &_m, std::string const &s) { - if (this->m >= _m) logger->out(s + kul::os::EOL()); + if (this->m >= _m) logger->out(s + mkn::kul::os::EOL()); } - void err(std::string const &s) { logger->err(s + kul::os::EOL()); } + void err(std::string const &s) { logger->err(s + mkn::kul::os::EOL()); } std::string str(char const *f, char const *fn, uint16_t const &l, const log::mode &_m, - std::string const &s = "", const std::string fmt = __KUL_LOG_FRMT__) { + std::string const &s = "", const std::string fmt = __MKN_KUL_LOG_FRMT__) { std::string st(fmt); logger->str(f, fn, l, s, _m, st); return st; @@ -182,7 +183,9 @@ class Message { std::stringstream ss; const log::mode &m; - Message(const log::mode &_m) : m(_m) {} + Message(const log::mode &_m) : m(_m) { + ss.precision(22); + } public: template @@ -209,7 +212,7 @@ class DBgMessage : public Message { DBgMessage(char const *_f, char const *_fn, uint16_t const &_l, const log::mode &_m) : Message(_m), f(_f), fn(_fn), l(_l) {} #else - DBgMessage() : Message(kul::log::mode::NON) {} + DBgMessage() : Message(mkn::kul::log::mode::NON) {} #endif template @@ -225,7 +228,7 @@ class DBgMessage : public Message { class OutMessage : public Message { public: ~OutMessage() { LogMan::INSTANCE().out(m, ss.str()); } - OutMessage(const log::mode &_m = kul::log::mode::NON) : Message(_m) {} + OutMessage(const log::mode &_m = mkn::kul::log::mode::NON) : Message(_m) {} }; class ErrMessage : public Message { public: @@ -235,7 +238,7 @@ class ErrMessage : public Message { class DBoMessage : public Message { public: ~DBoMessage() { KUL_DEBUG_DO(LogMan::INSTANCE().out(m, ss.str())); } - DBoMessage(const log::mode &_m = kul::log::mode::NON) : Message(_m) {} + DBoMessage(const log::mode &_m = mkn::kul::log::mode::NON) : Message(_m) {} template DBoMessage &operator<<([[maybe_unused]] const T &s) { KUL_DEBUG_DO(ss << s;) @@ -243,30 +246,36 @@ class DBoMessage : public Message { } }; -#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) +} // namespace kul +} // namespace mkn + +#if !defined(_MKN_KUL_DISABLE_KLOG_DEF_) || _MKN_KUL_DISABLE_KLOG_DEF_ == 1 + +#define KLOG_NON mkn::kul::LogMessage(__FILE__, __func__, __LINE__, mkn::kul::log::mode::NON) +#define KLOG_INF mkn::kul::LogMessage(__FILE__, __func__, __LINE__, mkn::kul::log::mode::INF) +#define KLOG_ERR mkn::kul::LogMessage(__FILE__, __func__, __LINE__, mkn::kul::log::mode::ERR) #define KLOG(sev) KLOG_##sev #if !defined(NDEBUG) -#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_DBG mkn::kul::DBgMessage(__FILE__, __func__, __LINE__, mkn::kul::log::mode::DBG) +#define KLOG_OTH mkn::kul::DBgMessage(__FILE__, __func__, __LINE__, mkn::kul::log::mode::OTH) +#define KLOG_TRC mkn::kul::DBgMessage(__FILE__, __func__, __LINE__, mkn::kul::log::mode::TRC) #else -#define KLOG_DBG kul::DBgMessage() -#define KLOG_OTH kul::DBgMessage() -#define KLOG_TRC kul::DBgMessage() +#define KLOG_DBG mkn::kul::DBgMessage() +#define KLOG_OTH mkn::kul::DBgMessage() +#define KLOG_TRC mkn::kul::DBgMessage() #endif -#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::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_NON mkn::kul::OutMessage() +#define KOUT_INF mkn::kul::OutMessage(mkn::kul::log::mode::INF) +#define KOUT_ERR mkn::kul::OutMessage(mkn::kul::log::mode::ERR) +#define KOUT_DBG mkn::kul::DBoMessage(mkn::kul::log::mode::DBG) +#define KOUT_OTH mkn::kul::DBoMessage(mkn::kul::log::mode::OTH) +#define KOUT_TRC mkn::kul::DBoMessage(mkn::kul::log::mode::TRC) #define KOUT(sev) KOUT_##sev -#define KERR kul::ErrMessage() +#define KERR mkn::kul::ErrMessage() -} // namespace kul -#endif /* _KUL_LOG_HPP_ */ +#endif //!defined(_MKN_KUL_DISABLE_KLOG_DEF_) + +#endif /* _MKN_KUL_LOG_HPP_ */ diff --git a/inc/kul/map.hpp b/inc/mkn/kul/map.hpp similarity index 98% rename from inc/kul/map.hpp rename to inc/mkn/kul/map.hpp index 65343c3..eb00c38 100644 --- a/inc/kul/map.hpp +++ b/inc/mkn/kul/map.hpp @@ -42,8 +42,8 @@ REQUIRES * T TEMPLATE **/ -#ifndef _KUL_MAP_HPP_ -#define _KUL_MAP_HPP_ +#ifndef _MKN_KUL_MAP_HPP_ +#define _MKN_KUL_MAP_HPP_ #include @@ -52,6 +52,7 @@ REQUIRES #include #include +namespace mkn { namespace kul { namespace hash { @@ -83,6 +84,7 @@ using String = Set; } // namespace set } // namespace hash } // namespace kul +} // namespace mkn #else @@ -92,6 +94,7 @@ using String = Set; #include "sparsehash/dense_hash_map" #include "sparsehash/dense_hash_set" +namespace mkn { namespace kul { struct StdStringComparator { @@ -238,7 +241,8 @@ using S2S = S2T; } // namespace hash } // namespace dense } // namespace kul +} // namespace mkn #endif //_MKN_WITH_GOOGLE_SPARSEHASH_ -#endif /* _KUL_MAP_HPP_ */ +#endif /* _MKN_KUL_MAP_HPP_ */ diff --git a/inc/kul/math.hpp b/inc/mkn/kul/math.hpp similarity index 84% rename from inc/kul/math.hpp rename to inc/mkn/kul/math.hpp index d543c65..69d6dd6 100644 --- a/inc/kul/math.hpp +++ b/inc/mkn/kul/math.hpp @@ -28,19 +28,20 @@ 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. */ -#ifndef _KUL_MATH_HPP_ -#define _KUL_MATH_HPP_ +#ifndef _MKN_KUL_MATH_HPP_ +#define _MKN_KUL_MATH_HPP_ #include -#include "kul/dbg.hpp" +#include "mkn/kul/dbg.hpp" +namespace mkn { namespace kul { namespace math { -class Exception : public kul::Exception { +class Exception : public mkn::kul::Exception { public: - Exception(char const *f, uint16_t const &l, std::string const &s) : kul::Exception(f, l, s) {} + Exception(char const *f, uint16_t const &l, std::string const &s) : mkn::kul::Exception(f, l, s) {} }; template @@ -65,16 +66,17 @@ T root(const float &f, const int16_t &r = 2, uint16_t const &it = 6, T g = 0) { } // namespace math } // namespace kul +} // namespace mkn #include #include #include -#include "kul/math/noop.hpp" +#include "mkn/kul/math/noop.hpp" -#if defined(_KUL_USE_MKL) +#if defined(_MKN_KUL_USE_MKL) #include "mkl.h" -#elif defined(_KUL_USE_CBLAS) +#elif defined(_MKN_KUL_USE_CBLAS) #if defined(__APPLE__) #include #else @@ -83,9 +85,9 @@ extern "C" { } #endif // defined(__APPLE__) #endif -#if defined(_KUL_USE_MKL) || defined(_KUL_USE_CBLAS) -#include "kul/math/blas.hpp" +#if defined(_MKN_KUL_USE_MKL) || defined(_MKN_KUL_USE_CBLAS) +#include "mkn/kul/math/blas.hpp" #else -#include "kul/math/noblas.hpp" +#include "mkn/kul/math/noblas.hpp" #endif -#endif // _KUL_MATH_HPP_ +#endif // _MKN_KUL_MATH_HPP_ diff --git a/inc/kul/math/blas.hpp b/inc/mkn/kul/math/blas.hpp similarity index 98% rename from inc/kul/math/blas.hpp rename to inc/mkn/kul/math/blas.hpp index f85db92..9d49508 100644 --- a/inc/kul/math/blas.hpp +++ b/inc/mkn/kul/math/blas.hpp @@ -2,6 +2,7 @@ #ifndef KUL_MATH_BLAS_HPP_ #define KUL_MATH_BLAS_HPP_ +namespace mkn { namespace kul { namespace math { template @@ -57,4 +58,5 @@ static inline typename std::enable_if::value>::type scal } } // namespace math } // namespace kul +} // namespace mkn #endif // KUL_MATH_BLAS_HPP_ diff --git a/inc/kul/math/noblas.hpp b/inc/mkn/kul/math/noblas.hpp similarity index 97% rename from inc/kul/math/noblas.hpp rename to inc/mkn/kul/math/noblas.hpp index 6738228..fec14ca 100644 --- a/inc/kul/math/noblas.hpp +++ b/inc/mkn/kul/math/noblas.hpp @@ -2,6 +2,7 @@ #ifndef KUL_MATH_NOBLAS_HPP_ #define KUL_MATH_NOBLAS_HPP_ +namespace mkn { namespace kul { namespace math { template @@ -37,4 +38,5 @@ static inline } // namespace math } // namespace kul +} // namespace mkn #endif // KUL_MATH_NOBLAS_HPP_ diff --git a/inc/kul/math/noop.hpp b/inc/mkn/kul/math/noop.hpp similarity index 96% rename from inc/kul/math/noop.hpp rename to inc/mkn/kul/math/noop.hpp index ddec63d..b3436ee 100644 --- a/inc/kul/math/noop.hpp +++ b/inc/mkn/kul/math/noop.hpp @@ -4,23 +4,24 @@ // This macro ensures that the corresponding optimized blas function is used if // available -#if !defined(NDEBUG) && defined(_KUL_USE_CBLAS) +#if !defined(NDEBUG) && defined(_MKN_KUL_USE_CBLAS) // x and y are two pointers #define CHECK_BLAS_OPTIMIZATION_PP(x, y, func_name) \ if (typeid(*x) == typeid(*y) && \ (typeid(*x) == typeid(double) || typeid(*x) == typeid(float))) /* NOLINT */ \ - KEXCEPT(kul::math::Exception, func_name) << " should use blas optimized version"; + KEXCEPT(mkn::kul::math::Exception, func_name) << " should use blas optimized version"; // x is a pointer, y is a scalar #define CHECK_BLAS_OPTIMIZATION_PS(x, y, func_name) \ if (typeid(*x) == typeid(y) && \ (typeid(*x) == typeid(double) || typeid(*x) == typeid(float))) /* NOLINT */ \ - KEXCEPT(kul::math::Exception, func_name) << " should use blas optimized version"; + KEXCEPT(mkn::kul::math::Exception, func_name) << " should use blas optimized version"; #else #define CHECK_BLAS_OPTIMIZATION_PP(x, y, func_name) #define CHECK_BLAS_OPTIMIZATION_PS(x, y, func_name) #endif +namespace mkn { namespace kul { namespace math { namespace detail { @@ -199,5 +200,6 @@ typename std::enable_if>::value>::type dot_matri } // end namespace math } // namespace kul +} // namespace mkn #endif // KUL_MATH_NOOP_HPP_ diff --git a/inc/kul/os.hpp b/inc/mkn/kul/os.hpp similarity index 87% rename from inc/kul/os.hpp rename to inc/mkn/kul/os.hpp index ae9c269..978698f 100644 --- a/inc/kul/os.hpp +++ b/inc/mkn/kul/os.hpp @@ -28,31 +28,32 @@ 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. */ -#ifndef _KUL_OS_HPP_ -#define _KUL_OS_HPP_ +#ifndef _MKN_KUL_OS_HPP_ +#define _MKN_KUL_OS_HPP_ #include -#include "kul/cpu.hpp" -#include "kul/env.hpp" -#include "kul/except.hpp" -#include "kul/string.hpp" +#include "mkn/kul/cpu.hpp" +#include "mkn/kul/env.hpp" +#include "mkn/kul/except.hpp" +#include "mkn/kul/string.hpp" #if KUL_IS_WIN -#include "kul/os/win/os.top.hpp" +#include "mkn/kul/os/win/os.top.hpp" #else -#include "kul/os/nixish/os.top.hpp" +#include "mkn/kul/os/nixish/os.top.hpp" #endif +namespace mkn { namespace kul { class Dir; class File; namespace fs { -class Exception : public kul::Exception { +class Exception : public mkn::kul::Exception { public: - Exception(char const *f, uint16_t const &l, std::string const &s) : kul::Exception(f, l, s) {} + Exception(char const *f, uint16_t const &l, std::string const &s) : mkn::kul::Exception(f, l, s) {} }; class TimeStamps { @@ -64,8 +65,8 @@ class TimeStamps { const uint64_t &accessed() const { return _a; } const uint64_t &created() const { return _c; } const uint64_t &modified() const { return _m; } - friend class kul::Dir; - friend class kul::File; + friend class mkn::kul::Dir; + friend class mkn::kul::File; }; class Item { @@ -97,7 +98,7 @@ class Dir : public fs::Item { static inline std::string ESC(std::string s); static std::string PRNT(std::string const &s) { std::string const &p = s.substr(0, s.rfind(SEP()) + 1); - return kul::Dir(p).root() ? p : s.substr(0, s.rfind(SEP())); + return mkn::kul::Dir(p).root() ? p : s.substr(0, s.rfind(SEP())); } static std::string MINI(std::string const &a) { return a.find(env::CWD()) == std::string::npos @@ -169,7 +170,7 @@ class Dir : public fs::Item { } explicit operator bool() const { return is(); } - std::string relative(kul::Dir const &r) const { + std::string relative(mkn::kul::Dir const &r) const { const auto &l(*this); std::string left = l.real(), right = r.real(); auto l_p = l, r_p = r; @@ -182,7 +183,7 @@ class Dir : public fs::Item { while (true) { left = l_p.real(); if ((pos = right.find(left)) != std::string::npos) break; - l_p = kul::Dir(l_p.real()).parent(); + l_p = mkn::kul::Dir(l_p.real()).parent(); upsies++; } std::string rel = ""; @@ -209,7 +210,7 @@ class File : public fs::Item { this->_n = Dir::REAL(this->_n); this->_d = Dir(Dir::PRNT(this->_n), m); this->_n = this->_n.substr(_d.path().size() + 1); - } catch (const kul::fs::Exception &e) { + } catch (const mkn::kul::fs::Exception &e) { } } else { if (n.find(Dir::SEP()) != std::string::npos) { @@ -218,7 +219,7 @@ class File : public fs::Item { } else { try { this->_d = Dir(Dir::PRNT(Dir::REAL(this->_n)), m); - } catch (const kul::fs::Exception &e) { + } catch (const mkn::kul::fs::Exception &e) { } } } @@ -231,7 +232,7 @@ class File : public fs::Item { bool cp(Dir const &d) const { if (!d.is() && !d.mk()) KEXCEPT(fs::Exception, "Directory: \"" + _d.path() + "\" is not valid"); - return cp(kul::File(name(), d._p)); + return cp(mkn::kul::File(name(), d._p)); } bool cp(File const &f) const { std::ifstream src(_d.join(_n), std::ios::binary); @@ -269,16 +270,16 @@ class File : public fs::Item { } explicit operator bool() const { return is(); } - std::string relative(kul::Dir const &r) const { return this->dir().relative(r); } + std::string relative(mkn::kul::Dir const &r) const { return this->dir().relative(r); } - std::string relative(kul::File const &r) const { + std::string relative(mkn::kul::File const &r) const { std::string rel = this->dir().relative(r.dir()); rel += Dir::SEP() + r.name(); return rel; } }; -inline bool kul::Dir::cp(Dir const &d) const { +inline bool mkn::kul::Dir::cp(Dir const &d) const { if (!d.is() && !d.mk()) KEXCEPT(fs::Exception, "Directory: \"" + d.path() + "\" is not valid"); Dir c(d.join(name())); c.mk(); @@ -290,19 +291,21 @@ inline bool kul::Dir::cp(Dir const &d) const { inline std::ostream &operator<<(std::ostream &s, File const &d) { return s << d.full(); } } // namespace kul +} // namespace mkn +namespace mkn { namespace kul { namespace os { class PushDir { public: - PushDir(kul::Dir const &d) { + PushDir(mkn::kul::Dir const &d) { if (!d) KEXCEPTION("PushDir directory does not exist: ") << d; - cwd = kul::env::CWD(); - kul::env::CWD(d.real()); + cwd = mkn::kul::env::CWD(); + mkn::kul::env::CWD(d.real()); } - PushDir(std::string const &d) : PushDir(kul::Dir(d)) {} - ~PushDir() { kul::env::CWD(cwd); } + PushDir(std::string const &d) : PushDir(mkn::kul::Dir(d)) {} + ~PushDir() { mkn::kul::env::CWD(cwd); } private: std::string cwd; @@ -313,8 +316,8 @@ class PushDir { namespace env { inline std::string WHERE(char const *c) { - for (const auto &s : kul::String::SPLIT(env::GET("PATH"), kul::env::SEP())) { - const kul::Dir d(s); + for (const auto &s : mkn::kul::String::SPLIT(env::GET("PATH"), mkn::kul::env::SEP())) { + const mkn::kul::Dir d(s); if (d) for (const auto &f : d.files()) if (f.name().compare(c) == 0) return f.real(); @@ -326,11 +329,12 @@ inline bool WHICH(char const *c) { return WHERE(c).size(); } inline bool WHICH(std::string const &s) { return WHERE(s.c_str()).size(); } } // namespace env } // namespace kul +} // namespace mkn #if KUL_IS_WIN -#include "kul/os/win/os.bot.hpp" +#include "mkn/kul/os/win/os.bot.hpp" #else -#include "kul/os/nixish/os.bot.hpp" +#include "mkn/kul/os/nixish/os.bot.hpp" #endif -#endif /* _KUL_OS_HPP_ */ +#endif /* _MKN_KUL_OS_HPP_ */ diff --git a/inc/kul/os/bsd/cpu.hpp b/inc/mkn/kul/os/bsd/cpu.hpp similarity index 92% rename from inc/kul/os/bsd/cpu.hpp rename to inc/mkn/kul/os/bsd/cpu.hpp index 847d756..a8b1de2 100644 --- a/inc/kul/os/bsd/cpu.hpp +++ b/inc/mkn/kul/os/bsd/cpu.hpp @@ -28,10 +28,10 @@ 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. */ -// IWYU pragma: private, include "kul/cpu.hpp" +// IWYU pragma: private, include "mkn/kul/cpu.hpp" -#ifndef _KUL_OS_BSD_CPU_HPP_ -#define _KUL_OS_BSD_CPU_HPP_ +#ifndef _MKN_KUL_OS_BSD_CPU_HPP_ +#define _MKN_KUL_OS_BSD_CPU_HPP_ #include #include @@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +namespace mkn { namespace kul { namespace cpu { inline uint32_t cores() { @@ -75,5 +76,6 @@ inline uint32_t cores() { inline uint16_t threads() { return std::thread::hardware_concurrency(); } } // namespace cpu } // namespace kul +} // namespace mkn -#endif /* _KUL_OS_BSD_CPU_HPP_ */ +#endif /* _MKN_KUL_OS_BSD_CPU_HPP_ */ diff --git a/inc/kul/os/bsd/def.hpp b/inc/mkn/kul/os/bsd/def.hpp similarity index 83% rename from inc/kul/os/bsd/def.hpp rename to inc/mkn/kul/os/bsd/def.hpp index f46e7b1..cfc27bd 100644 --- a/inc/kul/os/bsd/def.hpp +++ b/inc/mkn/kul/os/bsd/def.hpp @@ -28,20 +28,20 @@ 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. */ -// IWYU pragma: private, include "kul/defs.hpp" +// IWYU pragma: private, include "mkn/kul/defs.hpp" -#ifndef _KUL_OS_BSD_DEF_HPP_ -#define _KUL_OS_BSD_DEF_HPP_ +#ifndef _MKN_KUL_OS_BSD_DEF_HPP_ +#define _MKN_KUL_OS_BSD_DEF_HPP_ -#include "kul/defs.hpp" +#include "mkn/kul/defs.hpp" -#ifndef __KUL_OS__ -#define __KUL_OS__ bsd -#endif /* __KUL_OS__ */ +#ifndef __MKN_KUL_OS__ +#define __MKN_KUL_OS__ bsd +#endif /* __MKN_KUL_OS__ */ -#ifndef __KUL_THREAD_SPAWN_WAIT__ -#define __KUL_THREAD_SPAWN_WAIT__ 5000000 -#endif /* __KUL_THREAD_SPAWN_WAIT__ */ +#ifndef __MKN_KUL_THREAD_SPAWN_WAIT__ +#define __MKN_KUL_THREAD_SPAWN_WAIT__ 5000000 +#endif /* __MKN_KUL_THREAD_SPAWN_WAIT__ */ #if defined(__APPLE__) @@ -67,4 +67,4 @@ mach_port_t pthread_mach_thread_np(pthread_t); #endif /* __APPLE__ */ -#endif /* _KUL_OS_BSD_DEF_HPP_ */ +#endif /* _MKN_KUL_OS_BSD_DEF_HPP_ */ diff --git a/inc/kul/os/bsd/proc.os.hpp b/inc/mkn/kul/os/bsd/proc.os.hpp similarity index 93% rename from inc/kul/os/bsd/proc.os.hpp rename to inc/mkn/kul/os/bsd/proc.os.hpp index a1ee1fa..0bf0c29 100644 --- a/inc/kul/os/bsd/proc.os.hpp +++ b/inc/mkn/kul/os/bsd/proc.os.hpp @@ -28,10 +28,10 @@ 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. */ -// IWYU pragma: private, include "kul/proc.hpp" +// IWYU pragma: private, include "mkn/kul/proc.hpp" -#ifndef _KUL_OS_BSD_PROC_OS_HPP_ -#define _KUL_OS_BSD_PROC_OS_HPP_ +#ifndef _MKN_KUL_OS_BSD_PROC_OS_HPP_ +#define _MKN_KUL_OS_BSD_PROC_OS_HPP_ #include #include @@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #endif +namespace mkn { namespace kul { namespace this_proc { class MemGetter { @@ -95,4 +96,5 @@ inline uint64_t totalMemory() { inline uint16_t cpuLoad() { return 0; } } // namespace this_proc } // namespace kul -#endif /* _KUL_OS_BSD_PROC_OS_HPP_ */ +} // namespace mkn +#endif /* _MKN_KUL_OS_BSD_PROC_OS_HPP_ */ diff --git a/inc/kul/os/cli.hpp b/inc/mkn/kul/os/cli.hpp similarity index 86% rename from inc/kul/os/cli.hpp rename to inc/mkn/kul/os/cli.hpp index 6c97d5e..8f99a41 100644 --- a/inc/kul/os/cli.hpp +++ b/inc/mkn/kul/os/cli.hpp @@ -28,17 +28,17 @@ 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. */ -// IWYU pragma: private, include "kul/cli.hpp" +// IWYU pragma: private, include "mkn/kul/cli.hpp" -#ifndef _KUL_OS_CLI_HPP_ -#define _KUL_OS_CLI_HPP_ +#ifndef _MKN_KUL_OS_CLI_HPP_ +#define _MKN_KUL_OS_CLI_HPP_ -#include "kul/defs.hpp" +#include "mkn/kul/defs.hpp" #if defined(_WIN32) -#include "kul/os/win/cli.os.hpp" +#include "mkn/kul/os/win/cli.os.hpp" #else -#include "kul/os/nixish/cli.os.hpp" +#include "mkn/kul/os/nixish/cli.os.hpp" #endif -#endif // _KUL_OS_CLI_HPP_ \ No newline at end of file +#endif // _MKN_KUL_OS_CLI_HPP_ \ No newline at end of file diff --git a/inc/kul/os/def.hpp b/inc/mkn/kul/os/def.hpp similarity index 86% rename from inc/kul/os/def.hpp rename to inc/mkn/kul/os/def.hpp index 0b4d219..4e91caf 100644 --- a/inc/kul/os/def.hpp +++ b/inc/mkn/kul/os/def.hpp @@ -28,19 +28,19 @@ 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. */ -// IWYU pragma: private, include "kul/defs.hpp" +// IWYU pragma: private, include "mkn/kul/defs.hpp" -#ifndef _KUL_OS_DEF_HPP_ -#define _KUL_OS_DEF_HPP_ +#ifndef _MKN_KUL_OS_DEF_HPP_ +#define _MKN_KUL_OS_DEF_HPP_ #if KUL_IS_NIX -#include "kul/os/nix/def.hpp" +#include "mkn/kul/os/nix/def.hpp" #elif KUL_IS_BSD -#include "kul/os/bsd/def.hpp" +#include "mkn/kul/os/bsd/def.hpp" #elif KUL_IS_WIN -#include "kul/os/win/def.hpp" +#include "mkn/kul/os/win/def.hpp" #else #error unresolved #endif -#endif // _KUL_OS_DEF_HPP_ +#endif // _MKN_KUL_OS_DEF_HPP_ diff --git a/inc/kul/os/nix/cpu.hpp b/inc/mkn/kul/os/nix/cpu.hpp similarity index 90% rename from inc/kul/os/nix/cpu.hpp rename to inc/mkn/kul/os/nix/cpu.hpp index 9fdc833..4cf0a3a 100644 --- a/inc/kul/os/nix/cpu.hpp +++ b/inc/mkn/kul/os/nix/cpu.hpp @@ -28,10 +28,10 @@ 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. */ -// IWYU pragma: private, include "kul/cpu.hpp" +// IWYU pragma: private, include "mkn/kul/cpu.hpp" -#ifndef _KUL_OS_NIX_CPU_HPP_ -#define _KUL_OS_NIX_CPU_HPP_ +#ifndef _MKN_KUL_OS_NIX_CPU_HPP_ +#define _MKN_KUL_OS_NIX_CPU_HPP_ #include #include @@ -44,11 +44,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +namespace mkn { namespace kul { namespace cpu { inline uint32_t cores() { return sysconf(_SC_NPROCESSORS_ONLN); } inline uint16_t threads() { return std::thread::hardware_concurrency(); } } // namespace cpu } // namespace kul +} // namespace mkn -#endif /* _KUL_OS_NIX_CPU_HPP_ */ +#endif /* _MKN_KUL_OS_NIX_CPU_HPP_ */ diff --git a/inc/kul/os/nix/def.hpp b/inc/mkn/kul/os/nix/def.hpp similarity index 79% rename from inc/kul/os/nix/def.hpp rename to inc/mkn/kul/os/nix/def.hpp index e8c0a84..d931167 100644 --- a/inc/kul/os/nix/def.hpp +++ b/inc/mkn/kul/os/nix/def.hpp @@ -28,19 +28,19 @@ 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. */ -// IWYU pragma: private, include "kul/defs.hpp" +// IWYU pragma: private, include "mkn/kul/defs.hpp" -#ifndef _KUL_OS_NIX_DEF_HPP_ -#define _KUL_OS_NIX_DEF_HPP_ +#ifndef _MKN_KUL_OS_NIX_DEF_HPP_ +#define _MKN_KUL_OS_NIX_DEF_HPP_ -#include "kul/defs.hpp" +#include "mkn/kul/defs.hpp" -#ifndef __KUL_OS__ -#define __KUL_OS__ nix -#endif /* __KUL_OS__ */ +#ifndef __MKN_KUL_OS__ +#define __MKN_KUL_OS__ nix +#endif /* __MKN_KUL_OS__ */ -#ifndef __KUL_THREAD_SPAWN_WAIT__ -#define __KUL_THREAD_SPAWN_WAIT__ 10000000 -#endif /* __KUL_THREAD_SPAWN_WAIT__ */ +#ifndef __MKN_KUL_THREAD_SPAWN_WAIT__ +#define __MKN_KUL_THREAD_SPAWN_WAIT__ 10000000 +#endif /* __MKN_KUL_THREAD_SPAWN_WAIT__ */ -#endif /* _KUL_OS_NIX_DEF_HPP_ */ +#endif /* _MKN_KUL_OS_NIX_DEF_HPP_ */ diff --git a/inc/kul/os/nix/proc.os.hpp b/inc/mkn/kul/os/nix/proc.os.hpp similarity index 86% rename from inc/kul/os/nix/proc.os.hpp rename to inc/mkn/kul/os/nix/proc.os.hpp index 7a28ebd..21fae9a 100644 --- a/inc/kul/os/nix/proc.os.hpp +++ b/inc/mkn/kul/os/nix/proc.os.hpp @@ -28,10 +28,10 @@ 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. */ -// IWYU pragma: private, include "kul/proc.hpp" +// IWYU pragma: private, include "mkn/kul/proc.hpp" -#ifndef _KUL_OS_NIX_PROC_OS_HPP_ -#define _KUL_OS_NIX_PROC_OS_HPP_ +#ifndef _MKN_KUL_OS_NIX_PROC_OS_HPP_ +#define _MKN_KUL_OS_NIX_PROC_OS_HPP_ #include #include @@ -42,6 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +namespace mkn { namespace kul { namespace this_proc { @@ -75,11 +76,12 @@ inline uint64_t totalMemory() { inline uint16_t cpuLoad() { return 0; } } // namespace this_proc } // namespace kul +} // namespace mkn -#ifndef _KUL_COMPILED_LIB_ -#include "kul/os/nix/src/proc//xparse_line.ipp" -#include "kul/os/nix/src/proc//xphysical.ipp" -#include "kul/os/nix/src/proc//xvirtual.ipp" +#ifndef _MKN_KUL_COMPILED_LIB_ +#include "mkn/kul/os/nix/src/proc//xparse_line.ipp" +#include "mkn/kul/os/nix/src/proc//xphysical.ipp" +#include "mkn/kul/os/nix/src/proc//xvirtual.ipp" #endif -#endif /* _KUL_OS_NIX_PROC_OS_HPP_ */ +#endif /* _MKN_KUL_OS_NIX_PROC_OS_HPP_ */ diff --git a/inc/kul/os/nix/src/proc/xparse_line.ipp b/inc/mkn/kul/os/nix/src/proc/xparse_line.ipp similarity index 93% rename from inc/kul/os/nix/src/proc/xparse_line.ipp rename to inc/mkn/kul/os/nix/src/proc/xparse_line.ipp index 528deee..40ea0e5 100644 --- a/inc/kul/os/nix/src/proc/xparse_line.ipp +++ b/inc/mkn/kul/os/nix/src/proc/xparse_line.ipp @@ -28,9 +28,9 @@ 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. */ -// IWYU pragma: private, include "kul/proc.hpp" +// IWYU pragma: private, include "mkn/kul/proc.hpp" -int kul::this_proc::ProcParser::PARSE_LINE(char* line) { +int mkn::kul::this_proc::ProcParser::PARSE_LINE(char* line) { int i = strlen(line); while (*line < '0' || *line > '9') line++; line[i - 3] = '\0'; diff --git a/inc/kul/os/nix/src/proc/xphysical.ipp b/inc/mkn/kul/os/nix/src/proc/xphysical.ipp similarity index 93% rename from inc/kul/os/nix/src/proc/xphysical.ipp rename to inc/mkn/kul/os/nix/src/proc/xphysical.ipp index a0b90b6..e13cf66 100644 --- a/inc/kul/os/nix/src/proc/xphysical.ipp +++ b/inc/mkn/kul/os/nix/src/proc/xphysical.ipp @@ -28,9 +28,9 @@ 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. */ -// IWYU pragma: private, include "kul/proc.hpp" +// IWYU pragma: private, include "mkn/kul/proc.hpp" -void kul::this_proc::ProcParser::PHYSICAL(uint64_t& mem) { +void mkn::kul::this_proc::ProcParser::PHYSICAL(uint64_t& mem) { FILE* file = fopen("/proc/self/status", "r"); char line[128]; while (fgets(line, 128, file) != NULL) { diff --git a/inc/kul/os/nix/src/proc/xvirtual.ipp b/inc/mkn/kul/os/nix/src/proc/xvirtual.ipp similarity index 93% rename from inc/kul/os/nix/src/proc/xvirtual.ipp rename to inc/mkn/kul/os/nix/src/proc/xvirtual.ipp index d2b682c..da9e4ce 100644 --- a/inc/kul/os/nix/src/proc/xvirtual.ipp +++ b/inc/mkn/kul/os/nix/src/proc/xvirtual.ipp @@ -28,9 +28,9 @@ 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. */ -// IWYU pragma: private, include "kul/proc.hpp" +// IWYU pragma: private, include "mkn/kul/proc.hpp" -void kul::this_proc::ProcParser::VIRTUAL(uint64_t& mem) { +void mkn::kul::this_proc::ProcParser::VIRTUAL(uint64_t& mem) { FILE* file = fopen("/proc/self/status", "r"); char line[128]; while (fgets(line, 128, file) != NULL) { diff --git a/inc/kul/os/nixish/cli.os.hpp b/inc/mkn/kul/os/nixish/cli.os.hpp similarity index 85% rename from inc/kul/os/nixish/cli.os.hpp rename to inc/mkn/kul/os/nixish/cli.os.hpp index 6206f4a..ec9311f 100644 --- a/inc/kul/os/nixish/cli.os.hpp +++ b/inc/mkn/kul/os/nixish/cli.os.hpp @@ -28,13 +28,14 @@ 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. */ -#ifndef _KUL_OS_NIXISH_CLI_OS_HPP_ -#define _KUL_OS_NIXISH_CLI_OS_HPP_ +#ifndef _MKN_KUL_OS_NIXISH_CLI_OS_HPP_ +#define _MKN_KUL_OS_NIXISH_CLI_OS_HPP_ #include #include #include +namespace mkn { namespace kul { namespace cli { @@ -43,10 +44,11 @@ inline void show(); } // namespace cli } // namespace kul +} // namespace mkn -#ifndef _KUL_COMPILED_LIB_ -#include "kul/os/nixish/src/cli/hidden.ipp" -#include "kul/os/nixish/src/cli/show.ipp" +#ifndef _MKN_KUL_COMPILED_LIB_ +#include "mkn/kul/os/nixish/src/cli/hidden.ipp" +#include "mkn/kul/os/nixish/src/cli/show.ipp" #endif -#endif /* _KUL_OS_NIXISH_CLI_OS_HPP_ */ +#endif /* _MKN_KUL_OS_NIXISH_CLI_OS_HPP_ */ diff --git a/inc/kul/os/nixish/env.hpp b/inc/mkn/kul/os/nixish/env.hpp similarity index 88% rename from inc/kul/os/nixish/env.hpp rename to inc/mkn/kul/os/nixish/env.hpp index 776bf68..d13bb48 100644 --- a/inc/kul/os/nixish/env.hpp +++ b/inc/mkn/kul/os/nixish/env.hpp @@ -28,10 +28,10 @@ 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. */ -// IWYU pragma: private, include "kul/env.hpp" +// IWYU pragma: private, include "mkn/kul/env.hpp" -#ifndef _KUL_OS_NIXISH_ENV_HPP_ -#define _KUL_OS_NIXISH_ENV_HPP_ +#ifndef _MKN_KUL_OS_NIXISH_ENV_HPP_ +#define _MKN_KUL_OS_NIXISH_ENV_HPP_ #include #include @@ -46,18 +46,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include +namespace mkn { namespace kul { namespace env { inline std::string EOL() { return "\r\n"; } -#if defined(_KUL_MAX_PATH_) -constexpr size_t KUL_MAX_PATH = _KUL_MAX_PATH_; +#if defined(_MKN_KUL_MAX_PATH_) +constexpr size_t KUL_MAX_PATH = _MKN_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_*/ +#endif /*_MKN_KUL_MAX_PATH_*/ inline bool EXISTS(char const *c) { return getenv(c); } inline std::string GET(char const *c) { @@ -79,5 +80,6 @@ inline bool CWD(std::string const &c) { return chdir(c.c_str()) != -1; } } // namespace env } // namespace kul +} // namespace mkn -#endif /* _KUL_OS_NIXISH_ENV_HPP_ */ +#endif /* _MKN_KUL_OS_NIXISH_ENV_HPP_ */ diff --git a/inc/kul/os/nixish/ipc.hpp b/inc/mkn/kul/os/nixish/ipc.hpp similarity index 78% rename from inc/kul/os/nixish/ipc.hpp rename to inc/mkn/kul/os/nixish/ipc.hpp index 772cb21..831c7fe 100644 --- a/inc/kul/os/nixish/ipc.hpp +++ b/inc/mkn/kul/os/nixish/ipc.hpp @@ -28,17 +28,17 @@ 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. */ -// IWYU pragma: private, include "kul/ipc.hpp" +// IWYU pragma: private, include "mkn/kul/ipc.hpp" -#ifndef _KUL_OS_NIXISH_IPC_HPP_ -#define _KUL_OS_NIXISH_IPC_HPP_ +#ifndef _MKN_KUL_OS_NIXISH_IPC_HPP_ +#define _MKN_KUL_OS_NIXISH_IPC_HPP_ -#ifndef _KUL_IPC_UUID_PREFIX_ -#define _KUL_IPC_UUID_PREFIX_ "/tmp/pipe" +#ifndef _MKN_KUL_IPC_UUID_PREFIX_ +#define _MKN_KUL_IPC_UUID_PREFIX_ "/tmp/pipe" #endif -#include "kul/log.hpp" -#include "kul/proc.hpp" +#include "mkn/kul/log.hpp" +#include "mkn/kul/proc.hpp" #include #include @@ -49,12 +49,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define BUFSIZE 512 +namespace mkn { namespace kul { namespace ipc { -class Exception : public kul::Exception { +class Exception : public mkn::kul::Exception { public: - Exception(char const *f, uint16_t const &l, std::string const &s) : kul::Exception(f, l, s) {} + Exception(char const *f, uint16_t const &l, std::string const &s) : mkn::kul::Exception(f, l, s) {} }; class IPCCall { @@ -74,7 +75,7 @@ class IPCCall { class Server : public IPCCall { private: int16_t lp; - const kul::File uuid; + const mkn::kul::File uuid; void start() KTHROW(Exception) { uuid.dir().mk(); @@ -92,7 +93,7 @@ class Server : public IPCCall { while (lp) { memset(buff, 0, BUFSIZE); fd = open(uuid.full().c_str(), O_RDONLY); - if (fd == -1) KEXCEPT(kul::ipc::Exception, "Cannot open FIFO for read"); + if (fd == -1) KEXCEPT(mkn::kul::ipc::Exception, "Cannot open FIFO for read"); int16_t l; read(fd, buff, 3); std::istringstream ssl(buff); @@ -106,33 +107,33 @@ class Server : public IPCCall { } Server(const int16_t &_lp = -1) KTHROW(Exception) : lp(_lp), - uuid(std::to_string(kul::this_proc::id()), - Dir(_KUL_IPC_UUID_PREFIX_ + std::string("/pid/"))) { + uuid(std::to_string(mkn::kul::this_proc::id()), + Dir(_MKN_KUL_IPC_UUID_PREFIX_ + std::string("/pid/"))) { start(); } Server(std::string const &ui, const int16_t &_lp = -1) KTHROW(Exception) - : lp(_lp), uuid(ui, Dir(_KUL_IPC_UUID_PREFIX_)) { + : lp(_lp), uuid(ui, Dir(_MKN_KUL_IPC_UUID_PREFIX_)) { start(); } }; class Client : public IPCCall { private: - const kul::File uuid; + const mkn::kul::File uuid; void start() KTHROW(Exception) { fd = open(uuid.full().c_str(), O_WRONLY); - if (fd == -1) KEXCEPT(kul::ipc::Exception, "Cannot contact server"); + if (fd == -1) KEXCEPT(mkn::kul::ipc::Exception, "Cannot contact server"); } void stop() const KTHROW(Exception) { close(fd); } public: virtual ~Client() { stop(); } - Client(std::string const &ui) KTHROW(Exception) : uuid(ui, Dir(_KUL_IPC_UUID_PREFIX_)) { + Client(std::string const &ui) KTHROW(Exception) : uuid(ui, Dir(_MKN_KUL_IPC_UUID_PREFIX_)) { start(); } Client(const int16_t &pid) KTHROW(Exception) - : uuid(std::to_string(pid), Dir(_KUL_IPC_UUID_PREFIX_ + std::string("/pid/"))) { + : uuid(std::to_string(pid), Dir(_MKN_KUL_IPC_UUID_PREFIX_ + std::string("/pid/"))) { start(); } virtual void send(std::string const &m) const KTHROW(Exception) { @@ -143,5 +144,6 @@ class Client : public IPCCall { } // namespace ipc } // namespace kul +} // namespace mkn -#endif /* _KUL_OS_NIXISH_IPC_HPP_ */ +#endif /* _MKN_KUL_OS_NIXISH_IPC_HPP_ */ diff --git a/inc/kul/os/nixish/os.bot.hpp b/inc/mkn/kul/os/nixish/os.bot.hpp similarity index 70% rename from inc/kul/os/nixish/os.bot.hpp rename to inc/mkn/kul/os/nixish/os.bot.hpp index c9e652e..854c817 100644 --- a/inc/kul/os/nixish/os.bot.hpp +++ b/inc/mkn/kul/os/nixish/os.bot.hpp @@ -28,12 +28,12 @@ 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. */ -// IWYU pragma: private, include "kul/os.hpp" +// IWYU pragma: private, include "mkn/kul/os.hpp" -#ifndef _KUL_OS_NIXISH_OS_BOT_HPP_ -#define _KUL_OS_NIXISH_OS_BOT_HPP_ +#ifndef _MKN_KUL_OS_NIXISH_OS_BOT_HPP_ +#define _MKN_KUL_OS_NIXISH_OS_BOT_HPP_ -void kul::Dir::rm() const { +void mkn::kul::Dir::rm() const { if (is()) { for (const auto &a : files()) a.rm(); for (const auto &a : dirs()) a.rm(); @@ -41,56 +41,57 @@ void kul::Dir::rm() const { } } -std::string kul::Dir::LOCL(std::string s) { - kul::String::REPLACE_ALL(s, "\\", "/"); +std::string mkn::kul::Dir::LOCL(std::string s) { + mkn::kul::String::REPLACE_ALL(s, "\\", "/"); return s; } -std::string kul::Dir::ESC(std::string s) { +std::string mkn::kul::Dir::ESC(std::string s) { ESC_REPLACE(s, " ", "\\ "); return s; } -bool kul::Dir::is() const { +bool mkn::kul::Dir::is() const { if (path().empty()) return false; DIR *d = opendir(path().c_str()); if (d) closedir(d); return d; } -bool kul::Dir::mk() const { +bool mkn::kul::Dir::mk() const { if (path().empty()) return false; - kul::Dir const &prnt(parent()); + mkn::kul::Dir const &prnt(parent()); if (_p != prnt.path() && !prnt.is()) parent().mk(); return mkdir(locl().c_str(), 0777) == 0; } -bool kul::Dir::root() const { return is() && real().size() == 1; } +bool mkn::kul::Dir::root() const { return is() && real().size() == 1; } -bool kul::File::is() const { +bool mkn::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); return 0; } -bool kul::File::rm() const { +bool mkn::kul::File::rm() const { if (is()) { remove(real().c_str()); return true; } return false; } -bool kul::File::mk() const { +bool mkn::kul::File::mk() const { FILE *pFile = fopen(full().c_str(), "w"); if (pFile != NULL) { fclose(pFile); } return pFile != NULL; } -uint64_t kul::File::size() const { +uint64_t mkn::kul::File::size() const { uint64_t r = 0; struct stat att; if (stat(mini().c_str(), &att) != -1) r = att.st_size; return r; } +namespace mkn { namespace kul { namespace os { @@ -109,20 +110,21 @@ inline std::string EOL() { return "\n"; } namespace user { -inline kul::Dir home() { return Dir(env::GET("HOME")); } -inline kul::Dir home(std::string const &app) { return Dir(Dir::JOIN(env::GET("HOME"), "." + app)); } +inline mkn::kul::Dir home() { return Dir(env::GET("HOME")); } +inline mkn::kul::Dir home(std::string const &app) { return Dir(Dir::JOIN(env::GET("HOME"), "." + app)); } } // namespace user namespace env { -inline bool CWD(kul::Dir const &d) { return chdir(d.path().c_str()) != -1; } +inline bool CWD(mkn::kul::Dir const &d) { return chdir(d.path().c_str()) != -1; } } // namespace env } // namespace kul +} // namespace mkn -#ifndef _KUL_COMPILED_LIB_ -#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_ +#ifndef _MKN_KUL_COMPILED_LIB_ +#include "mkn/kul/os/nixish/src/os/dir/dirs.ipp" +#include "mkn/kul/os/nixish/src/os/dir/files.ipp" +#include "mkn/kul/os/nixish/src/os/dir/real.ipp" +#endif //_MKN_KUL_COMPILED_LIB_ -#endif /* _KUL_OS_NIXISH_OS_BOT_HPP_ */ +#endif /* _MKN_KUL_OS_NIXISH_OS_BOT_HPP_ */ diff --git a/inc/kul/os/nixish/os.top.hpp b/inc/mkn/kul/os/nixish/os.top.hpp similarity index 89% rename from inc/kul/os/nixish/os.top.hpp rename to inc/mkn/kul/os/nixish/os.top.hpp index dd0caeb..4bdd77a 100644 --- a/inc/kul/os/nixish/os.top.hpp +++ b/inc/mkn/kul/os/nixish/os.top.hpp @@ -28,10 +28,10 @@ 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. */ -// IWYU pragma: private, include "kul/os.hpp" +// IWYU pragma: private, include "mkn/kul/os.hpp" -#ifndef _KUL_OS_NIXISH_OS_TOP_HPP_ -#define _KUL_OS_NIXISH_OS_TOP_HPP_ +#ifndef _MKN_KUL_OS_NIXISH_OS_TOP_HPP_ +#define _MKN_KUL_OS_NIXISH_OS_TOP_HPP_ #include #include @@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +namespace mkn { namespace kul { class Dir; @@ -59,10 +60,11 @@ class KulTimeStampsResolver { c = 0; // doesn't exist on this platform } } - friend class kul::Dir; + friend class mkn::kul::Dir; }; } // namespace fs } // namespace kul +} // namespace mkn -#endif /* _KUL_OS_NIXISH_OS_TOP_HPP_ */ +#endif /* _MKN_KUL_OS_NIXISH_OS_TOP_HPP_ */ diff --git a/inc/kul/os/nixish/proc.hpp b/inc/mkn/kul/os/nixish/proc.hpp similarity index 65% rename from inc/kul/os/nixish/proc.hpp rename to inc/mkn/kul/os/nixish/proc.hpp index bb533ce..ecc4bef 100644 --- a/inc/kul/os/nixish/proc.hpp +++ b/inc/mkn/kul/os/nixish/proc.hpp @@ -28,39 +28,40 @@ 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. */ -// IWYU pragma: private, include "kul/proc.hpp" +// IWYU pragma: private, include "mkn/kul/proc.hpp" -#ifndef _KUL_OS_NIXISH_PROC_HPP_ -#define _KUL_OS_NIXISH_PROC_HPP_ +#ifndef _MKN_KUL_OS_NIXISH_PROC_HPP_ +#define _MKN_KUL_OS_NIXISH_PROC_HPP_ #include #include #include #include -#include "kul/log.hpp" -#include "kul/os.hpp" +#include "mkn/kul/log.hpp" +#include "mkn/kul/os.hpp" #if KUL_IS_NIX -#include "kul/os/nix/proc.os.hpp" +#include "mkn/kul/os/nix/proc.os.hpp" #elif KUL_IS_BSD -#include "kul/os/bsd/proc.os.hpp" +#include "mkn/kul/os/bsd/proc.os.hpp" #else #error unresolved #endif -#ifndef __KUL_PROC_DUP_RETRY__ -#define __KUL_PROC_DUP_RETRY__ 3 -#endif //__KUL_PROC_DUP_RETRY__ +#ifndef __MKN_KUL_PROC_DUP_RETRY__ +#define __MKN_KUL_PROC_DUP_RETRY__ 3 +#endif //__MKN_KUL_PROC_DUP_RETRY__ +namespace mkn { namespace kul { namespace this_proc { inline int32_t id() { return getpid(); } -inline void kill(const int32_t &e) { ::kill(kul::this_proc::id(), e); } +inline void kill(const int32_t &e) { ::kill(mkn::kul::this_proc::id(), e); } } // namespace this_proc -class Process : public kul::AProcess { +class Process : public mkn::kul::AProcess { private: int inFd[2], outFd[2], errFd[2], popPip[3]; int cStat; // child status @@ -73,11 +74,11 @@ class Process : public kul::AProcess { } public: - Process(std::string const &cmd, const bool &_wfe = true) : kul::AProcess(cmd, _wfe) {} + Process(std::string const &cmd, const bool &_wfe = true) : mkn::kul::AProcess(cmd, _wfe) {} Process(std::string const &cmd, std::string const &path, const bool &_wfe = true) - : kul::AProcess(cmd, path, _wfe) {} - Process(std::string const &cmd, kul::Dir const &_d, const bool &_wfe = true) - : kul::AProcess(cmd, (_d ? _d.real() : _d.path()), _wfe) {} + : mkn::kul::AProcess(cmd, path, _wfe) {} + Process(std::string const &cmd, mkn::kul::Dir const &_d, const bool &_wfe = true) + : mkn::kul::AProcess(cmd, (_d ? _d.real() : _d.path()), _wfe) {} bool kill(int16_t k = 6) { if (started()) { bool b = ::kill(pid(), k) == 0; @@ -91,22 +92,23 @@ class Process : public kul::AProcess { int16_t inline child(); virtual void inline expand(std::string &) const; void inline waitForStatus(); - void inline waitExit() KTHROW(kul::proc::ExitException); + void inline waitExit() KTHROW(mkn::kul::proc::ExitException); void inline tearDown(); - void inline run() KTHROW(kul::proc::Exception); + void inline run() KTHROW(mkn::kul::proc::Exception); virtual void finish() {} virtual void preStart() {} }; } // 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/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" +} // namespace mkn + +#ifndef _MKN_KUL_COMPILED_LIB_ +#include "mkn/kul/os/nixish/src/proc/child.ipp" +#include "mkn/kul/os/nixish/src/proc/expand.ipp" +#include "mkn/kul/os/nixish/src/proc/run.ipp" +#include "mkn/kul/os/nixish/src/proc/tearDown.ipp" +#include "mkn/kul/os/nixish/src/proc/waitExit.ipp" +#include "mkn/kul/os/nixish/src/proc/waitForStatus.ipp" #endif -#endif /* _KUL_OS_NIXISH_PROC_HPP_ */ +#endif /* _MKN_KUL_OS_NIXISH_PROC_HPP_ */ diff --git a/inc/kul/os/nixish/signal.hpp b/inc/mkn/kul/os/nixish/signal.hpp similarity index 80% rename from inc/kul/os/nixish/signal.hpp rename to inc/mkn/kul/os/nixish/signal.hpp index 611224a..eb48cac 100644 --- a/inc/kul/os/nixish/signal.hpp +++ b/inc/mkn/kul/os/nixish/signal.hpp @@ -28,14 +28,14 @@ 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. */ -// IWYU pragma: private, include "kul/signal.hpp" +// IWYU pragma: private, include "mkn/kul/signal.hpp" -#ifndef _KUL_OS_NIXISH_SIGNAL_HPP_ -#define _KUL_OS_NIXISH_SIGNAL_HPP_ +#ifndef _MKN_KUL_OS_NIXISH_SIGNAL_HPP_ +#define _MKN_KUL_OS_NIXISH_SIGNAL_HPP_ -#include "kul/defs.hpp" -#include "kul/log.hpp" -#include "kul/proc.hpp" +#include "mkn/kul/defs.hpp" +#include "mkn/kul/log.hpp" +#include "mkn/kul/proc.hpp" #include @@ -69,9 +69,10 @@ 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 mkn { namespace kul { namespace this_thread { -#include "kul/os/nixish/src/signal/stacktrace.ipp" +#include "mkn/kul/os/nixish/src/signal/stacktrace.ipp" inline void print_stacktrace() { for (auto const &s : stacktrace()) std::cout << s << std::endl; @@ -85,8 +86,8 @@ class SignalStatic { struct sigaction sigHandler; std::vector> ab, in, se; SignalStatic() { - addr = kul::env::WHICH("addr2line"); - euaddr = kul::env::WHICH("eu-addr2line"); + addr = mkn::kul::env::WHICH("addr2line"); + euaddr = mkn::kul::env::WHICH("eu-addr2line"); sigemptyset(&sigHandler.sa_mask); sigHandler.sa_flags = SA_SIGINFO; sigHandler.sa_sigaction = kul_sig_handler; @@ -113,26 +114,27 @@ class SignalStatic { class Signal { public: - Signal() { kul::SignalStatic::INSTANCE(); } + Signal() { mkn::kul::SignalStatic::INSTANCE(); } Signal &abrt(const std::function &f) { - kul::SignalStatic::INSTANCE().abrt(f); + mkn::kul::SignalStatic::INSTANCE().abrt(f); return *this; } Signal &intr(const std::function &f) { - kul::SignalStatic::INSTANCE().intr(f); + mkn::kul::SignalStatic::INSTANCE().intr(f); return *this; } Signal &segv(const std::function &f) { - kul::SignalStatic::INSTANCE().se.push_back(f); + mkn::kul::SignalStatic::INSTANCE().se.push_back(f); return *this; } - void quiet() { kul::SignalStatic::INSTANCE().q = 1; } + void quiet() { mkn::kul::SignalStatic::INSTANCE().q = 1; } }; } // namespace kul +} // namespace mkn -#ifndef _KUL_COMPILED_LIB_ -#include "kul/os/nixish/src/signal/handler.ipp" +#ifndef _MKN_KUL_COMPILED_LIB_ +#include "mkn/kul/os/nixish/src/signal/handler.ipp" #endif -#endif /* _KUL_OS_NIXISH_SIGNAL_HPP_ */ +#endif /* _MKN_KUL_OS_NIXISH_SIGNAL_HPP_ */ diff --git a/inc/kul/os/nixish/src/cli/hidden.ipp b/inc/mkn/kul/os/nixish/src/cli/hidden.ipp similarity index 94% rename from inc/kul/os/nixish/src/cli/hidden.ipp rename to inc/mkn/kul/os/nixish/src/cli/hidden.ipp index e072af6..1a926f0 100644 --- a/inc/kul/os/nixish/src/cli/hidden.ipp +++ b/inc/mkn/kul/os/nixish/src/cli/hidden.ipp @@ -28,9 +28,9 @@ 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. */ -// IWYU pragma: private, include "kul/cli.hpp" +// IWYU pragma: private, include "mkn/kul/cli.hpp" -std::string kul::cli::hidden(const std::string& t) { +std::string mkn::kul::cli::hidden(const std::string& t) { if (!t.empty()) std::cout << t << std::endl; termios oldt; tcgetattr(STDIN_FILENO, &oldt); diff --git a/inc/kul/os/nixish/src/cli/show.ipp b/inc/mkn/kul/os/nixish/src/cli/show.ipp similarity index 95% rename from inc/kul/os/nixish/src/cli/show.ipp rename to inc/mkn/kul/os/nixish/src/cli/show.ipp index 4671624..7aca08d 100644 --- a/inc/kul/os/nixish/src/cli/show.ipp +++ b/inc/mkn/kul/os/nixish/src/cli/show.ipp @@ -28,9 +28,9 @@ 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. */ -// IWYU pragma: private, include "kul/cli.hpp" +// IWYU pragma: private, include "mkn/kul/cli.hpp" -void kul::cli::show() { +void mkn::kul::cli::show() { termios tty; tcgetattr(STDIN_FILENO, &tty); tty.c_lflag |= ECHO; diff --git a/inc/kul/os/nixish/src/os/dir/dirs.ipp b/inc/mkn/kul/os/nixish/src/os/dir/dirs.ipp similarity index 90% rename from inc/kul/os/nixish/src/os/dir/dirs.ipp rename to inc/mkn/kul/os/nixish/src/os/dir/dirs.ipp index e39bef7..24949a9 100644 --- a/inc/kul/os/nixish/src/os/dir/dirs.ipp +++ b/inc/mkn/kul/os/nixish/src/os/dir/dirs.ipp @@ -28,9 +28,9 @@ 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. */ -// IWYU pragma: private, include "kul/os.hpp" +// IWYU pragma: private, include "mkn/kul/os.hpp" -std::vector kul::Dir::dirs(bool incHidden) const KTHROW(fs::Exception) { +std::vector mkn::kul::Dir::dirs(bool incHidden) const KTHROW(fs::Exception) { if (!is()) KEXCEPT(fs::Exception, "Directory : \"" + path() + "\" does not exist"); std::vector dirs; @@ -38,7 +38,7 @@ std::vector kul::Dir::dirs(bool incHidden) const KTHROW(fs::Exception) struct dirent *entry = readdir(dir); while (entry != NULL) { std::string d(entry->d_name); - kul::Dir dd(JOIN(real(), entry->d_name)); + mkn::kul::Dir dd(JOIN(real(), entry->d_name)); if (d.compare(".") != 0 && d.compare("..") != 0 && !(d.substr(0, 1).compare(".") == 0 && !incHidden) && dd.is()) dirs.push_back(dd); diff --git a/inc/kul/os/nixish/src/os/dir/files.ipp b/inc/mkn/kul/os/nixish/src/os/dir/files.ipp similarity index 84% rename from inc/kul/os/nixish/src/os/dir/files.ipp rename to inc/mkn/kul/os/nixish/src/os/dir/files.ipp index 50aa702..e07551f 100644 --- a/inc/kul/os/nixish/src/os/dir/files.ipp +++ b/inc/mkn/kul/os/nixish/src/os/dir/files.ipp @@ -28,22 +28,22 @@ 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. */ -// IWYU pragma: private, include "kul/os.hpp" +// IWYU pragma: private, include "mkn/kul/os.hpp" -std::vector kul::Dir::files(bool recursive) const KTHROW(fs::Exception) { +std::vector mkn::kul::Dir::files(bool recursive) const KTHROW(fs::Exception) { if (!is()) KEXCEPT(fs::Exception, "Directory : \"" + path() + "\" does not exist"); std::vector fs; DIR *dir = opendir(path().c_str()); struct dirent *entry = readdir(dir); while (entry != NULL) { - if (!kul::Dir(JOIN(real(), entry->d_name)).is()) fs.push_back(File(entry->d_name, *this)); + if ( !mkn::kul::Dir(JOIN(real(), entry->d_name)).is()) fs.push_back(File(entry->d_name, *this)); entry = readdir(dir); } closedir(dir); if (recursive) { - for (kul::Dir const &d : dirs()) { - const std::vector &tFs = d.files(true); + for (mkn::kul::Dir const &d : dirs()) { + const std::vector &tFs = d.files(true); fs.insert(fs.end(), tFs.begin(), tFs.end()); } } diff --git a/inc/kul/os/nixish/src/os/dir/real.ipp b/inc/mkn/kul/os/nixish/src/os/dir/real.ipp similarity index 93% rename from inc/kul/os/nixish/src/os/dir/real.ipp rename to inc/mkn/kul/os/nixish/src/os/dir/real.ipp index cd03406..327b611 100644 --- a/inc/kul/os/nixish/src/os/dir/real.ipp +++ b/inc/mkn/kul/os/nixish/src/os/dir/real.ipp @@ -28,9 +28,9 @@ 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. */ -// IWYU pragma: private, include "kul/os.hpp" +// IWYU pragma: private, include "mkn/kul/os.hpp" -std::string kul::Dir::REAL(const std::string& s) KTHROW(fs::Exception) { +std::string mkn::kul::Dir::REAL(const std::string& s) KTHROW(fs::Exception) { char* expanded = realpath(s.c_str(), NULL); if (expanded) { std::string dir(expanded); diff --git a/inc/kul/os/nixish/src/proc/child.ipp b/inc/mkn/kul/os/nixish/src/proc/child.ipp similarity index 91% rename from inc/kul/os/nixish/src/proc/child.ipp rename to inc/mkn/kul/os/nixish/src/proc/child.ipp index 676d27d..ba9dc6a 100644 --- a/inc/kul/os/nixish/src/proc/child.ipp +++ b/inc/mkn/kul/os/nixish/src/proc/child.ipp @@ -28,12 +28,12 @@ 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. */ -// IWYU pragma: private, include "kul/proc.hpp" +// IWYU pragma: private, include "mkn/kul/proc.hpp" -int16_t kul::Process::child() { +int16_t mkn::kul::Process::child() { std::string _s(toString()); expand(_s); - std::vector cli(kul::cli::asArgs(_s)); + std::vector cli(mkn::kul::cli::asArgs(_s)); std::vector argV; for (auto &a : cli) argV.push_back(&a[0]); argV.push_back(NULL); diff --git a/inc/kul/os/nixish/src/proc/expand.ipp b/inc/mkn/kul/os/nixish/src/proc/expand.ipp similarity index 87% rename from inc/kul/os/nixish/src/proc/expand.ipp rename to inc/mkn/kul/os/nixish/src/proc/expand.ipp index 39715c0..d26dcf2 100644 --- a/inc/kul/os/nixish/src/proc/expand.ipp +++ b/inc/mkn/kul/os/nixish/src/proc/expand.ipp @@ -28,9 +28,9 @@ 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. */ -// IWYU pragma: private, include "kul/proc.hpp" +// IWYU pragma: private, include "mkn/kul/proc.hpp" -void kul::Process::expand(std::string& _s) const { +void mkn::kul::Process::expand(std::string& _s) const { std::string r = _s; auto lb = _s.find("$("); auto clb = _s.find("\\$("); @@ -48,11 +48,11 @@ void kul::Process::expand(std::string& _s) const { if (rb == std::string::npos) return; std::string k(r.substr(lb + 2, rb - 2 - lb)); - std::vector cli(kul::cli::asArgs(k)); + std::vector cli(mkn::kul::cli::asArgs(k)); std::stringstream ss; if (cli.size() > 1) { - kul::Process p(cli[0]); - kul::ProcessCapture pc(p); + mkn::kul::Process p(cli[0]); + mkn::kul::ProcessCapture pc(p); for (size_t i = 1; i < cli.size(); i++) p.arg(cli[i]); p.start(); std::string out(pc.outs()); @@ -60,7 +60,7 @@ void kul::Process::expand(std::string& _s) const { std::string t(r.substr(0, lb) + out + r.substr(rb + 1)); ss << r.substr(0, lb) << out << r.substr(rb + 1); } else - ss << r.substr(0, lb) << kul::env::GET(cli[0].c_str()) << r.substr(rb + 1); + ss << r.substr(0, lb) << mkn::kul::env::GET(cli[0].c_str()) << r.substr(rb + 1); std::string t(ss.str()); expand(t); diff --git a/inc/kul/os/nixish/src/proc/run.ipp b/inc/mkn/kul/os/nixish/src/proc/run.ipp similarity index 92% rename from inc/kul/os/nixish/src/proc/run.ipp rename to inc/mkn/kul/os/nixish/src/proc/run.ipp index c52aba2..5418a6a 100644 --- a/inc/kul/os/nixish/src/proc/run.ipp +++ b/inc/mkn/kul/os/nixish/src/proc/run.ipp @@ -28,9 +28,9 @@ 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. */ -// IWYU pragma: private, include "kul/proc.hpp" +// IWYU pragma: private, include "mkn/kul/proc.hpp" -void kul::Process::run() KTHROW(kul::proc::Exception) { +void mkn::kul::Process::run() KTHROW(mkn::kul::proc::Exception) { { int16_t ret = 0; if ((ret = pipe(inFd)) < 0) error(__LINE__, "Failed to pipe in"); @@ -47,7 +47,7 @@ void kul::Process::run() KTHROW(kul::proc::Exception) { popPip[1] = outFd[0]; popPip[2] = errFd[0]; -#ifdef __KUL_PROC_BLOCK_ERR__ +#ifdef __MKN_KUL_PROC_BLOCK_ERR__ if ((ret = fcntl(popPip[1], F_SETFL, O_NONBLOCK)) < 0) error(__LINE__, "Failed nonblocking for popPip[1]"); if ((ret = fcntl(popPip[2], F_SETFL, O_NONBLOCK)) < 0) @@ -66,8 +66,8 @@ void kul::Process::run() KTHROW(kul::proc::Exception) { char cOut[30024] = {'\0'}; char cErr[30024] = {'\0'}; do { -#if defined(_KUL_PROC_LOOP_NSLEEP_) && (_KUL_PROC_LOOP_NSLEEP_ > 0) - kul::this_thread::nSleep(_KUL_PROC_LOOP_NSLEEP_); +#if defined(_MKN_KUL_PROC_LOOP_NSLEEP_) && (_MKN_KUL_PROC_LOOP_NSLEEP_ > 0) + mkn::kul::this_thread::nSleep(_MKN_KUL_PROC_LOOP_NSLEEP_); #endif alive = ::kill(pid(), 0) == 0; if (FD_ISSET(popPip[1], &childOutFds)) { @@ -113,7 +113,7 @@ void kul::Process::run() KTHROW(kul::proc::Exception) { close(errFd[0]); int16_t ret = 0; // check rets - int8_t retry = __KUL_PROC_DUP_RETRY__; + int8_t retry = __MKN_KUL_PROC_DUP_RETRY__; if (retry < 1) retry = 1; close(0); @@ -136,7 +136,7 @@ void kul::Process::run() KTHROW(kul::proc::Exception) { for (auto const &ev : vars()) env::SET(ev.first.c_str(), ev.second.c_str()); - if (!this->directory().empty()) kul::env::CWD(this->directory()); + if (!this->directory().empty()) mkn::kul::env::CWD(this->directory()); exit(this->child()); } else error(__LINE__, "Unhandled process id for child: " + std::to_string(pid())); diff --git a/inc/kul/os/nixish/src/proc/tearDown.ipp b/inc/mkn/kul/os/nixish/src/proc/tearDown.ipp similarity index 95% rename from inc/kul/os/nixish/src/proc/tearDown.ipp rename to inc/mkn/kul/os/nixish/src/proc/tearDown.ipp index 320fe72..ad5d484 100644 --- a/inc/kul/os/nixish/src/proc/tearDown.ipp +++ b/inc/mkn/kul/os/nixish/src/proc/tearDown.ipp @@ -28,9 +28,9 @@ 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. */ -// IWYU pragma: private, include "kul/proc.hpp" +// IWYU pragma: private, include "mkn/kul/proc.hpp" -void kul::Process::tearDown() { +void mkn::kul::Process::tearDown() { recall(close(popPip[0])); recall(close(popPip[1])); recall(close(popPip[2])); diff --git a/inc/kul/os/nixish/src/proc/waitExit.ipp b/inc/mkn/kul/os/nixish/src/proc/waitExit.ipp similarity index 92% rename from inc/kul/os/nixish/src/proc/waitExit.ipp rename to inc/mkn/kul/os/nixish/src/proc/waitExit.ipp index 73b9cf2..c370899 100644 --- a/inc/kul/os/nixish/src/proc/waitExit.ipp +++ b/inc/mkn/kul/os/nixish/src/proc/waitExit.ipp @@ -28,9 +28,9 @@ 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. */ -// IWYU pragma: private, include "kul/proc.hpp" +// IWYU pragma: private, include "mkn/kul/proc.hpp" -void kul::Process::waitExit() KTHROW(kul::proc::ExitException) { +void mkn::kul::Process::waitExit() KTHROW(mkn::kul::proc::ExitException) { tearDown(); exitCode(WEXITSTATUS(cStat)); finish(); diff --git a/inc/kul/os/nixish/src/proc/waitForStatus.ipp b/inc/mkn/kul/os/nixish/src/proc/waitForStatus.ipp similarity index 94% rename from inc/kul/os/nixish/src/proc/waitForStatus.ipp rename to inc/mkn/kul/os/nixish/src/proc/waitForStatus.ipp index 535405c..7433e87 100644 --- a/inc/kul/os/nixish/src/proc/waitForStatus.ipp +++ b/inc/mkn/kul/os/nixish/src/proc/waitForStatus.ipp @@ -28,9 +28,9 @@ 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. */ -// IWYU pragma: private, include "kul/proc.hpp" +// IWYU pragma: private, include "mkn/kul/proc.hpp" -void kul::Process::waitForStatus() { +void mkn::kul::Process::waitForStatus() { int16_t ret = 0; ret = recall(waitpid(pid(), &cStat, 0)); (void)ret; diff --git a/inc/kul/os/nixish/src/signal/handler.ipp b/inc/mkn/kul/os/nixish/src/signal/handler.ipp similarity index 76% rename from inc/kul/os/nixish/src/signal/handler.ipp rename to inc/mkn/kul/os/nixish/src/signal/handler.ipp index 33c6ad4..83f04b0 100644 --- a/inc/kul/os/nixish/src/signal/handler.ipp +++ b/inc/mkn/kul/os/nixish/src/signal/handler.ipp @@ -28,21 +28,21 @@ 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. */ -// IWYU pragma: private, include "kul/signal.hpp" +// IWYU pragma: private, include "mkn/kul/signal.hpp" void kul_sig_handler(int s, siginfo_t *info, void *v) { - if (info->si_pid == 0 || info->si_pid == kul::this_proc::id()) { + if (info->si_pid == 0 || info->si_pid == mkn::kul::this_proc::id()) { if (s == SIGABRT) - for (auto &f : kul::SignalStatic::INSTANCE().ab) f(s); + for (auto &f : mkn::kul::SignalStatic::INSTANCE().ab) f(s); if (s == SIGINT) - for (auto &f : kul::SignalStatic::INSTANCE().in) f(s); + for (auto &f : mkn::kul::SignalStatic::INSTANCE().in) f(s); if (s == SIGSEGV) - for (auto &f : kul::SignalStatic::INSTANCE().se) f(s); - if (s == SIGSEGV && !kul::SignalStatic::INSTANCE().q) { - auto tid = kul::this_thread::id(); + for (auto &f : mkn::kul::SignalStatic::INSTANCE().se) f(s); + if (s == SIGSEGV && !mkn::kul::SignalStatic::INSTANCE().q) { + auto tid = mkn::kul::this_thread::id(); ucontext_t *uc = (ucontext_t *)v; printf("[bt] Stacktrace:\n"); - for (auto const &st : kul::this_thread::stacktrace(uc)) KOUT(NON) << tid << " : " << st; + for (auto const &st : mkn::kul::this_thread::stacktrace(uc)) KOUT(NON) << tid << " : " << st; } exit(s); } diff --git a/inc/kul/os/nixish/src/signal/stacktrace.ipp b/inc/mkn/kul/os/nixish/src/signal/stacktrace.ipp similarity index 95% rename from inc/kul/os/nixish/src/signal/stacktrace.ipp rename to inc/mkn/kul/os/nixish/src/signal/stacktrace.ipp index 03b1931..85c234b 100644 --- a/inc/kul/os/nixish/src/signal/stacktrace.ipp +++ b/inc/mkn/kul/os/nixish/src/signal/stacktrace.ipp @@ -28,7 +28,7 @@ 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. */ -// IWYU pragma: private, include "kul/signal.hpp" +// IWYU pragma: private, include "mkn/kul/signal.hpp" // This file is included by other files and is not in itself syntactically correct. @@ -38,7 +38,7 @@ inline std::vector stacktrace(ucontext_t */*uc*/ = nullptr, int /*s // constexpr size_t max_trace = 128; std::string const invalid = "??:0"; - bool euaddr = kul::env::WHICH("eu-addr2line"); + bool euaddr = mkn::kul::env::WHICH("eu-addr2line"); std::vector v; @@ -111,8 +111,8 @@ inline std::vector stacktrace(ucontext_t */*uc*/ = nullptr, int /*s // address = ss.str(); // } // if (euaddr) { - // kul::Process p("eu-addr2line"); - // kul::ProcessCapture pc(p); + // mkn::kul::Process p("eu-addr2line"); + // mkn::kul::ProcessCapture pc(p); // p.arg("-e").arg(symbollist[i]).arg(address).start(); // std::string out = pc.outs(); // KLOG(INF) << p.toString(); @@ -122,7 +122,7 @@ inline std::vector stacktrace(ucontext_t */*uc*/ = nullptr, int /*s // } // if(line.size()) line.pop_back(); - // kul::String::TRIM(line); + // mkn::kul::String::TRIM(line); // if(line.empty()) v.emplace_back(li); // else v.emplace_back(line); // } diff --git a/inc/kul/os/nixish/sys.hpp b/inc/mkn/kul/os/nixish/sys.hpp similarity index 83% rename from inc/kul/os/nixish/sys.hpp rename to inc/mkn/kul/os/nixish/sys.hpp index cc71bbe..b64e17c 100644 --- a/inc/kul/os/nixish/sys.hpp +++ b/inc/mkn/kul/os/nixish/sys.hpp @@ -28,19 +28,20 @@ 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. */ -// IWYU pragma: private, include "kul/sys.hpp" +// IWYU pragma: private, include "mkn/kul/sys.hpp" -#ifndef _KUL_OS_NIXISH_SYS_HPP_ -#define _KUL_OS_NIXISH_SYS_HPP_ +#ifndef _MKN_KUL_OS_NIXISH_SYS_HPP_ +#define _MKN_KUL_OS_NIXISH_SYS_HPP_ -#include "kul/log.hpp" +#include "mkn/kul/log.hpp" #include -#ifndef __KUL_SYS_DLOPEN__ -#define __KUL_SYS_DLOPEN__ RTLD_NOW | RTLD_GLOBAL -#endif //__KUL_SYS_DLOPEN__ +#ifndef __MKN_KUL_SYS_DLOPEN__ +#define __MKN_KUL_SYS_DLOPEN__ RTLD_NOW | RTLD_GLOBAL +#endif //__MKN_KUL_SYS_DLOPEN__ +namespace mkn { namespace kul { namespace sys { @@ -54,12 +55,12 @@ class SharedLibrary { private: bool _loaded = 0; void *_handle; - const kul::File _f; + const mkn::kul::File _f; public: - SharedLibrary(kul::File const &f) KTHROW(Exception) : _f(f) { + SharedLibrary(mkn::kul::File const &f) KTHROW(Exception) : _f(f) { if (!_f) KEXCEPSTREAM << "Library attempted to be loaded does not exist: " << _f.full(); - _handle = dlopen(_f.real().c_str(), __KUL_SYS_DLOPEN__); + _handle = dlopen(_f.real().c_str(), __MKN_KUL_SYS_DLOPEN__); if (!_handle) KEXCEPSTREAM << "Cannot load library: " << f << " - Error: " << dlerror(); _loaded = 1; } @@ -67,7 +68,7 @@ class SharedLibrary { if (_loaded) dlclose(_handle); dlerror(); } - const kul::File file() const { return _f; } + const mkn::kul::File file() const { return _f; } }; template @@ -97,7 +98,7 @@ class SharedClass { SharedFunction _d; public: - SharedClass(kul::File const &f, std::string const &c, std::string const &d) KTHROW(Exception) + SharedClass(mkn::kul::File const &f, std::string const &c, std::string const &d) KTHROW(Exception) : _lib(f), _c(_lib, c), _d(_lib, d) {} virtual ~SharedClass() {} @@ -115,5 +116,6 @@ class SharedClass { } // namespace sys } // namespace kul +} // namespace mkn -#endif /* _KUL_OS_NIXISH_SYS_HPP_ */ +#endif /* _MKN_KUL_OS_NIXISH_SYS_HPP_ */ diff --git a/inc/kul/os/nixish/threads.os.hpp b/inc/mkn/kul/os/nixish/threads.os.hpp similarity index 91% rename from inc/kul/os/nixish/threads.os.hpp rename to inc/mkn/kul/os/nixish/threads.os.hpp index 8f3ec1d..60ac901 100644 --- a/inc/kul/os/nixish/threads.os.hpp +++ b/inc/mkn/kul/os/nixish/threads.os.hpp @@ -28,10 +28,10 @@ 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. */ -// IWYU pragma: private, include "kul/threads.hpp" +// IWYU pragma: private, include "mkn/kul/threads.hpp" -#ifndef _KUL_OS_NIXISH_THREADS_OS_HPP_ -#define _KUL_OS_NIXISH_THREADS_OS_HPP_ +#ifndef _MKN_KUL_OS_NIXISH_THREADS_OS_HPP_ +#define _MKN_KUL_OS_NIXISH_THREADS_OS_HPP_ #include #include @@ -42,6 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #endif +namespace mkn { namespace kul { namespace this_thread { inline const std::string id() { @@ -115,7 +116,7 @@ class Thread : public threading::AThread { virtual ~Thread() {} bool detach() { return pthread_detach(thr); } - void interrupt() KTHROW(kul::threading::InterruptionException) { + void interrupt() KTHROW(mkn::kul::threading::InterruptionException) { pthread_cancel(thr); f = 1; } @@ -124,7 +125,7 @@ class Thread : public threading::AThread { pthread_join(thr, 0); s = 0; } - void run() KTHROW(kul::threading::Exception) { + void run() KTHROW(mkn::kul::threading::Exception) { if (s) KEXCEPTION("Thread running"); f = 0; s = 1; @@ -133,4 +134,5 @@ class Thread : public threading::AThread { }; } // namespace kul -#endif /* _KUL_OS_NIXISH_THREADS_OS_HPP_ */ +} // namespace mkn +#endif /* _MKN_KUL_OS_NIXISH_THREADS_OS_HPP_ */ diff --git a/inc/kul/os/threads.hpp b/inc/mkn/kul/os/threads.hpp similarity index 83% rename from inc/kul/os/threads.hpp rename to inc/mkn/kul/os/threads.hpp index 948de58..f7d249a 100644 --- a/inc/kul/os/threads.hpp +++ b/inc/mkn/kul/os/threads.hpp @@ -28,12 +28,12 @@ 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. */ -// IWYU pragma: private, include "kul/threads.hpp" +// IWYU pragma: private, include "mkn/kul/threads.hpp" -#ifndef _KUL_OS_THREADS_HPP_ -#define _KUL_OS_THREADS_HPP_ +#ifndef _MKN_KUL_OS_THREADS_HPP_ +#define _MKN_KUL_OS_THREADS_HPP_ -#include "kul/defs.hpp" +#include "mkn/kul/defs.hpp" #include #include @@ -42,9 +42,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include "kul/defs.hpp" -#include "kul/except.hpp" +#include "mkn/kul/defs.hpp" +#include "mkn/kul/except.hpp" +namespace mkn { namespace kul { namespace this_thread { inline void sleep(unsigned long const &millis) { @@ -62,9 +63,9 @@ inline void nSleep(unsigned long const &nanos) { // template class PredicatedThreadQueue; namespace threading { -class Exception : public kul::Exception { +class Exception : public mkn::kul::Exception { public: - Exception(char const *f, uint16_t const &l, std::string const &s) : kul::Exception(f, l, s) {} + Exception(char const *f, uint16_t const &l, std::string const &s) : mkn::kul::Exception(f, l, s) {} }; class InterruptionException : public Exception { public: @@ -78,14 +79,14 @@ class AThread { std::exception_ptr ep; AThread() : f(1), s(0) {} - virtual void run() KTHROW(kul::threading::Exception) = 0; + virtual void run() KTHROW(mkn::kul::threading::Exception) = 0; public: virtual ~AThread() {} virtual void join() = 0; bool started() const { return s; } bool finished() const { return f; } - const std::exception_ptr &exception() { return ep; } + auto& exception() const { return ep; } void rethrow() { if (ep) std::rethrow_exception(ep); } @@ -93,11 +94,13 @@ class AThread { } // namespace threading } // namespace kul +} // namespace mkn #if defined(_WIN32) -#include "kul/os/win/threads.os.hpp" +#include "mkn/kul/os/win/threads.os.hpp" #else -#include "kul/os/nixish/threads.os.hpp" +#include "mkn/kul/os/nixish/threads.os.hpp" #endif -#endif // _KUL_OS_THREADS_HPP_ \ No newline at end of file +#endif // _MKN_KUL_OS_THREADS_HPP_ + diff --git a/inc/kul/os/win/cli.os.hpp b/inc/mkn/kul/os/win/cli.os.hpp similarity index 87% rename from inc/kul/os/win/cli.os.hpp rename to inc/mkn/kul/os/win/cli.os.hpp index e9ad898..90a4acd 100644 --- a/inc/kul/os/win/cli.os.hpp +++ b/inc/mkn/kul/os/win/cli.os.hpp @@ -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. */ -#ifndef _KUL_OS_WIN_CLI_OS_HPP_ -#define _KUL_OS_WIN_CLI_OS_HPP_ +#ifndef _MKN_KUL_OS_WIN_CLI_OS_HPP_ +#define _MKN_KUL_OS_WIN_CLI_OS_HPP_ #include @@ -37,14 +37,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +namespace mkn { namespace kul { namespace cli { -#ifndef _KUL_COMPILED_LIB_ +#ifndef _MKN_KUL_COMPILED_LIB_ inline std::string hidden(std::string const& t) { -#include "kul/os/win/src/cli/hidden.cpp" +#include "mkn/kul/os/win/src/cli/hidden.cpp" } inline void show() { -#include "kul/os/win/src/cli/show.cpp" +#include "mkn/kul/os/win/src/cli/show.cpp" } #else std::string hidden(std::string const& t); @@ -52,5 +53,6 @@ void show(); #endif } // namespace cli } // namespace kul +} // namespace mkn -#endif /* _KUL_OS_WIN_CLI_OS_HPP_ */ \ No newline at end of file +#endif /* _MKN_KUL_OS_WIN_CLI_OS_HPP_ */ \ No newline at end of file diff --git a/inc/kul/os/win/cpu.hpp b/inc/mkn/kul/os/win/cpu.hpp similarity index 92% rename from inc/kul/os/win/cpu.hpp rename to inc/mkn/kul/os/win/cpu.hpp index 0fdeda1..a0c9b09 100644 --- a/inc/kul/os/win/cpu.hpp +++ b/inc/mkn/kul/os/win/cpu.hpp @@ -28,13 +28,14 @@ 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. */ -#ifndef _KUL_OS_WIN_CPU_HPP_ -#define _KUL_OS_WIN_CPU_HPP_ +#ifndef _MKN_KUL_OS_WIN_CPU_HPP_ +#define _MKN_KUL_OS_WIN_CPU_HPP_ #include #include +namespace mkn { namespace kul { namespace cpu { inline uint32_t cores() { @@ -45,5 +46,6 @@ inline uint32_t cores() { inline uint16_t threads() { return std::thread::hardware_concurrency(); } } // namespace cpu } // namespace kul +} // namespace mkn -#endif /* _KUL_OS_WIN_CPU_HPP_ */ +#endif /* _MKN_KUL_OS_WIN_CPU_HPP_ */ diff --git a/inc/kul/os/win/def.hpp b/inc/mkn/kul/os/win/def.hpp similarity index 74% rename from inc/kul/os/win/def.hpp rename to inc/mkn/kul/os/win/def.hpp index 87e2fa4..3120d57 100644 --- a/inc/kul/os/win/def.hpp +++ b/inc/mkn/kul/os/win/def.hpp @@ -28,30 +28,30 @@ 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. */ -#ifndef _KUL_OS_WIN_DEF_HPP_ -#define _KUL_OS_WIN_DEF_HPP_ +#ifndef _MKN_KUL_OS_WIN_DEF_HPP_ +#define _MKN_KUL_OS_WIN_DEF_HPP_ -#include "kul/defs.hpp" +#include "mkn/kul/defs.hpp" -#ifndef __KUL_OS__ -#define __KUL_OS__ win -#endif /* __KUL_OS__ */ +#ifndef __MKN_KUL_OS__ +#define __MKN_KUL_OS__ win +#endif /* __MKN_KUL_OS__ */ -#ifndef __KUL_THREAD_SPAWN_WAIT__ -#define __KUL_THREAD_SPAWN_WAIT__ 0 -#endif /* __KUL_THREAD_SPAWN_WAIT__ */ +#ifndef __MKN_KUL_THREAD_SPAWN_WAIT__ +#define __MKN_KUL_THREAD_SPAWN_WAIT__ 0 +#endif /* __MKN_KUL_THREAD_SPAWN_WAIT__ */ -#ifndef __KUL_ENV_BUFFER__ -#define __KUL_ENV_BUFFER__ 1024 -#endif /* __KUL_ENV_BUFFER__ */ +#ifndef __MKN_KUL_ENV_BUFFER__ +#define __MKN_KUL_ENV_BUFFER__ 1024 +#endif /* __MKN_KUL_ENV_BUFFER__ */ -#ifndef __KUL_PROCESS_BUFFER__ -#define __KUL_PROCESS_BUFFER__ 1024 -#endif /* __KUL_PROCESS_BUFFER__ */ +#ifndef __MKN_KUL_PROCESS_BUFFER__ +#define __MKN_KUL_PROCESS_BUFFER__ 1024 +#endif /* __MKN_KUL_PROCESS_BUFFER__ */ -#ifndef __KUL_PROCESS_ENV_BUFFER__ -#define __KUL_PROCESS_ENV_BUFFER__ 4096 * 2 -#endif /* __KUL_PROCESS_ENV_BUFFER__ */ +#ifndef __MKN_KUL_PROCESS_ENV_BUFFER__ +#define __MKN_KUL_PROCESS_ENV_BUFFER__ 4096 * 2 +#endif /* __MKN_KUL_PROCESS_ENV_BUFFER__ */ #pragma warning(disable : 4005) #pragma warning(disable : 4101) @@ -78,4 +78,4 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define __func__ __FUNCTION__ #endif -#endif /* _KUL_OS_WIN_DEF_HPP_ */ +#endif /* _MKN_KUL_OS_WIN_DEF_HPP_ */ diff --git a/inc/kul/os/win/env.hpp b/inc/mkn/kul/os/win/env.hpp similarity index 91% rename from inc/kul/os/win/env.hpp rename to inc/mkn/kul/os/win/env.hpp index 5d244b6..bbed880 100644 --- a/inc/kul/os/win/env.hpp +++ b/inc/mkn/kul/os/win/env.hpp @@ -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. */ -#ifndef _KUL_OS_WIN_ENV_HPP_ -#define _KUL_OS_WIN_ENV_HPP_ +#ifndef _MKN_KUL_OS_WIN_ENV_HPP_ +#define _MKN_KUL_OS_WIN_ENV_HPP_ #include #include @@ -42,16 +42,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +namespace mkn { namespace kul { namespace env { -#if defined(_KUL_MAX_PATH_) -constexpr size_t KUL_MAX_PATH = _KUL_MAX_PATH_; +#if defined(_MKN_KUL_MAX_PATH_) +constexpr size_t KUL_MAX_PATH = _MKN_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_*/ +#endif /*_MKN_KUL_MAX_PATH_*/ inline std::string EOL() { #if (_MSC_VER >= 1800) @@ -99,5 +100,6 @@ inline bool CWD(std::string const &c) { return _chdir(c.c_str()) != -1; } } // namespace env } // namespace kul +} // namespace mkn -#endif /* _KUL_OS_WIN_ENV_HPP_ */ +#endif /* _MKN_KUL_OS_WIN_ENV_HPP_ */ diff --git a/inc/kul/os/win/ipc.hpp b/inc/mkn/kul/os/win/ipc.hpp similarity index 82% rename from inc/kul/os/win/ipc.hpp rename to inc/mkn/kul/os/win/ipc.hpp index 57202c4..dc204c5 100644 --- a/inc/kul/os/win/ipc.hpp +++ b/inc/mkn/kul/os/win/ipc.hpp @@ -28,14 +28,14 @@ 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. */ -#ifndef _KUL_OS_WIN_IPC_HPP_ -#define _KUL_OS_WIN_IPC_HPP_ +#ifndef _MKN_KUL_OS_WIN_IPC_HPP_ +#define _MKN_KUL_OS_WIN_IPC_HPP_ -#ifndef _KUL_IPC_UUID_PREFIX_ -#define _KUL_IPC_UUID_PREFIX_ "\\\\.\\pipe\\" +#ifndef _MKN_KUL_IPC_UUID_PREFIX_ +#define _MKN_KUL_IPC_UUID_PREFIX_ "\\\\.\\pipe\\" #endif -#include "kul/proc.hpp" +#include "mkn/kul/proc.hpp" #include #include @@ -45,12 +45,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define KUL_IPC_BUFFER 512 +namespace mkn { namespace kul { namespace ipc { -class Exception : public kul::Exception { +class Exception : public mkn::kul::Exception { public: - Exception(char const *f, uint16_t const &l, std::string const &s) : kul::Exception(f, l, s) {} + Exception(char const *f, uint16_t const &l, std::string const &s) : mkn::kul::Exception(f, l, s) {} }; class Server { @@ -75,7 +76,7 @@ class Server { 0, // client time-out NULL); // default security attribute if (hPipe == INVALID_HANDLE_VALUE) - KEXCEPT(kul::ipc::Exception, "CreateNamedPipe failed: " + std::to_string(GetLastError())); + KEXCEPT(mkn::kul::ipc::Exception, "CreateNamedPipe failed: " + std::to_string(GetLastError())); } protected: @@ -94,7 +95,7 @@ class Server { if (!fConnected) continue; DWORD cbBytesRead = 0, cbReplyBytes = 0, cbWritten = 0; if (pchRequest == NULL) - KEXCEPT(kul::ipc::Exception, + KEXCEPT(mkn::kul::ipc::Exception, "Pipe Server Failure pchRequest: " + std::to_string(GetLastError())); bool fSuccess = FALSE; while (1) { @@ -110,18 +111,18 @@ class Server { } Server(const int16_t &lp = -1) KTHROW(Exception) : lp(lp), - uuid(_KUL_IPC_UUID_PREFIX_ + std::string("pid\\") + std::to_string(kul::this_proc::id())) { + uuid(_MKN_KUL_IPC_UUID_PREFIX_ + std::string("pid\\") + std::to_string(mkn::kul::this_proc::id())) { start(); } Server(std::string const &ui, const int16_t &lp = -1) KTHROW(Exception) - : uuid(_KUL_IPC_UUID_PREFIX_ + ui), lp(lp) { + : uuid(_MKN_KUL_IPC_UUID_PREFIX_ + ui), lp(lp) { start(); } }; class Client { private: - const std::string uuid; + std::string const uuid; HANDLE hPipe; void start() KTHROW(Exception) { @@ -140,24 +141,24 @@ class Client { if (hPipe != INVALID_HANDLE_VALUE) break; if (GetLastError() != ERROR_PIPE_BUSY) - KEXCEPT(kul::ipc::Exception, "Could not open pipe: " + std::to_string(GetLastError())); + KEXCEPT(mkn::kul::ipc::Exception, "Could not open pipe: " + std::to_string(GetLastError())); if (!WaitNamedPipe(lpszPipename, 5000)) - KEXCEPT(kul::ipc::Exception, "Could not open pipe: 5 second wait timed out."); + KEXCEPT(mkn::kul::ipc::Exception, "Could not open pipe: 5 second wait timed out."); } dwMode = PIPE_READMODE_MESSAGE; fSuccess = SetNamedPipeHandleState(hPipe, &dwMode, NULL, NULL); if (!fSuccess) - KEXCEPT(kul::ipc::Exception, + KEXCEPT(mkn::kul::ipc::Exception, "SetNamedPipeHandleState failed: " + std::to_string(GetLastError())); } void stop() const KTHROW(Exception) { CloseHandle(hPipe); } public: virtual ~Client() { stop(); } - Client(std::string const &ui) KTHROW(Exception) : uuid(_KUL_IPC_UUID_PREFIX_ + ui) { start(); } + Client(std::string const &ui) KTHROW(Exception) : uuid(_MKN_KUL_IPC_UUID_PREFIX_ + ui) { start(); } Client(const int16_t &pid) KTHROW(Exception) - : uuid(_KUL_IPC_UUID_PREFIX_ + std::string("pid\\") + std::to_string(pid)) { + : uuid(_MKN_KUL_IPC_UUID_PREFIX_ + std::string("pid\\") + std::to_string(pid)) { start(); } virtual void send(std::string const &m) const KTHROW(Exception) { @@ -165,11 +166,12 @@ class Client { LPTSTR lpvMessage = _strdup(m.c_str()); cbToWrite = (lstrlen(lpvMessage) + 1) * sizeof(TCHAR); if (!WriteFile(hPipe, lpvMessage, cbToWrite, &cbWritten, NULL)) - KEXCEPT(kul::ipc::Exception, "WriteFile to pipe failed: " + std::to_string(GetLastError())); + KEXCEPT(mkn::kul::ipc::Exception, "WriteFile to pipe failed: " + std::to_string(GetLastError())); } }; } // namespace ipc } // namespace kul +} // namespace mkn -#endif /* _KUL_OS_WIN_IPC_HPP_ */ +#endif /* _MKN_KUL_OS_WIN_IPC_HPP_ */ diff --git a/inc/kul/os/win/os.bot.hpp b/inc/mkn/kul/os/win/os.bot.hpp similarity index 69% rename from inc/kul/os/win/os.bot.hpp rename to inc/mkn/kul/os/win/os.bot.hpp index 9bc13bf..86471ab 100644 --- a/inc/kul/os/win/os.bot.hpp +++ b/inc/mkn/kul/os/win/os.bot.hpp @@ -28,10 +28,10 @@ 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. */ -#ifndef _KUL_OS_WIN_OS_BOT_HPP_ -#define _KUL_OS_WIN_OS_BOT_HPP_ +#ifndef _MKN_KUL_OS_WIN_OS_BOT_HPP_ +#define _MKN_KUL_OS_WIN_OS_BOT_HPP_ -void kul::Dir::rm() const { +void mkn::kul::Dir::rm() const { if (is()) { for (const auto &a : files()) a.rm(); for (const auto &a : dirs()) a.rm(); @@ -39,31 +39,31 @@ void kul::Dir::rm() const { } } -std::string kul::Dir::ESC(std::string s) { +std::string mkn::kul::Dir::ESC(std::string s) { ESC_REPLACE(s, "\\", "\\\\"); return s; } -std::string kul::Dir::LOCL(std::string s) { - kul::String::REPLACE_ALL(s, "/", "\\"); +std::string mkn::kul::Dir::LOCL(std::string s) { + mkn::kul::String::REPLACE_ALL(s, "/", "\\"); return s; } -bool kul::Dir::is() const { +bool mkn::kul::Dir::is() const { if (path().empty()) return false; DWORD ftyp = GetFileAttributesA(path().c_str()); return (ftyp != INVALID_FILE_ATTRIBUTES && ftyp & FILE_ATTRIBUTE_DIRECTORY); } -bool kul::Dir::mk() const { +bool mkn::kul::Dir::mk() const { if (path().empty()) return false; - kul::Dir const &prnt(parent()); + mkn::kul::Dir const &prnt(parent()); if (_p != prnt.path() && !prnt.is()) parent().mk(); return CreateDirectory(locl().c_str(), NULL); } -bool kul::Dir::root() const { return is() && real().size() == 3; } +bool mkn::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 { +bool mkn::kul::File::is() const { return !name().empty() && (bool)std::ifstream(_d.join(_n).c_str()); } +bool mkn::kul::File::rm() const { if (is()) { _unlink(_d.join(_n).c_str()); return true; @@ -71,7 +71,7 @@ bool kul::File::rm() const { return false; } -bool kul::File::mk() const { +bool mkn::kul::File::mk() const { FILE *pFile; fopen_s(&pFile, full().c_str(), "w"); if (pFile != NULL) { @@ -80,7 +80,7 @@ bool kul::File::mk() const { return pFile != NULL; } -uint64_t kul::File::size() const { +uint64_t mkn::kul::File::size() const { uint64_t r = 0; WIN32_FIND_DATA ffd; HANDLE h = FindFirstFile(TEXT(mini().c_str()), &ffd); @@ -94,6 +94,7 @@ uint64_t kul::File::size() const { return r; } +namespace mkn { namespace kul { namespace os { @@ -115,24 +116,25 @@ inline std::string EOL() { namespace user { -inline kul::Dir home() { +inline mkn::kul::Dir home() { const std::string h(env::GET("HOME")); - if (h.size()) return kul::Dir(h); - return kul::Dir(std::string(env::GET("HOMEDRIVE")) + std::string(env::GET("HOMEPATH"))); + if (h.size()) return mkn::kul::Dir(h); + return mkn::kul::Dir(std::string(env::GET("HOMEDRIVE")) + std::string(env::GET("HOMEPATH"))); } -inline kul::Dir home(std::string const &app) { return kul::Dir(home().join(app)); } +inline mkn::kul::Dir home(std::string const &app) { return mkn::kul::Dir(home().join(app)); } } // namespace user namespace env { -inline bool CWD(kul::Dir const &d) { return _chdir(d.path().c_str()) != -1; } +inline bool CWD(mkn::kul::Dir const &d) { return _chdir(d.path().c_str()) != -1; } } // namespace env } // namespace kul +} // namespace mkn -#ifndef _KUL_COMPILED_LIB_ -#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_ +#ifndef _MKN_KUL_COMPILED_LIB_ +#include "mkn/kul/os/win/src/os/dir/dirs.ipp" +#include "mkn/kul/os/win/src/os/dir/files.ipp" +#include "mkn/kul/os/win/src/os/dir/real.ipp" +#endif //_MKN_KUL_COMPILED_LIB_ -#endif /* _KUL_OS_WIN_OS_BOT_HPP_ */ +#endif /* _MKN_KUL_OS_WIN_OS_BOT_HPP_ */ diff --git a/inc/kul/os/win/os.top.hpp b/inc/mkn/kul/os/win/os.top.hpp similarity index 92% rename from inc/kul/os/win/os.top.hpp rename to inc/mkn/kul/os/win/os.top.hpp index ba9d9ae..e1ec89d 100644 --- a/inc/kul/os/win/os.top.hpp +++ b/inc/mkn/kul/os/win/os.top.hpp @@ -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. */ -#ifndef _KUL_OS_WIN_OS_TOP_HPP_ -#define _KUL_OS_WIN_OS_TOP_HPP_ +#ifndef _MKN_KUL_OS_WIN_OS_TOP_HPP_ +#define _MKN_KUL_OS_WIN_OS_TOP_HPP_ #include #include @@ -42,8 +42,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include "kul/defs.hpp" +#include "mkn/kul/defs.hpp" +namespace mkn { namespace kul { class Dir; @@ -69,10 +70,11 @@ class KulTimeStampsResolver { FindClose(h); } } - friend class kul::Dir; + friend class mkn::kul::Dir; }; } // namespace fs } // namespace kul +} // namespace mkn -#endif /* _KUL_OS_WIN_OS_TOP_HPP_ */ +#endif /* _MKN_KUL_OS_WIN_OS_TOP_HPP_ */ diff --git a/inc/kul/os/win/proc.hpp b/inc/mkn/kul/os/win/proc.hpp similarity index 79% rename from inc/kul/os/win/proc.hpp rename to inc/mkn/kul/os/win/proc.hpp index 3d61967..6d90156 100644 --- a/inc/kul/os/win/proc.hpp +++ b/inc/mkn/kul/os/win/proc.hpp @@ -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. */ -#ifndef _KUL_OS_WIN_PROC_HPP_ -#define _KUL_OS_WIN_PROC_HPP_ +#ifndef _MKN_KUL_OS_WIN_PROC_HPP_ +#define _MKN_KUL_OS_WIN_PROC_HPP_ #include #include @@ -39,13 +39,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include "kul/defs.hpp" -#include "kul/log.hpp" -#include "kul/os.hpp" -#include "kul/string.hpp" +#include "mkn/kul/defs.hpp" +#include "mkn/kul/log.hpp" +#include "mkn/kul/os.hpp" +#include "mkn/kul/string.hpp" // extern char **environ; +namespace mkn { namespace kul { namespace this_proc { @@ -83,11 +84,11 @@ inline uint16_t cpuLoad() { return 0; } inline int32_t id() { return GetCurrentProcessId(); } inline void kill(const int32_t &e) { - TerminateProcess(OpenProcess(PROCESS_TERMINATE, 0, kul::this_proc::id()), 128 + e); + TerminateProcess(OpenProcess(PROCESS_TERMINATE, 0, mkn::kul::this_proc::id()), 128 + e); } } // namespace this_proc -class Process : public kul::AProcess { +class Process : public mkn::kul::AProcess { private: static ULONG PIPE_ID() { static ULONG p = 999; @@ -102,11 +103,11 @@ class Process : public kul::AProcess { HANDLE revent = CreateEvent(0, 1, 0, 0); public: - Process(std::string const &cmd, const bool &wfe = true) : kul::AProcess(cmd, wfe) {} + Process(std::string const &cmd, const bool &wfe = true) : mkn::kul::AProcess(cmd, wfe) {} Process(std::string const &cmd, std::string const &path, const bool &wfe = true) - : kul::AProcess(cmd, path, wfe) {} - Process(std::string const &cmd, kul::Dir const &d, const bool &wfe = true) - : kul::AProcess(cmd, d ? d.real() : d.path(), wfe) {} + : mkn::kul::AProcess(cmd, path, wfe) {} + Process(std::string const &cmd, mkn::kul::Dir const &d, const bool &wfe = true) + : mkn::kul::AProcess(cmd, d ? d.real() : d.path(), wfe) {} ~Process() { tearDown(); } bool kill(int16_t k = 6) { if (!started()) return 0; @@ -121,22 +122,23 @@ class Process : public kul::AProcess { } protected: -#ifndef _KUL_COMPILED_LIB_ +#ifndef _MKN_KUL_COMPILED_LIB_ void tearDown() { -#include "kul/os/win/src/proc/tearDown.cpp" +#include "mkn/kul/os/win/src/proc/tearDown.cpp" } virtual void expand(std::string &s) const { -#include "kul/os/win/src/proc/expand.cpp" +#include "mkn/kul/os/win/src/proc/expand.cpp" } - void run() KTHROW(kul::Exception) { -#include "kul/os/win/src/proc/run.cpp" + void run() KTHROW(mkn::kul::Exception) { +#include "mkn/kul/os/win/src/proc/run.cpp" } #else void tearDown(); virtual void expand(std::string &s) const; - void run() KTHROW(kul::Exception); + void run() KTHROW(mkn::kul::Exception); #endif }; } // namespace kul +} // namespace mkn -#endif /* _KUL_OS_WIN_PROC_HPP_ */ +#endif /* _MKN_KUL_OS_WIN_PROC_HPP_ */ diff --git a/inc/kul/os/win/signal.hpp b/inc/mkn/kul/os/win/signal.hpp similarity index 85% rename from inc/kul/os/win/signal.hpp rename to inc/mkn/kul/os/win/signal.hpp index 98932b0..4131f03 100644 --- a/inc/kul/os/win/signal.hpp +++ b/inc/mkn/kul/os/win/signal.hpp @@ -28,10 +28,10 @@ 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. */ -#ifndef _KUL_OS_WIN_SIGNAL_HPP_ -#define _KUL_OS_WIN_SIGNAL_HPP_ +#ifndef _MKN_KUL_OS_WIN_SIGNAL_HPP_ +#define _MKN_KUL_OS_WIN_SIGNAL_HPP_ -#include +#include "mkn/kul/log.hpp" #include #include @@ -64,10 +64,11 @@ BOOL WINAPI kul_sigint_function(DWORD d) { return TRUE; } +namespace mkn { namespace kul { namespace this_thread { std::vector stacktrace() { - // #include "kul/os/win/src/signal/stacktrace.ipp" + // #include "mkn/kul/os/win/src/signal/stacktrace.ipp" return std::vector{}; } @@ -109,35 +110,36 @@ class Signal { SetUnhandledExceptionFilter(kul_top_level_exception_handler); } Signal &abrt(const std::function &f) { - kul::SignalStatic::INSTANCE().ab.push_back(f); + mkn::kul::SignalStatic::INSTANCE().ab.push_back(f); return *this; } Signal &intr(const std::function &f) { - kul::SignalStatic::INSTANCE().intr(f); + mkn::kul::SignalStatic::INSTANCE().intr(f); return *this; } Signal &segv(const std::function &f) { - kul::SignalStatic::INSTANCE().se.push_back(f); + mkn::kul::SignalStatic::INSTANCE().se.push_back(f); return *this; } - void quiet() { kul::SignalStatic::INSTANCE().q = 1; } + void quiet() { mkn::kul::SignalStatic::INSTANCE().q = 1; } }; } // namespace kul +} // namespace mkn void kul_sig_function_handler(uint16_t const &s) { if (s == 2) - for (auto &f : kul::SignalStatic::INSTANCE().in) f(s); + for (auto &f : mkn::kul::SignalStatic::INSTANCE().in) f(s); if (s == 11) - for (auto &f : kul::SignalStatic::INSTANCE().se) f(s); + for (auto &f : mkn::kul::SignalStatic::INSTANCE().se) f(s); } -#ifndef _KUL_COMPILED_LIB_ +#ifndef _MKN_KUL_COMPILED_LIB_ void kul_real_se_handler(EXCEPTION_POINTERS *pExceptionInfo) { -#include "kul/os/win/src/signal/se_handler.cpp" +#include "mkn/kul/os/win/src/signal/se_handler.cpp" } #else void kul_real_se_handler(EXCEPTION_POINTERS *pExceptionInfo); #endif -#endif /* _KUL_OS_WIN_SIGNAL_HPP_ */ +#endif /* _MKN_KUL_OS_WIN_SIGNAL_HPP_ */ diff --git a/inc/kul/os/win/src/cli/hidden.cpp b/inc/mkn/kul/os/win/src/cli/hidden.cpp similarity index 96% rename from inc/kul/os/win/src/cli/hidden.cpp rename to inc/mkn/kul/os/win/src/cli/hidden.cpp index 62fd433..bcef5bc 100644 --- a/inc/kul/os/win/src/cli/hidden.cpp +++ b/inc/mkn/kul/os/win/src/cli/hidden.cpp @@ -32,7 +32,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // This file is included by other files and is not in itself syntactically // correct. -// std::string kul::cli::hidden(const std::string& t){ +// std::string mkn::kul::cli::hidden(const std::string& t){ if (!t.empty()) std::cout << t << std::endl; HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE); diff --git a/inc/kul/os/win/src/cli/show.cpp b/inc/mkn/kul/os/win/src/cli/show.cpp similarity index 98% rename from inc/kul/os/win/src/cli/show.cpp rename to inc/mkn/kul/os/win/src/cli/show.cpp index e16547f..1aa6ee9 100644 --- a/inc/kul/os/win/src/cli/show.cpp +++ b/inc/mkn/kul/os/win/src/cli/show.cpp @@ -32,7 +32,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // This file is included by other files and is not in itself syntactically // correct. -// void kul::cli::show(){ +// void mkn::kul::cli::show(){ HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE); DWORD mode = 0; diff --git a/inc/kul/os/win/src/os/dir/dirs.ipp b/inc/mkn/kul/os/win/src/os/dir/dirs.ipp similarity index 95% rename from inc/kul/os/win/src/os/dir/dirs.ipp rename to inc/mkn/kul/os/win/src/os/dir/dirs.ipp index a970999..89959cb 100644 --- a/inc/kul/os/win/src/os/dir/dirs.ipp +++ b/inc/mkn/kul/os/win/src/os/dir/dirs.ipp @@ -29,7 +29,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -std::vector kul::Dir::dirs(bool incHidden) const KTHROW(fs::Exception) { +std::vector mkn::kul::Dir::dirs(bool incHidden) const KTHROW(fs::Exception) { if (!is()) KEXCEPT(fs::Exception, "Directory : \"" + path() + "\" does not exist"); std::vector dirs; @@ -44,7 +44,7 @@ std::vector kul::Dir::dirs(bool incHidden) const KTHROW(fs::Exception) sprintf_s(sPath, "%s\\%s", path().c_str(), fdFile.cFileName); if (fdFile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if (!incHidden && std::string(sPath) - .substr(std::string(sPath).rfind(kul::Dir::SEP()) + 1) + .substr(std::string(sPath).rfind(mkn::kul::Dir::SEP()) + 1) .substr(0, 1) .compare(".") == 0) continue; diff --git a/inc/kul/os/win/src/os/dir/files.ipp b/inc/mkn/kul/os/win/src/os/dir/files.ipp similarity index 93% rename from inc/kul/os/win/src/os/dir/files.ipp rename to inc/mkn/kul/os/win/src/os/dir/files.ipp index c332453..66e3feb 100644 --- a/inc/kul/os/win/src/os/dir/files.ipp +++ b/inc/mkn/kul/os/win/src/os/dir/files.ipp @@ -29,7 +29,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -std::vector kul::Dir::files(bool recursive) const KTHROW(fs::Exception) { +std::vector mkn::kul::Dir::files(bool recursive) const KTHROW(fs::Exception) { if (!is()) KEXCEPT(fs::Exception, "Directory : \"" + path() + "\" does not exist"); std::vector fs; @@ -45,7 +45,7 @@ std::vector kul::Dir::files(bool recursive) const KTHROW(fs::Exceptio sprintf_s(sPath, "%s\\%s", path().c_str(), fdFile.cFileName); if (!(fdFile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { std::string f(sPath); - fs.push_back(File(f.substr(f.rfind(kul::Dir::SEP()) + 1), *this)); + fs.push_back(File(f.substr(f.rfind(mkn::kul::Dir::SEP()) + 1), *this)); } } } while (FindNextFile(hFind, &fdFile)); diff --git a/inc/kul/os/win/src/os/dir/real.ipp b/inc/mkn/kul/os/win/src/os/dir/real.ipp similarity index 95% rename from inc/kul/os/win/src/os/dir/real.ipp rename to inc/mkn/kul/os/win/src/os/dir/real.ipp index 7b5d82d..6e734c5 100644 --- a/inc/kul/os/win/src/os/dir/real.ipp +++ b/inc/mkn/kul/os/win/src/os/dir/real.ipp @@ -29,7 +29,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -std::string kul::Dir::REAL(const std::string& s) KTHROW(fs::Exception) { +std::string mkn::kul::Dir::REAL(const std::string& s) KTHROW(fs::Exception) { char* expanded = _fullpath(NULL, s.c_str(), _MAX_PATH); if (expanded) { std::string dir(expanded); diff --git a/inc/kul/os/win/src/proc/expand.cpp b/inc/mkn/kul/os/win/src/proc/expand.cpp similarity index 90% rename from inc/kul/os/win/src/proc/expand.cpp rename to inc/mkn/kul/os/win/src/proc/expand.cpp index c9f834e..d9f0b95 100644 --- a/inc/kul/os/win/src/proc/expand.cpp +++ b/inc/mkn/kul/os/win/src/proc/expand.cpp @@ -32,7 +32,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // This file is included by other files and is not in itself syntactically // correct. -// void kul::Process::expand(std::string& s) const { +// void mkn::kul::Process::expand(std::string& s) const { std::string r = s; auto lb = s.find("$("); @@ -51,11 +51,11 @@ while ((rb - crb + 1) == 0) { if (rb == std::string::npos) return; std::string k(r.substr(lb + 2, rb - 2 - lb)); -std::vector cli(kul::cli::asArgs(k)); +std::vector cli(mkn::kul::cli::asArgs(k)); std::stringstream ss; if (cli.size() > 1) { - kul::Process p(cli[0]); - kul::ProcessCapture pc(p); + mkn::kul::Process p(cli[0]); + mkn::kul::ProcessCapture pc(p); for (size_t i = 1; i < cli.size(); i++) p.arg(cli[i]); p.start(); std::string out(pc.outs()); @@ -63,7 +63,7 @@ if (cli.size() > 1) { std::string t(r.substr(0, lb) + out + r.substr(rb + 1)); ss << r.substr(0, lb) << out << r.substr(rb + 1); } else - ss << r.substr(0, lb) << kul::env::GET(cli[0].c_str()) << r.substr(rb + 1); + ss << r.substr(0, lb) << mkn::kul::env::GET(cli[0].c_str()) << r.substr(rb + 1); std::string t(ss.str()); expand(t); diff --git a/inc/kul/os/win/src/proc/run.cpp b/inc/mkn/kul/os/win/src/proc/run.cpp similarity index 90% rename from inc/kul/os/win/src/proc/run.cpp rename to inc/mkn/kul/os/win/src/proc/run.cpp index d2e8309..6d0fd24 100644 --- a/inc/kul/os/win/src/proc/run.cpp +++ b/inc/mkn/kul/os/win/src/proc/run.cpp @@ -32,7 +32,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // This file is included by other files and is not in itself syntactically // correct. -// void kul::Process::run() KTHROW(kul::proc::Exception){ +// void mkn::kul::Process::run() KTHROW(mkn::kul::proc::Exception){ SECURITY_ATTRIBUTES sa; ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES)); @@ -55,7 +55,7 @@ std::string pipeIn = "\\\\.\\Pipe\\kul_proc_in." + std::to_string(this_proc::id( LPSTR lPipeOut = _strdup(pipeOut.c_str()); g_hChildStd_OUT_Wr = ::CreateNamedPipeA(lPipeOut, PIPE_ACCESS_OUTBOUND | FILE_FLAG_OVERLAPPED, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, 1, - __KUL_PROCESS_BUFFER__, __KUL_PROCESS_BUFFER__, 0, &sa); + __MKN_KUL_PROCESS_BUFFER__, __MKN_KUL_PROCESS_BUFFER__, 0, &sa); if (!g_hChildStd_OUT_Wr) error(__LINE__, "CreatePipe failed"); g_hChildStd_OUT_Rd = ::CreateFileA(lPipeOut, GENERIC_READ, 0, &sa, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, 0); @@ -66,7 +66,7 @@ if (!SetHandleInformation(g_hChildStd_OUT_Rd, HANDLE_FLAG_INHERIT, 0)) LPSTR lPipeErr = _strdup(pipeErr.c_str()); g_hChildStd_ERR_Wr = ::CreateNamedPipeA(lPipeErr, PIPE_ACCESS_OUTBOUND | FILE_FLAG_OVERLAPPED, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, 1, - __KUL_PROCESS_BUFFER__, __KUL_PROCESS_BUFFER__, 0, &sa); + __MKN_KUL_PROCESS_BUFFER__, __MKN_KUL_PROCESS_BUFFER__, 0, &sa); if (!g_hChildStd_ERR_Wr) error(__LINE__, "CreatePipe failed"); g_hChildStd_ERR_Rd = ::CreateFileA(lPipeErr, GENERIC_READ, 0, &sa, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, 0); @@ -160,17 +160,17 @@ if (this->waitForExit()) { el.hEvent = revent; DWORD dwRead; - CHAR chBuf[__KUL_PROCESS_BUFFER__ + 1]; + CHAR chBuf[__MKN_KUL_PROCESS_BUFFER__ + 1]; bSuccess = FALSE; bool alive = true; do { -#if defined(_KUL_PROC_LOOP_NSLEEP_) && (_KUL_PROC_LOOP_NSLEEP_ > 0) - kul::this_thread::nSleep(_KUL_PROC_LOOP_NSLEEP_); +#if defined(_MKN_KUL_PROC_LOOP_NSLEEP_) && (_MKN_KUL_PROC_LOOP_NSLEEP_ > 0) + mkn::kul::this_thread::nSleep(_MKN_KUL_PROC_LOOP_NSLEEP_); #endif alive = WaitForSingleObject(piProcInfo.hProcess, 11) == WAIT_TIMEOUT; for (;;) { dwRead = 0; - bSuccess = ::ReadFile(g_hChildStd_OUT_Rd, chBuf, __KUL_PROCESS_BUFFER__, &dwRead, &ol); + bSuccess = ::ReadFile(g_hChildStd_OUT_Rd, chBuf, __MKN_KUL_PROCESS_BUFFER__, &dwRead, &ol); while (!bSuccess && (GetLastError() == ERROR_IO_PENDING || GetLastError() == ERROR_IO_INCOMPLETE)) { WaitForSingleObject(ol.hEvent, 11); @@ -182,7 +182,7 @@ if (this->waitForExit()) { } for (;;) { dwRead = 0; - bSuccess = ::ReadFile(g_hChildStd_ERR_Rd, chBuf, __KUL_PROCESS_BUFFER__, &dwRead, &el); + bSuccess = ::ReadFile(g_hChildStd_ERR_Rd, chBuf, __MKN_KUL_PROCESS_BUFFER__, &dwRead, &el); if (GetLastError() == ERROR_IO_PENDING) { WaitForSingleObject(el.hEvent, 11); bSuccess = GetOverlappedResult(g_hChildStd_OUT_Rd, &el, &dwRead, 0); @@ -197,7 +197,7 @@ tearDown(); if (this->waitForExit()) { DWORD ec = 0; if (FALSE == GetExitCodeProcess(piProcInfo.hProcess, &ec)) - KEXCEPT(kul::proc::Exception, "GetExitCodeProcess failure"); + KEXCEPT(mkn::kul::proc::Exception, "GetExitCodeProcess failure"); exitCode(ec); finish(); setFinished(); diff --git a/inc/kul/os/win/src/proc/tearDown.cpp b/inc/mkn/kul/os/win/src/proc/tearDown.cpp similarity index 97% rename from inc/kul/os/win/src/proc/tearDown.cpp rename to inc/mkn/kul/os/win/src/proc/tearDown.cpp index f6bfe03..92d22c1 100644 --- a/inc/kul/os/win/src/proc/tearDown.cpp +++ b/inc/mkn/kul/os/win/src/proc/tearDown.cpp @@ -32,7 +32,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // This file is included by other files and is not in itself syntactically // correct. -// void kul::Process::tearDown(){ +// void mkn::kul::Process::tearDown(){ CloseHandle(g_hChildStd_OUT_Rd); CloseHandle(g_hChildStd_ERR_Rd); diff --git a/inc/kul/os/win/src/signal/se_handler.cpp b/inc/mkn/kul/os/win/src/signal/se_handler.cpp similarity index 97% rename from inc/kul/os/win/src/signal/se_handler.cpp rename to inc/mkn/kul/os/win/src/signal/se_handler.cpp index 41b9021..4289584 100644 --- a/inc/kul/os/win/src/signal/se_handler.cpp +++ b/inc/mkn/kul/os/win/src/signal/se_handler.cpp @@ -34,12 +34,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // void kul_real_se_handler(EXCEPTION_POINTERS* pExceptionInfo){ -std::string const &tid(kul::this_thread::id()); +std::string const &tid(mkn::kul::this_thread::id()); uint16_t sig = pExceptionInfo->ExceptionRecord->ExceptionCode; if (pExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) kul_sig_function_handler(sig = 11); -if (!kul::SignalStatic::INSTANCE().q) { +if ( !mkn::kul::SignalStatic::INSTANCE().q) { HANDLE process = GetCurrentProcess(); SymInitialize(process, NULL, TRUE); diff --git a/inc/kul/os/win/src/thread/main.cpp b/inc/mkn/kul/os/win/src/thread/main.cpp similarity index 95% rename from inc/kul/os/win/src/thread/main.cpp rename to inc/mkn/kul/os/win/src/thread/main.cpp index 731eaa0..89f3ca5 100644 --- a/inc/kul/os/win/src/thread/main.cpp +++ b/inc/mkn/kul/os/win/src/thread/main.cpp @@ -32,12 +32,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // This file is included by other files and is not in itself syntactically // correct. -// bool kul::this_thread::main(){ +// bool mkn::kul::this_thread::main(){ const std::shared_ptr hThreadSnapshot(CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0), CloseHandle); if (hThreadSnapshot.get() == INVALID_HANDLE_VALUE) - KEXCEPT(kul::threading::Exception, "GetMainThreadId failed"); + KEXCEPT(mkn::kul::threading::Exception, "GetMainThreadId failed"); THREADENTRY32 tEntry; tEntry.dwSize = sizeof(THREADENTRY32); DWORD result = 0; diff --git a/inc/kul/os/win/sys.hpp b/inc/mkn/kul/os/win/sys.hpp similarity index 88% rename from inc/kul/os/win/sys.hpp rename to inc/mkn/kul/os/win/sys.hpp index ade9499..8d899cb 100644 --- a/inc/kul/os/win/sys.hpp +++ b/inc/mkn/kul/os/win/sys.hpp @@ -28,15 +28,15 @@ 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. */ -#ifndef _KUL_OS_WIN_SYS_HPP_ -#define _KUL_OS_WIN_SYS_HPP_ +#ifndef _MKN_KUL_OS_WIN_SYS_HPP_ +#define _MKN_KUL_OS_WIN_SYS_HPP_ -#include "kul/log.hpp" +#include "mkn/kul/log.hpp" #include +namespace mkn { namespace kul { - namespace sys { template @@ -49,10 +49,10 @@ class SharedLibrary { private: bool _loaded = 0; HINSTANCE _handle; - const kul::File _f; + const mkn::kul::File _f; public: - SharedLibrary(kul::File const &f) KTHROW(Exception) : _f(f) { + SharedLibrary(mkn::kul::File const &f) KTHROW(Exception) : _f(f) { if (!_f) KEXCEPSTREAM << "Library attempted to be loaded does not exist: " << _f.full(); LPSTR lib = _strdup(_f.real().c_str()); _handle = LoadLibrary(lib); @@ -62,7 +62,7 @@ class SharedLibrary { ~SharedLibrary() { if (_loaded) FreeLibrary(_handle); } - const kul::File file() const { return _f; } + const mkn::kul::File file() const { return _f; } }; template @@ -92,7 +92,7 @@ class SharedClass { SharedFunction _d; public: - SharedClass(kul::File const &f, std::string const &c, std::string const &d) KTHROW(Exception) + SharedClass(mkn::kul::File const &f, std::string const &c, std::string const &d) KTHROW(Exception) : _lib(f), _c(_lib, c), _d(_lib, d) {} virtual ~SharedClass() {} @@ -110,5 +110,6 @@ class SharedClass { } // namespace sys } // namespace kul +} // namespace mkn -#endif /* _KUL_OS_WIN_SYS_HPP_ */ +#endif /* _MKN_KUL_OS_WIN_SYS_HPP_ */ diff --git a/inc/kul/os/win/threads.os.hpp b/inc/mkn/kul/os/win/threads.os.hpp similarity index 91% rename from inc/kul/os/win/threads.os.hpp rename to inc/mkn/kul/os/win/threads.os.hpp index 260ad5c..cbc2136 100644 --- a/inc/kul/os/win/threads.os.hpp +++ b/inc/mkn/kul/os/win/threads.os.hpp @@ -28,12 +28,13 @@ 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. */ -#ifndef _KUL_OS_WIN_THREADS_OS_HPP_ -#define _KUL_OS_WIN_THREADS_OS_HPP_ +#ifndef _MKN_KUL_OS_WIN_THREADS_OS_HPP_ +#define _MKN_KUL_OS_WIN_THREADS_OS_HPP_ #include #include +namespace mkn { namespace kul { namespace this_thread { inline const std::string id() { @@ -43,7 +44,7 @@ inline const std::string id() { } inline bool main() { -#include "kul/os/win/src/thread/main.cpp" +#include "mkn/kul/os/win/src/thread/main.cpp" } inline void kill() { @@ -100,11 +101,11 @@ class Thread : public threading::AThread { s = 0; } bool detach() { return CloseHandle(h); } - void interrupt() KTHROW(kul::threading::InterruptionException) { + void interrupt() KTHROW(mkn::kul::threading::InterruptionException) { TerminateThread(h, 1); f = 1; } - void run() KTHROW(kul::threading::Exception) { + void run() KTHROW(mkn::kul::threading::Exception) { if (s) KEXCEPTION("Thread running"); f = 0; s = 1; @@ -120,4 +121,5 @@ inline DWORD WINAPI threadFunction(LPVOID th) { } // namespace threading } // namespace kul -#endif /* _KUL_OS_WIN_THREADS_OS_HPP_ */ +} // namespace mkn +#endif /* _MKN_KUL_OS_WIN_THREADS_OS_HPP_ */ diff --git a/inc/kul/proc.hpp b/inc/mkn/kul/proc.hpp similarity index 79% rename from inc/kul/proc.hpp rename to inc/mkn/kul/proc.hpp index 2bd20bb..e9a0d3d 100644 --- a/inc/kul/proc.hpp +++ b/inc/mkn/kul/proc.hpp @@ -28,18 +28,19 @@ 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. */ -#ifndef _KUL_PROC_HPP_ -#define _KUL_PROC_HPP_ +#ifndef _MKN_KUL_PROC_HPP_ +#define _MKN_KUL_PROC_HPP_ #include #include #include #include -#include "kul/cli.hpp" -#include "kul/log.hpp" -#include "kul/map.hpp" +#include "mkn/kul/cli.hpp" +#include "mkn/kul/log.hpp" +#include "mkn/kul/map.hpp" +namespace mkn { namespace kul { namespace this_proc { @@ -54,12 +55,12 @@ uint16_t cpuLoad(); namespace proc { -class Exception : public kul::Exception { +class Exception : public mkn::kul::Exception { public: - Exception(char const *f, uint16_t const &l, std::string const &s) : kul::Exception(f, l, s) {} + Exception(char const *f, uint16_t const &l, std::string const &s) : mkn::kul::Exception(f, l, s) {} }; -class ExitException : public kul::proc::Exception { +class ExitException : public mkn::kul::proc::Exception { private: const short ec; @@ -74,31 +75,31 @@ class Call { std::string cwd; const std::string d; std::string const &s; - kul::hash::map::S2S oldEvs; + mkn::kul::hash::map::S2S oldEvs; void setCWD() { if (d.size()) { - cwd = kul::env::CWD(); - if (!kul::env::CWD(d)) KEXCEPTION("FAILED TO SET DIRECTORY: " + d); + cwd = mkn::kul::env::CWD(); + if ( !mkn::kul::env::CWD(d)) KEXCEPTION("FAILED TO SET DIRECTORY: " + d); } } public: ~Call() { - if (d.size()) kul::env::CWD(cwd); + if (d.size()) mkn::kul::env::CWD(cwd); for (auto const &oldEv : oldEvs) - kul::env::SET(oldEv.first.c_str(), oldEv.second.c_str()); + mkn::kul::env::SET(oldEv.first.c_str(), oldEv.second.c_str()); } Call(std::string const &_s, std::string const &_d = "") : d(_d), s(_s) { setCWD(); } - Call(std::string const &_s, const kul::hash::map::S2S &evs, std::string const &_d = "") + Call(std::string const &_s, const mkn::kul::hash::map::S2S &evs, std::string const &_d = "") : d(_d), s(_s) { setCWD(); for (const auto &ev : evs) { - std::string const &v = kul::env::GET(ev.first.c_str()); + std::string const &v = mkn::kul::env::GET(ev.first.c_str()); if (v.size()) oldEvs.insert(ev.first, v); - kul::env::SET(ev.first.c_str(), ev.second.c_str()); + mkn::kul::env::SET(ev.first.c_str(), ev.second.c_str()); } } - int run() { return s.size() ? kul::os::exec(s) : 1; } + int run() { return s.size() ? mkn::kul::os::exec(s) : 1; } }; } // namespace proc @@ -110,7 +111,7 @@ class AProcess { const std::string d; std::function e, o; std::vector argv; - kul::hash::map::S2S evs; + mkn::kul::hash::map::S2S evs; friend std::ostream &operator<<(std::ostream &, const AProcess &); protected: @@ -126,12 +127,12 @@ class AProcess { virtual void preStart() {} virtual void finish() {} virtual void tearDown() {} - virtual void run() KTHROW(kul::Exception) = 0; + virtual void run() KTHROW(mkn::kul::Exception) = 0; bool waitForExit() const { return wfe; } void pid(const int32_t &_pi) { this->pi = _pi; } const std::vector &args() const { return argv; }; - const kul::hash::map::S2S &vars() const { return evs; } + const mkn::kul::hash::map::S2S &vars() const { return evs; } virtual void out(std::string const &_s) { if (this->o) this->o(_s); @@ -144,9 +145,9 @@ class AProcess { else fprintf(stderr, "%s", _s.c_str()); } - void error(const int16_t &line, std::string const &_s) KTHROW(kul::Exception) { + void error(const int16_t &line, std::string const &_s) KTHROW(mkn::kul::Exception) { tearDown(); - throw Exception("kul/proc.hpp", line, _s); + throw Exception("mkn/kul/proc.hpp", line, _s); } void exitCode(const int32_t &_e) { pec = _e; } @@ -164,19 +165,19 @@ class AProcess { } AProcess &args(std::string const &a) { if (a.size()) - for (const auto &c : kul::cli::asArgs(a)) argv.push_back(c); + for (const auto &c : mkn::kul::cli::asArgs(a)) argv.push_back(c); return *this; } AProcess &var(std::string const &n, std::string const &v) { evs[n] = v; return *this; } - AProcess &set(std::vector const &in) { + AProcess &set(std::vector const &in) { for (auto const &ev : in) evs[ev.name()] = ev.toString(); return *this; } - virtual inline void start() KTHROW(kul::Exception); + virtual inline void start() KTHROW(mkn::kul::Exception); virtual inline std::string toString() const; const int32_t &pid() const { return pi; } @@ -214,16 +215,17 @@ class ProcessCapture { } }; } // namespace kul +} // namespace mkn -#ifndef _KUL_COMPILED_LIB_ -#include "kul/src/proc.base/start.ipp" -#include "kul/src/proc.base/toString.ipp" +#ifndef _MKN_KUL_COMPILED_LIB_ +#include "mkn/kul/src/proc.base/start.ipp" +#include "mkn/kul/src/proc.base/toString.ipp" #endif #if defined(_WIN32) -#include "kul/os/win/proc.hpp" +#include "mkn/kul/os/win/proc.hpp" #else -#include "kul/os/nixish/proc.hpp" +#include "mkn/kul/os/nixish/proc.hpp" #endif -#endif // _KUL_PROC_HPP_ \ No newline at end of file +#endif // _MKN_KUL_PROC_HPP_ \ No newline at end of file diff --git a/inc/kul/scm.hpp b/inc/mkn/kul/scm.hpp similarity index 73% rename from inc/kul/scm.hpp rename to inc/mkn/kul/scm.hpp index 05a4b3e..d6e9103 100644 --- a/inc/kul/scm.hpp +++ b/inc/mkn/kul/scm.hpp @@ -28,26 +28,27 @@ 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. */ -#ifndef _KUL_SCM_HPP_ -#define _KUL_SCM_HPP_ +#ifndef _MKN_KUL_SCM_HPP_ +#define _MKN_KUL_SCM_HPP_ -#include "kul/map.hpp" -#include "kul/os.hpp" -#include "kul/proc.hpp" -#include "kul/string.hpp" +#include "mkn/kul/map.hpp" +#include "mkn/kul/os.hpp" +#include "mkn/kul/proc.hpp" +#include "mkn/kul/string.hpp" +namespace mkn { namespace kul { namespace scm { -class Exception : public kul::Exception { +class Exception : public mkn::kul::Exception { public: - Exception(char const *f, uint16_t const &l, std::string const &s) : kul::Exception(f, l, s) {} + Exception(char const *f, uint16_t const &l, std::string const &s) : mkn::kul::Exception(f, l, s) {} }; -class NotFoundException : public kul::Exception { +class NotFoundException : public mkn::kul::Exception { public: NotFoundException(char const *f, uint16_t const &l, std::string const &s) - : kul::Exception(f, l, s) {} + : mkn::kul::Exception(f, l, s) {} }; } // namespace scm @@ -79,47 +80,47 @@ namespace scm { class Git : public SCM { public: std::string defaultRemoteBranch(std::string const &repo) const override { - kul::Process p("git"); - kul::ProcessCapture pc(p); + mkn::kul::Process p("git"); + mkn::kul::ProcessCapture pc(p); p << "ls-remote" << "--symref" << repo << "HEAD"; ; try { - KLOG(DBG) << kul::String::LINES(pc.outs())[0]; + KLOG(DBG) << mkn::kul::String::LINES(pc.outs())[0]; p.start(); - } catch (kul::proc::ExitException const& e) { + } catch (mkn::kul::proc::ExitException const& e) { KEXCEPT(Exception, "SCM ERROR - Checking local branch") << p.toString(); } - auto ret = kul::String::SPLIT(kul::String::LINES(pc.outs())[0], "/").back(); + auto ret = mkn::kul::String::SPLIT(mkn::kul::String::LINES(pc.outs())[0], "/").back(); return ret.substr(0, ret.size() - 5); // HEAD+tab // e.g. git ls-remote --symref git@github.com:user/repo HEAD }; - std::string branch(kul::Dir const &dr) const { - kul::os::PushDir pushd(dr); - kul::Process p("git"); - kul::ProcessCapture pc(p); + std::string branch(mkn::kul::Dir const &dr) const { + mkn::kul::os::PushDir pushd(dr); + mkn::kul::Process p("git"); + mkn::kul::ProcessCapture pc(p); p << "branch" << "--show-current"; try { p.start(); - } catch (kul::proc::ExitException const& e) { + } catch (mkn::kul::proc::ExitException const& e) { KEXCEPT(Exception, "SCM ERROR - Checking local branch"); } - return kul::String::LINES(pc.outs())[0]; + return mkn::kul::String::LINES(pc.outs())[0]; } - std::string branch(std::string const &d) const { return branch(kul::Dir(d)); } + std::string branch(std::string const &d) const { return branch(mkn::kul::Dir(d)); } std::string co(std::string const &d, std::string const &r, std::string const &v) const KTHROW(Exception) override { Dir dr(d, true); - kul::Process p("git"); - p << "clone" << kul::env::GET("KUL_GIT_CO") << r; + mkn::kul::Process p("git"); + p << "clone" << mkn::kul::env::GET("KUL_GIT_CO") << r; if (!v.empty()) p.arg("-b").arg(v); try { p.arg(d).start(); - } catch (kul::proc::ExitException const& e) { + } catch (mkn::kul::proc::ExitException const& e) { dr.rm(); KEXCEPT(Exception, "SCM ERROR - Check remote dependency location / version"); } @@ -130,92 +131,92 @@ class Git : public SCM { if (!Dir(d).is()) co(d, r, v); else { - kul::Process p("git", d); + mkn::kul::Process p("git", d); p.arg("pull"); if (!r.empty()) p.arg(r); if (!r.empty() && !v.empty()) p.arg(v); try { p.start(); - } catch (kul::proc::ExitException const& e) { + } catch (mkn::kul::proc::ExitException const& e) { KEXCEPT(Exception, "SCM ERROR - Check remote dependency location / version"); } } } std::string origin(std::string const &d) const override { - kul::Process p("git", d); - kul::ProcessCapture pc(p); + mkn::kul::Process p("git", d); + mkn::kul::ProcessCapture pc(p); try { p.arg("remote").arg("-v").start(); - } catch (kul::proc::ExitException const& e) { + } catch (mkn::kul::proc::ExitException const& e) { KERR << pc.errs(); KEXCEPT(Exception, "SCM ERROR " + std::string(e.what())); } if (pc.outs().empty()) KEXCEPT(Exception, "SCM ERROR: Directory may not be git repository : " + d); std::vector lines; - kul::String::LINES(pc.outs(), lines); - for (auto &line : lines) kul::String::REPLACE_ALL(line, "\t", " "); - for (auto &line : lines) kul::String::REPLACE_ALL(line, " ", " "); - if (lines.size()) return kul::String::SPLIT(lines[0], ' ')[1]; + mkn::kul::String::LINES(pc.outs(), lines); + for (auto &line : lines) mkn::kul::String::REPLACE_ALL(line, "\t", " "); + for (auto &line : lines) mkn::kul::String::REPLACE_ALL(line, " ", " "); + if (lines.size()) return mkn::kul::String::SPLIT(lines[0], ' ')[1]; KEXCEPT(Exception, "SCM ERROR - Check remote dependency location / version"); } std::string localVersion(std::string const &d, std::string const &b) const override { - kul::Process p("git", d); - kul::ProcessCapture pc(p); + mkn::kul::Process p("git", d); + mkn::kul::ProcessCapture pc(p); try { p.arg("rev-parse").arg(b.empty() ? "HEAD" : b).start(); - } catch (kul::proc::ExitException const& e) { + } catch (mkn::kul::proc::ExitException const& e) { KERR << pc.errs(); KEXCEPT(Exception, "SCM ERROR " + std::string(e.what())); } if (pc.outs().empty()) KEXCEPT(Exception, "SCM ERROR: Directory may not be git repository : " + d); - return kul::String::LINES(pc.outs())[0]; + return mkn::kul::String::LINES(pc.outs())[0]; } std::string remoteVersion(std::string const &url, std::string const &b) const KTHROW(Exception) override { - kul::Process p("git"); - kul::ProcessCapture pc(p); + mkn::kul::Process p("git"); + mkn::kul::ProcessCapture pc(p); try { p.arg("ls-remote").arg(url).arg(b).start(); - } catch (kul::proc::ExitException const& e) { + } catch (mkn::kul::proc::ExitException const& e) { KERR << pc.errs(); KEXCEPT(Exception, "SCM ERROR " + std::string(e.what())); } if (pc.outs().empty()) KEXCEPT(Exception, "SCM ERROR URL OR BRANCH MAY NOT EXIST: " + url + " / " + b); - std::string s(kul::String::LINES(pc.outs())[0]); - kul::String::TRIM(s); + std::string s(mkn::kul::String::LINES(pc.outs())[0]); + mkn::kul::String::TRIM(s); return s.substr(0, s.find('\t')); } bool hasChanges(std::string const &d) const override { - kul::Process p("git", d); - kul::ProcessCapture pc(p); + mkn::kul::Process p("git", d); + mkn::kul::ProcessCapture pc(p); try { p.arg("status").arg("-sb").start(); - } catch (kul::proc::ExitException const& e) { + } catch (mkn::kul::proc::ExitException const& e) { KERR << pc.errs(); KEXCEPT(Exception, "SCM ERROR " + std::string(e.what())); } - return kul::String::LINES(pc.outs()).size() > 1; + return mkn::kul::String::LINES(pc.outs()).size() > 1; } void status(std::string const &d, bool full = 1) const override { - kul::Process p("git", d); + mkn::kul::Process p("git", d); try { p << "status"; if (!full) p << "--short"; p.start(); - } catch (kul::proc::ExitException const& e) { + } catch (mkn::kul::proc::ExitException const& e) { KEXCEPT(Exception, "SCM ERROR " + std::string(e.what())); } } void diff(std::string const &d) const override { - kul::Process p("git", d); + mkn::kul::Process p("git", d); try { p.arg("diff").start(); - } catch (kul::proc::ExitException const& e) { + } catch (mkn::kul::proc::ExitException const& e) { KEXCEPT(Exception, "SCM ERROR " + std::string(e.what())); } } @@ -225,13 +226,13 @@ class Git : public SCM { class Svn : public SCM { public: std::string co(std::string const&d, std::string const&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); +std::string &v) const KTHROW(Exception) { Dir dr(d, true); mkn::kul::Process p("svn", +d); p.arg("checkout").arg(mkn::kul::env::GET("KUL_SVN_CO")); if (v.empty()) p.arg(r); else p.arg(r + "/" + v); try { p.arg(".").start(); - } catch (kul::proc::ExitException const& e) { + } catch (mkn::kul::proc::ExitException const& e) { dr.rm(); KEXCEPT(Exception, "SCM ERROR - Check remote dependency location / version"); @@ -265,4 +266,5 @@ KEXCEPT(Exception, "SCM ERROR - SVN NOT IMPLEMENTED"); } } // namespace scm } // namespace kul -#endif /* _KUL_SCM_HPP_ */ +} // namespace mkn +#endif /* _MKN_KUL_SCM_HPP_ */ diff --git a/inc/kul/scm/man.hpp b/inc/mkn/kul/scm/man.hpp similarity index 93% rename from inc/kul/scm/man.hpp rename to inc/mkn/kul/scm/man.hpp index 7b50782..93905eb 100644 --- a/inc/kul/scm/man.hpp +++ b/inc/mkn/kul/scm/man.hpp @@ -28,11 +28,12 @@ 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. */ -#ifndef _KUL_SCM_MAN_HPP_ -#define _KUL_SCM_MAN_HPP_ +#ifndef _MKN_KUL_SCM_MAN_HPP_ +#define _MKN_KUL_SCM_MAN_HPP_ -#include "kul/scm.hpp" +#include "mkn/kul/scm.hpp" +namespace mkn { namespace kul { namespace scm { @@ -63,4 +64,5 @@ class Manager { } // namespace scm } // namespace kul -#endif /* _KUL_SCM_MAN_HPP_ */ +} // namespace mkn +#endif /* _MKN_KUL_SCM_MAN_HPP_ */ diff --git a/inc/kul/serial.hpp b/inc/mkn/kul/serial.hpp similarity index 95% rename from inc/kul/serial.hpp rename to inc/mkn/kul/serial.hpp index 996e616..b1f1a41 100644 --- a/inc/kul/serial.hpp +++ b/inc/mkn/kul/serial.hpp @@ -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. */ -#ifndef _KUL_SERIAL_HPP_ -#define _KUL_SERIAL_HPP_ +#ifndef _MKN_KUL_SERIAL_HPP_ +#define _MKN_KUL_SERIAL_HPP_ #if defined(_MKN_WITH_IO_CEREAL_) #include @@ -44,4 +44,4 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #endif // _MKN_WITH_IO_CEREAL_ -#endif // _KUL_SERIAL_HPP_ +#endif // _MKN_KUL_SERIAL_HPP_ diff --git a/inc/kul/serial/cli.arg.end.hpp b/inc/mkn/kul/serial/cli.arg.end.hpp similarity index 80% rename from inc/kul/serial/cli.arg.end.hpp rename to inc/mkn/kul/serial/cli.arg.end.hpp index e06ac6e..434df07 100644 --- a/inc/kul/serial/cli.arg.end.hpp +++ b/inc/mkn/kul/serial/cli.arg.end.hpp @@ -28,17 +28,17 @@ 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. */ -#ifndef _KUL_SERIAL_CLI_ARG_END_HPP_ -#define _KUL_SERIAL_CLI_ARG_END_HPP_ +#ifndef _MKN_KUL_SERIAL_CLI_ARG_END_HPP_ +#define _MKN_KUL_SERIAL_CLI_ARG_END_HPP_ #if defined(_MKN_WITH_IO_CEREAL_) template void save(Archive &ar) const { auto convert_to_std_map = - [](const kul::hash::map::S2S &s) -> std::unordered_map { + [](mkn::kul::hash::map::S2S const& s) -> std::unordered_map { std::unordered_map ret; - for (const auto &p : s) ret.emplace(p.first, p.second); + for (auto const& p : s) ret.emplace(p.first, p.second); return ret; }; ar(convert_to_std_map(vals)); @@ -46,9 +46,9 @@ void save(Archive &ar) const { template void load(Archive &ar) { auto convert_to_kul_map = - [](const std::unordered_map &s) -> kul::hash::map::S2S { - kul::hash::map::S2S ret; - for (const auto &p : s) ret.insert(p.first, p.second); + [](std::unordered_map const& s) -> mkn::kul::hash::map::S2S { + mkn::kul::hash::map::S2S ret; + for (auto const& p : s) ret.insert(p.first, p.second); return ret; }; std::unordered_map _vals; @@ -58,4 +58,4 @@ void load(Archive &ar) { #endif // _MKN_WITH_IO_CEREAL_ -#endif // _KUL_SERIAL_CLI_ARG_END_HPP_ +#endif // _MKN_KUL_SERIAL_CLI_ARG_END_HPP_ diff --git a/inc/kul/serial/cli.bottom.hpp b/inc/mkn/kul/serial/cli.bottom.hpp similarity index 87% rename from inc/kul/serial/cli.bottom.hpp rename to inc/mkn/kul/serial/cli.bottom.hpp index dd9d923..eeadb34 100644 --- a/inc/kul/serial/cli.bottom.hpp +++ b/inc/mkn/kul/serial/cli.bottom.hpp @@ -28,11 +28,11 @@ 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. */ -#ifndef _KUL_SERIAL_CLI_BOTTOM_HPP_ -#define _KUL_SERIAL_CLI_BOTTOM_HPP_ +#ifndef _MKN_KUL_SERIAL_CLI_BOTTOM_HPP_ +#define _MKN_KUL_SERIAL_CLI_BOTTOM_HPP_ #if defined(_MKN_WITH_IO_CEREAL_) -CEREAL_SPECIALIZE_FOR_ALL_ARCHIVES(kul::cli::Args, cereal::specialization::member_load_save) +CEREAL_SPECIALIZE_FOR_ALL_ARCHIVES(mkn::kul::cli::Args, cereal::specialization::member_load_save) #endif // _MKN_WITH_IO_CEREAL_ -#endif // _KUL_SERIAL_CLI_BOTTOM_HPP_ +#endif // _MKN_KUL_SERIAL_CLI_BOTTOM_HPP_ diff --git a/inc/kul/signal.hpp b/inc/mkn/kul/signal.hpp similarity index 88% rename from inc/kul/signal.hpp rename to inc/mkn/kul/signal.hpp index 2b1a163..cbf4518 100644 --- a/inc/kul/signal.hpp +++ b/inc/mkn/kul/signal.hpp @@ -28,15 +28,15 @@ 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. */ -#ifndef _KUL_SIGNAL_HPP_ -#define _KUL_SIGNAL_HPP_ +#ifndef _MKN_KUL_SIGNAL_HPP_ +#define _MKN_KUL_SIGNAL_HPP_ -#include "kul/defs.hpp" +#include "mkn/kul/defs.hpp" #if KUL_IS_WIN -#include "kul/os/win/signal.hpp" +#include "mkn/kul/os/win/signal.hpp" #else -#include "kul/os/nixish/signal.hpp" +#include "mkn/kul/os/nixish/signal.hpp" #endif -#endif // _KUL_SIGNAL_HPP_ \ No newline at end of file +#endif // _MKN_KUL_SIGNAL_HPP_ \ No newline at end of file diff --git a/inc/kul/span.hpp b/inc/mkn/kul/span.hpp similarity index 96% rename from inc/kul/span.hpp rename to inc/mkn/kul/span.hpp index fcb509e..1a71948 100644 --- a/inc/kul/span.hpp +++ b/inc/mkn/kul/span.hpp @@ -28,13 +28,14 @@ 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. */ -#ifndef _KUL_SPAN_HPP_ -#define _KUL_SPAN_HPP_ +#ifndef _MKN_KUL_SPAN_HPP_ +#define _MKN_KUL_SPAN_HPP_ #include #include -#include "kul/decltype.hpp" +#include "mkn/kul/decltype.hpp" +namespace mkn { namespace kul { @@ -142,5 +143,6 @@ struct SpanSet { } // namespace kul +} // namespace mkn -#endif /* _KUL_SPAN_HPP_ */ +#endif /* _MKN_KUL_SPAN_HPP_ */ diff --git a/inc/kul/src/cli/asArgs.ipp b/inc/mkn/kul/src/cli/asArgs.ipp similarity index 95% rename from inc/kul/src/cli/asArgs.ipp rename to inc/mkn/kul/src/cli/asArgs.ipp index 40fc0e2..1b8230c 100644 --- a/inc/kul/src/cli/asArgs.ipp +++ b/inc/mkn/kul/src/cli/asArgs.ipp @@ -28,9 +28,9 @@ 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. */ -// IWYU pragma: private, include "kul/cli.hpp" +// IWYU pragma: private, include "mkn/kul/cli.hpp" -void kul::cli::asArgs(const std::string& cmd, std::vector& args) { +void mkn::kul::cli::asArgs(const std::string& cmd, std::vector& args) { std::string arg; bool openQuotesS = false, openQuotesD = false, backSlashed = false; for (const char c : cmd) { diff --git a/inc/kul/src/proc.base/start.ipp b/inc/mkn/kul/src/proc.base/start.ipp similarity index 84% rename from inc/kul/src/proc.base/start.ipp rename to inc/mkn/kul/src/proc.base/start.ipp index 0767522..8e92cf9 100644 --- a/inc/kul/src/proc.base/start.ipp +++ b/inc/mkn/kul/src/proc.base/start.ipp @@ -28,20 +28,20 @@ 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. */ -// IWYU pragma: private, include "kul/proc.hpp" +// IWYU pragma: private, include "mkn/kul/proc.hpp" -void kul::AProcess::start() KTHROW(kul::Exception) { - if (this->s) KEXCEPT(kul::proc::Exception, "Process is already started"); +void mkn::kul::AProcess::start() KTHROW(mkn::kul::Exception) { + if (this->s) KEXCEPT(mkn::kul::proc::Exception, "Process is already started"); this->s = true; if (this->o || this->e) this->run(); else pec = proc::Call(toString(), evs, d).run(); if (pec != 0) - kul::LogMan::INSTANCE().err() + mkn::kul::LogMan::INSTANCE().err() ? throw proc::ExitException( __FILE__, __LINE__, pec, - "Process exit code: " + std::to_string(pec) + kul::os::EOL() + toString()) + "Process exit code: " + std::to_string(pec) + mkn::kul::os::EOL() + toString()) : throw proc::ExitException(__FILE__, __LINE__, pec, "Process exit code: " + std::to_string(pec)); } diff --git a/inc/kul/src/proc.base/toString.ipp b/inc/mkn/kul/src/proc.base/toString.ipp similarity index 93% rename from inc/kul/src/proc.base/toString.ipp rename to inc/mkn/kul/src/proc.base/toString.ipp index 2f36e63..353e3e7 100644 --- a/inc/kul/src/proc.base/toString.ipp +++ b/inc/mkn/kul/src/proc.base/toString.ipp @@ -28,9 +28,9 @@ 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. */ -// IWYU pragma: private, include "kul/proc.hpp" +// IWYU pragma: private, include "mkn/kul/proc.hpp" -std::string kul::AProcess::toString() const { +std::string mkn::kul::AProcess::toString() const { std::string _s; for (std::string const& a : args()) _s += a + " "; _s.pop_back(); diff --git a/inc/kul/string.hpp b/inc/mkn/kul/string.hpp similarity index 97% rename from inc/kul/string.hpp rename to inc/mkn/kul/string.hpp index 8fcca42..b85b7ef 100644 --- a/inc/kul/string.hpp +++ b/inc/mkn/kul/string.hpp @@ -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. */ -#ifndef _KUL_STRING_HPP_ -#define _KUL_STRING_HPP_ +#ifndef _MKN_KUL_STRING_HPP_ +#define _MKN_KUL_STRING_HPP_ #include #include @@ -39,16 +39,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include "kul/except.hpp" +#include "mkn/kul/except.hpp" +namespace mkn { namespace kul { enum STR_INT_RET { IS_SUCCESS = 0, IS_OVERFLOW, IS_UNDERFLOW, IS_INCONVERTIBLE }; -class StringException : public kul::Exception { +class StringException : public mkn::kul::Exception { public: StringException(char const *f, uint16_t const &l, std::string const &s) - : kul::Exception(f, l, s) {} + : mkn::kul::Exception(f, l, s) {} }; class String; @@ -307,4 +308,5 @@ class String { } }; } // namespace kul -#endif /* _KUL_STRING_HPP_ */ +} // namespace mkn +#endif /* _MKN_KUL_STRING_HPP_ */ diff --git a/inc/kul/sys.hpp b/inc/mkn/kul/sys.hpp similarity index 84% rename from inc/kul/sys.hpp rename to inc/mkn/kul/sys.hpp index 8b3977c..5b32e09 100644 --- a/inc/kul/sys.hpp +++ b/inc/mkn/kul/sys.hpp @@ -28,26 +28,28 @@ 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. */ -#ifndef _KUL_SYS_HPP_ -#define _KUL_SYS_HPP_ +#ifndef _MKN_KUL_SYS_HPP_ +#define _MKN_KUL_SYS_HPP_ -#include "kul/os.hpp" +#include "mkn/kul/os.hpp" +namespace mkn { namespace kul { namespace sys { -class Exception : public kul::Exception { +class Exception : public mkn::kul::Exception { public: - Exception(char const *f, uint16_t const &l, std::string const &s) : kul::Exception(f, l, s) {} + Exception(char const *f, uint16_t const &l, std::string const &s) : mkn::kul::Exception(f, l, s) {} }; } // namespace sys } // namespace kul +} // namespace mkn #if defined(_WIN32) -#include "kul/os/win/sys.hpp" +#include "mkn/kul/os/win/sys.hpp" #else -#include "kul/os/nixish/sys.hpp" +#include "mkn/kul/os/nixish/sys.hpp" #endif -#endif /* _KUL_SYS_HPP_ */ +#endif /* _MKN_KUL_SYS_HPP_ */ diff --git a/inc/kul/threads.hpp b/inc/mkn/kul/threads.hpp similarity index 85% rename from inc/kul/threads.hpp rename to inc/mkn/kul/threads.hpp index 2e215fc..6c78ad5 100644 --- a/inc/kul/threads.hpp +++ b/inc/mkn/kul/threads.hpp @@ -28,12 +28,13 @@ 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. */ -#ifndef _KUL_THREADS_HPP_ -#define _KUL_THREADS_HPP_ +#ifndef _MKN_KUL_THREADS_HPP_ +#define _MKN_KUL_THREADS_HPP_ -#include "kul/map.hpp" -#include "kul/os/threads.hpp" +#include "mkn/kul/map.hpp" +#include "mkn/kul/os/threads.hpp" +namespace mkn { namespace kul { class ScopeLock { @@ -49,19 +50,19 @@ class ThreadQueue { protected: bool d = 0, f = 0, s = 0; uint16_t m = 1; - kul::Thread th; + mkn::kul::Thread th; std::function func; - std::vector> ts; + std::vector> ts; std::vector ePs; void setStarted() { s = true; } virtual void start() KTHROW(std::exception) { if (started()) KEXCEPT(Exception, "ThreadQueue is already started"); setStarted(); for (uint16_t i = 0; i < m; i++) { - std::shared_ptr at = std::make_shared(func); + std::shared_ptr at = std::make_shared(func); at->run(); ts.push_back(at); - this_thread::nSleep(__KUL_THREAD_SPAWN_WAIT__); + this_thread::nSleep(__MKN_KUL_THREAD_SPAWN_WAIT__); } } @@ -78,7 +79,7 @@ class ThreadQueue { virtual void join() KTHROW(std::exception) { th.join(); while (ts.size()) { - const std::shared_ptr *del = 0; + const std::shared_ptr *del = 0; for (const auto &t : ts) { if (t->finished()) { t->join(); @@ -98,7 +99,7 @@ class ThreadQueue { d = true; th.detach(); } - void interrupt() KTHROW(kul::threading::InterruptionException) {} + void interrupt() KTHROW(mkn::kul::threading::InterruptionException) {} const std::vector exceptionPointers() { return ePs; } bool started() { return s; } bool finished() { return f; } @@ -118,12 +119,12 @@ class PredicatedThreadQueue : public ThreadQueue { while (c < ps) { for (size_t i = ts.size(); i < m && c < ps; i++) { c++; - std::shared_ptr at = std::make_shared(func); + std::shared_ptr at = std::make_shared(func); at->run(); ts.push_back(at); - this_thread::nSleep(__KUL_THREAD_SPAWN_WAIT__); + this_thread::nSleep(__MKN_KUL_THREAD_SPAWN_WAIT__); } - const std::shared_ptr *del = 0; + const std::shared_ptr *del = 0; for (const auto &t : ts) { if (t->finished()) { t->join(); @@ -150,20 +151,20 @@ class PredicatedThreadQueue : public ThreadQueue { : ThreadQueue(ref), p(pr), ps(p.size()) {} }; -template +template class ConcurrentThreadQueue { - friend class kul::Thread; + friend class mkn::kul::Thread; protected: size_t _cur = 0, _max = 1; const uint64_t m_nWait; std::atomic _block, _detatched, _up; std::queue, std::function>>> _q; - kul::hash::map::S2T> _k; - kul::hash::map::S2T> _e; + mkn::kul::hash::map::S2T> _k; + mkn::kul::hash::map::S2T> _e; - kul::Thread _thread; - kul::Mutex _mmutex, _qmutex; + mkn::kul::Thread _thread; + mkn::kul::Mutex _mmutex, _qmutex; void _KTHROW(const std::exception_ptr &ep, const std::function &func) { try { @@ -176,24 +177,24 @@ class ConcurrentThreadQueue { while (_up) { this_thread::nSleep(m_nWait); { - kul::ScopeLock l(_qmutex); + mkn::kul::ScopeLock l(_qmutex); if (_q.empty()) continue; } for (; _cur < _max; _cur++) { - kul::ScopeLock l(_qmutex); + mkn::kul::ScopeLock l(_qmutex); auto &f_ptr(_q.front()); auto &f(*f_ptr.get()); std::stringstream ss; ss << &f; auto k(ss.str()); - _k.insert(k, std::make_shared(f.first)); + _k.insert(k, std::make_shared(f.first)); _e.insert(k, f.second); _k[k]->run(); _q.pop(); } - kul::hash::set::String del; + mkn::kul::hash::set::String del; for (const auto &t : _k) { if (t.second->finished()) { t.second->join(); @@ -238,15 +239,15 @@ class ConcurrentThreadQueue { return *this; } virtual ConcurrentThreadQueue &interrupt() { - kul::ScopeLock l(_mmutex); + mkn::kul::ScopeLock l(_mmutex); _thread.interrupt(); return *this; } - virtual ConcurrentThreadQueue &finish(const uint64_t &nWait = 1000000) KTHROW(kul::Exception) { + virtual ConcurrentThreadQueue &finish(const uint64_t &nWait = 1000000) KTHROW(mkn::kul::Exception) { while (_up) { this_thread::nSleep(nWait); { - kul::ScopeLock l(_qmutex); + mkn::kul::ScopeLock l(_qmutex); if (_q.empty()) stop(); } } @@ -274,13 +275,13 @@ class ConcurrentThreadQueue { { auto pair = std::unique_ptr, std::function>>( new std::pair, std::function>(function, exception)); - kul::ScopeLock l(_qmutex); + mkn::kul::ScopeLock l(_qmutex); _q.push(std::move(pair)); } return true; } - const std::exception_ptr &exception() { return _thread.exception(); } + std::exception_ptr const& exception() const { return _thread.exception(); } void rethrow() { if (_thread.exception()) std::rethrow_exception(_thread.exception()); @@ -298,7 +299,7 @@ class PoolThread { const uint64_t m_nWait; std::atomic m_ready, m_run; std::function m_function; - kul::Mutex _mutex; + mkn::kul::Mutex _mutex; bool if_ready_set(const std::function &f) { if (!m_ready) return false; @@ -332,19 +333,19 @@ class PoolThread { } }; -template +template class ConcurrentThreadPool : public ConcurrentThreadQueue { protected: - kul::hash::map::S2T> _p; + mkn::kul::hash::map::S2T> _p; virtual bool operate() { bool qEmpty = 0; { - kul::ScopeLock l(_qmutex); + mkn::kul::ScopeLock l(_qmutex); qEmpty = _q.empty(); } if (!qEmpty) { - kul::ScopeLock l(_qmutex); + mkn::kul::ScopeLock l(_qmutex); for (size_t i = 0; i < _max; i++) { const auto n = std::to_string(i); auto &f_ptr(_q.front()); @@ -359,7 +360,7 @@ class ConcurrentThreadPool : public ConcurrentThreadQueue { std::vector del; { if (!_up) return false; - kul::ScopeLock l(_mmutex); + mkn::kul::ScopeLock l(_mmutex); for (const auto &t : _k) { if (t.second->started() && t.second->finished()) { if (t.second->exception() != std::exception_ptr()) { @@ -374,7 +375,7 @@ class ConcurrentThreadPool : public ConcurrentThreadQueue { } } { - kul::ScopeLock l(_mmutex); + mkn::kul::ScopeLock l(_mmutex); if (!_up) return false; for (const auto &n : del) { _k[n]->join(); @@ -382,7 +383,7 @@ class ConcurrentThreadPool : public ConcurrentThreadQueue { _k.erase(n); _p.erase(n); _p.insert(n, std::make_shared()); - _k.insert(n, std::make_shared(std::ref(*_p[n].get()))); + _k.insert(n, std::make_shared(std::ref(*_p[n].get()))); _k[n]->run(); } } @@ -406,7 +407,7 @@ class ConcurrentThreadPool : public ConcurrentThreadQueue { for (size_t i = 0; i < max; i++) { auto n = std::to_string(i); _p.insert(n, std::make_shared()); - _k.insert(n, std::make_shared(std::ref(*_p[n].get()))); + _k.insert(n, std::make_shared(std::ref(*_p[n].get()))); } _p.setDeletedKey(""); if (strt) start(); @@ -425,17 +426,17 @@ class ConcurrentThreadPool : public ConcurrentThreadQueue { } virtual ConcurrentThreadPool &stop() override { _up = 0; - kul::ScopeLock l(_mmutex); + mkn::kul::ScopeLock l(_mmutex); for (auto &t : _p) t.second->stop(); return *this; } virtual ConcurrentThreadPool &finish(const uint64_t &nWait = 1000000) - KTHROW(kul::Exception) override { + KTHROW(mkn::kul::Exception) override { while (_up && !_thread.exception()) { this_thread::nSleep(nWait); { - kul::ScopeLock l1(_qmutex); - kul::ScopeLock l2(_mmutex); + mkn::kul::ScopeLock l1(_qmutex); + mkn::kul::ScopeLock l2(_mmutex); if (_q.empty()) { size_t i; for (i = 0; i < _max; i++) @@ -450,14 +451,14 @@ class ConcurrentThreadPool : public ConcurrentThreadQueue { return *this; } virtual ConcurrentThreadPool &interrupt() override { - kul::ScopeLock l(_mmutex); + mkn::kul::ScopeLock l(_mmutex); _thread.interrupt(); for (auto &t : _k) t.second->interrupt(); return *this; } virtual ConcurrentThreadPool &join() override { _thread.join(); - kul::ScopeLock l(_mmutex); + mkn::kul::ScopeLock l(_mmutex); for (auto &t : _k) if (t.second->started()) t.second->join(); return *this; @@ -465,7 +466,7 @@ class ConcurrentThreadPool : public ConcurrentThreadQueue { virtual ConcurrentThreadPool &detach() override { if (_up) { _thread.detach(); - kul::ScopeLock l(_mmutex); + mkn::kul::ScopeLock l(_mmutex); for (auto &t : _k) t.second->detach(); } return *this; @@ -494,7 +495,7 @@ class AutoChronPoolThread : public PoolThread { } }; -template +template class ChroncurrentThreadPool : public ConcurrentThreadPool { protected: uint64_t m_scale = 0; @@ -525,5 +526,6 @@ class ChroncurrentThreadPool : public ConcurrentThreadPool #include #include -#include "kul/string.hpp" +#include "mkn/kul/string.hpp" +namespace mkn { namespace kul { namespace time { -class Exception : public kul::Exception { +class Exception : public mkn::kul::Exception { public: - Exception(char const *f, const int l, std::string const &s) : kul::Exception(f, l, s) {} + Exception(char const *f, const int l, std::string const &s) : mkn::kul::Exception(f, l, s) {} }; } // namespace time @@ -73,7 +74,7 @@ class DateTime { public: static const std::string AS(const std::time_t t, std::string f = "%Y-%m-%d-%H:%M:%S") { - kul::String::REPLACE(f, "%i", MILLIS()); + mkn::kul::String::REPLACE(f, "%i", MILLIS()); char buffer[80]; struct tm ti; #ifdef _WIN32 @@ -97,4 +98,5 @@ class DateTime { } }; } // namespace kul -#endif /* _KUL_TIME_HPP_ */ +} // namespace mkn +#endif /* _MKN_KUL_TIME_HPP_ */ diff --git a/inc/kul/tuple.hpp b/inc/mkn/kul/tuple.hpp similarity index 95% rename from inc/kul/tuple.hpp rename to inc/mkn/kul/tuple.hpp index 403c0ee..09043b6 100644 --- a/inc/kul/tuple.hpp +++ b/inc/mkn/kul/tuple.hpp @@ -28,13 +28,14 @@ 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. */ -#ifndef _KUL_TUPLE_HPP_ -#define _KUL_TUPLE_HPP_ +#ifndef _MKN_KUL_TUPLE_HPP_ +#define _MKN_KUL_TUPLE_HPP_ #include #include -#include "kul/for.hpp" +#include "mkn/kul/for.hpp" +namespace mkn { namespace kul { template @@ -93,5 +94,6 @@ constexpr auto tuple_from(T t) { } } // namespace kul +} // namespace mkn -#endif /* _KUL_TUPLE_HPP_ */ +#endif /* _MKN_KUL_TUPLE_HPP_ */ diff --git a/inc/kul/wstring.hpp b/inc/mkn/kul/wstring.hpp similarity index 96% rename from inc/kul/wstring.hpp rename to inc/mkn/kul/wstring.hpp index 0061028..3dbdace 100644 --- a/inc/kul/wstring.hpp +++ b/inc/mkn/kul/wstring.hpp @@ -28,14 +28,15 @@ 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. */ -#ifndef _KUL_WSTRING_HPP_ -#define _KUL_WSTRING_HPP_ +#ifndef _MKN_KUL_WSTRING_HPP_ +#define _MKN_KUL_WSTRING_HPP_ #include #include #include #include +namespace mkn { namespace kul { class WString { @@ -83,4 +84,5 @@ class WString { } }; } // namespace kul -#endif /* _KUL_WSTRING_HPP_ */ +} // namespace mkn +#endif /* _MKN_KUL_WSTRING_HPP_ */ diff --git a/inc/kul/yaml.hpp b/inc/mkn/kul/yaml.hpp similarity index 92% rename from inc/kul/yaml.hpp rename to inc/mkn/kul/yaml.hpp index a2be45f..baaee50 100644 --- a/inc/kul/yaml.hpp +++ b/inc/mkn/kul/yaml.hpp @@ -37,24 +37,25 @@ or via cli mkn build -w parse.yaml */ -#ifndef _KUL_YAML_HPP_ -#define _KUL_YAML_HPP_ +#ifndef _MKN_KUL_YAML_HPP_ +#define _MKN_KUL_YAML_HPP_ -#include "kul/dbg.hpp" -#include "kul/io.hpp" -#include "kul/map.hpp" +#include "mkn/kul/dbg.hpp" +#include "mkn/kul/io.hpp" +#include "mkn/kul/map.hpp" #include "yaml-cpp/yaml.h" +namespace mkn { namespace kul { namespace yaml { class Validator; class NodeValidator; -class Exception : public kul::Exception { +class Exception : public mkn::kul::Exception { public: - Exception(char const *f, uint16_t const &l, std::string const &s) : kul::Exception(f, l, s) {} + Exception(char const *f, uint16_t const &l, std::string const &s) : mkn::kul::Exception(f, l, s) {} }; enum NodeType { NON = 0, STRING, LIST, MAP }; @@ -93,7 +94,7 @@ class Item { static void VALIDATE(YAML::Node const &n, const std::vector &nvs) KTHROW(Exception) { KUL_DBG_FUNC_ENTER - kul::hash::set::String keys; + mkn::kul::hash::set::String keys; for (const auto &nv : nvs) if (nv.name() == "*") return; @@ -155,7 +156,7 @@ class File : public Item { T file(f); try { Item::VALIDATE(file.root(), file.validator().children()); - } catch (const kul::yaml::Exception &e) { + } catch (const mkn::kul::yaml::Exception &e) { KEXCEPTION("YAML error encountered in file: " + f); } return file; @@ -173,7 +174,7 @@ class File : public Item { } } File(File const &f) : Item(f.r), f(f.f) {} - File(kul::File const &f) KTHROW(Exception) : f(f.real()) { reload(); } + File(mkn::kul::File const &f) KTHROW(Exception) : f(f.real()) { reload(); } File(std::string const &f) KTHROW(Exception) : f(f) { reload(); } private: @@ -181,4 +182,5 @@ class File : public Item { }; } // namespace yaml } // namespace kul -#endif /* _KUL_YAML_HPP_ */ +} // namespace mkn +#endif /* _MKN_KUL_YAML_HPP_ */ diff --git a/mkn.yaml b/mkn.yaml index 7a2576f..abe48f5 100644 --- a/mkn.yaml +++ b/mkn.yaml @@ -26,7 +26,7 @@ profile: if_src: bsd: ./src/os/nixish nix: ./src/os/nixish - arg: -D_KUL_COMPILED_LIB_ + arg: -D_MKN_KUL_COMPILED_LIB_ - name: test parent: lib diff --git a/src/all/asArgs.cpp b/src/all/asArgs.cpp index a9ba6a6..372955e 100644 --- a/src/all/asArgs.cpp +++ b/src/all/asArgs.cpp @@ -28,6 +28,6 @@ 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 "mkn/kul/cli.hpp" -#include "kul/src/cli/asArgs.ipp" +#include "mkn/kul/src/cli/asArgs.ipp" diff --git a/src/all/proc.base.cpp b/src/all/proc.base.cpp index 50c1d26..4358b19 100644 --- a/src/all/proc.base.cpp +++ b/src/all/proc.base.cpp @@ -28,7 +28,7 @@ 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/log.hpp" +#include "mkn/kul/log.hpp" -#include "kul/src/proc.base/start.ipp" -#include "kul/src/proc.base/toString.ipp" +#include "mkn/kul/src/proc.base/start.ipp" +#include "mkn/kul/src/proc.base/toString.ipp" diff --git a/src/os/nix/proc.os.cpp b/src/os/nix/proc.os.cpp index 4c515cc..792c40b 100644 --- a/src/os/nix/proc.os.cpp +++ b/src/os/nix/proc.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/proc.hpp" +#include "mkn/kul/proc.hpp" -#include "kul/os/nix/src/proc/xparse_line.ipp" -#include "kul/os/nix/src/proc/xphysical.ipp" -#include "kul/os/nix/src/proc/xvirtual.ipp" +#include "mkn/kul/os/nix/src/proc/xparse_line.ipp" +#include "mkn/kul/os/nix/src/proc/xphysical.ipp" +#include "mkn/kul/os/nix/src/proc/xvirtual.ipp" diff --git a/src/os/nixish/cli.os.cpp b/src/os/nixish/cli.os.cpp index 5f2cf04..bd3c0c2 100644 --- a/src/os/nixish/cli.os.cpp +++ b/src/os/nixish/cli.os.cpp @@ -29,7 +29,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include -#include "kul/cli.hpp" +#include "mkn/kul/cli.hpp" -#include "kul/os/nixish/src/cli/hidden.ipp" -#include "kul/os/nixish/src/cli/show.ipp" +#include "mkn/kul/os/nixish/src/cli/hidden.ipp" +#include "mkn/kul/os/nixish/src/cli/show.ipp" diff --git a/src/os/nixish/os.cpp b/src/os/nixish/os.cpp index 3a6020f..22bd398 100644 --- a/src/os/nixish/os.cpp +++ b/src/os/nixish/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/os.hpp" +#include "mkn/kul/os.hpp" -#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/Xreal.ipp" +#include "mkn/kul/os/nixish/src/os/dir/dirs.ipp" +#include "mkn/kul/os/nixish/src/os/dir/files.ipp" +#include "mkn/kul/os/nixish/src/os/dir/Xreal.ipp" diff --git a/src/os/nixish/proc.cpp b/src/os/nixish/proc.cpp index 92775ae..7d33069 100644 --- a/src/os/nixish/proc.cpp +++ b/src/os/nixish/proc.cpp @@ -28,11 +28,11 @@ 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/proc.hpp" +#include "mkn/kul/proc.hpp" -#include "kul/os/nixish/src/proc/child.cpp" -#include "kul/os/nixish/src/proc/expand.cpp" -#include "kul/os/nixish/src/proc/waitForStatus.cpp" -#include "kul/os/nixish/src/proc/waitExit.cpp" -#include "kul/os/nixish/src/proc/tearDown.cpp" -#include "kul/os/nixish/src/proc/tearDown.cpp" +#include "mkn/kul/os/nixish/src/proc/child.cpp" +#include "mkn/kul/os/nixish/src/proc/expand.cpp" +#include "mkn/kul/os/nixish/src/proc/waitForStatus.cpp" +#include "mkn/kul/os/nixish/src/proc/waitExit.cpp" +#include "mkn/kul/os/nixish/src/proc/tearDown.cpp" +#include "mkn/kul/os/nixish/src/proc/tearDown.cpp" diff --git a/src/os/nixish/signal.cpp b/src/os/nixish/signal.cpp index 793588f..7575c52 100644 --- a/src/os/nixish/signal.cpp +++ b/src/os/nixish/signal.cpp @@ -28,6 +28,6 @@ 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/signal.hpp" +#include "mkn/kul/signal.hpp" -#include "kul/os/nixish/src/signal/handler.ipp" +#include "mkn/kul/os/nixish/src/signal/handler.ipp" diff --git a/src/os/win/cli.os.cpp b/src/os/win/cli.os.cpp index 780ce62..c9584f2 100644 --- a/src/os/win/cli.os.cpp +++ b/src/os/win/cli.os.cpp @@ -28,12 +28,12 @@ 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 "mkn/kul/cli.hpp" -std::string kul::cli::hidden(std::string const& t) { -#include "kul/os/win/src/cli/hidden.cpp" +std::string mkn::kul::cli::hidden(std::string const& t) { +#include "mkn/kul/os/win/src/cli/hidden.cpp" } -void kul::cli::show() { -#include "kul/os/win/src/cli/show.cpp" +void mkn::kul::cli::show() { +#include "mkn/kul/os/win/src/cli/show.cpp" } \ No newline at end of file diff --git a/src/os/win/os.cpp b/src/os/win/os.cpp index 63f80a8..8279892 100644 --- a/src/os/win/os.cpp +++ b/src/os/win/os.cpp @@ -28,18 +28,18 @@ 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/os.hpp" +#include "mkn/kul/os.hpp" -// std::vector kul::Dir::dirs(bool incHidden) const -// KTHROW(kul::fs::Exception){ -#include "kul/os/win/src/os/dir/dirs.ipp" +// std::vector mkn::kul::Dir::dirs(bool incHidden) const +// KTHROW(mkn::kul::fs::Exception){ +#include "mkn/kul/os/win/src/os/dir/dirs.ipp" // } -// std::vector kul::Dir::files(bool recursive) const -// KTHROW(kul::fs::Exception){ -#include "kul/os/win/src/os/dir/files.ipp" +// std::vector mkn::kul::Dir::files(bool recursive) const +// KTHROW(mkn::kul::fs::Exception){ +#include "mkn/kul/os/win/src/os/dir/files.ipp" // } -// std::string kul::Dir::REAL(std::string const&s) KTHROW(fs::Exception) { -#include "kul/os/win/src/os/dir/Xreal.ipp" +// std::string mkn::kul::Dir::REAL(std::string const&s) KTHROW(fs::Exception) { +#include "mkn/kul/os/win/src/os/dir/Xreal.ipp" // } diff --git a/src/os/win/proc.cpp b/src/os/win/proc.cpp index 44017f7..7617e9c 100644 --- a/src/os/win/proc.cpp +++ b/src/os/win/proc.cpp @@ -28,16 +28,16 @@ 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/proc.hpp" +#include "mkn/kul/proc.hpp" -void kul::Process::expand(std::string &s) const { -#include "kul/src/proc/expand.cpp" +void mkn::kul::Process::expand(std::string &s) const { +#include "mkn/kul/src/proc/expand.cpp" } -void kul::Process::tearDown() { -#include "kul/src/proc/tearDown.cpp" +void mkn::kul::Process::tearDown() { +#include "mkn/kul/src/proc/tearDown.cpp" } -void kul::Process::run() KTHROW(kul::proc::Exception) { -#include "kul/src/proc/tearDown.cpp" +void mkn::kul::Process::run() KTHROW(mkn::kul::proc::Exception) { +#include "mkn/kul/src/proc/tearDown.cpp" } diff --git a/src/os/win/signal.cpp b/src/os/win/signal.cpp index 1ae8fbb..5fb4890 100644 --- a/src/os/win/signal.cpp +++ b/src/os/win/signal.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/signal.hpp" +#include "mkn/kul/signal.hpp" void kul_real_se_handler(EXCEPTION_POINTERS *pExceptionInfo) { -#include "kul/src/signal/se_handler.cpp" +#include "mkn/kul/src/signal/se_handler.cpp" } diff --git a/src/os/win/thread.os.cpp b/src/os/win/thread.os.cpp index d9c7aa0..689dc1f 100644 --- a/src/os/win/thread.os.cpp +++ b/src/os/win/thread.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/threads.hpp" +#include "mkn/kul/threads.hpp" -bool kul::this_thread::main() { -#include "kul/os/win/src/thread/main.cpp" +bool mkn::kul::this_thread::main() { +#include "mkn/kul/os/win/src/thread/main.cpp" } diff --git a/test/bench.cpp b/test/bench.cpp index 4316dd3..c1feea2 100644 --- a/test/bench.cpp +++ b/test/bench.cpp @@ -29,10 +29,10 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "kul/cli.hpp" -#include "kul/log.hpp" -#include "kul/os.hpp" -#include "kul/threads.hpp" +#include "mkn/kul/cli.hpp" +#include "mkn/kul/log.hpp" +#include "mkn/kul/os.hpp" +#include "mkn/kul/threads.hpp" #if __has_include("benchmark/benchmark.h") #include "benchmark/benchmark.h" @@ -42,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. void createDeleteFile(benchmark::State &state) { while (state.KeepRunning()) { - kul::File f("tmp.tmp"); + mkn::kul::File f("tmp.tmp"); f.mk(); f.rm(); } @@ -52,7 +52,7 @@ BENCHMARK(createDeleteFile)->Unit(benchmark::kMicrosecond); void parseStringAsCommandLineArguments(benchmark::State &state) { while (state.KeepRunning()) { std::vector v; - kul::cli::asArgs("/path/to \"words in quotes\" words\\ not\\ in\\ quotes end", v); + mkn::kul::cli::asArgs("/path/to \"words in quotes\" words\\ not\\ in\\ quotes end", v); } } BENCHMARK(parseStringAsCommandLineArguments)->Unit(benchmark::kMicrosecond); @@ -60,7 +60,7 @@ BENCHMARK(parseStringAsCommandLineArguments)->Unit(benchmark::kMicrosecond); void splitStringByChar(benchmark::State &state) { while (state.KeepRunning()) { std::vector v; - kul::String::SPLIT("split - by - char - dash", '-', v); + mkn::kul::String::SPLIT("split - by - char - dash", '-', v); } } BENCHMARK(splitStringByChar)->Unit(benchmark::kMicrosecond); @@ -68,7 +68,7 @@ BENCHMARK(splitStringByChar)->Unit(benchmark::kMicrosecond); void splitStringByString(benchmark::State &state) { while (state.KeepRunning()) { std::vector v; - kul::String::SPLIT("split - by - char - dash", "-", v); + mkn::kul::String::SPLIT("split - by - char - dash", "-", v); } } BENCHMARK(splitStringByString)->Unit(benchmark::kMicrosecond); @@ -76,7 +76,7 @@ BENCHMARK(splitStringByString)->Unit(benchmark::kMicrosecond); void splitStringByEscapedChar(benchmark::State &state) { while (state.KeepRunning()) { std::vector v; - kul::String::ESC_SPLIT("split \\- by - char - dash", '-', v); + mkn::kul::String::ESC_SPLIT("split \\- by - char - dash", '-', v); } } BENCHMARK(splitStringByEscapedChar)->Unit(benchmark::kMicrosecond); @@ -88,7 +88,7 @@ auto lambda = [](uint a, uint b) { void concurrentThreadPool(benchmark::State &state) { while (state.KeepRunning()) { - kul::ConcurrentThreadPool<> ctp(3, 1); + mkn::kul::ConcurrentThreadPool<> ctp(3, 1); for (size_t i = 0; i < 10000; i++) ctp.async(std::bind(lambda, 2, 4)); ctp.block().finish().join(); } @@ -97,7 +97,7 @@ BENCHMARK(concurrentThreadPool)->Unit(benchmark::kMicrosecond); void chroncurrentThreadPool(benchmark::State &state) { while (state.KeepRunning()) { - kul::ChroncurrentThreadPool<> ctp(3, 1); + mkn::kul::ChroncurrentThreadPool<> ctp(3, 1); for (size_t i = 0; i < 10000; i++) ctp.async(std::bind(lambda, 2, 4)); ctp.block().finish().join(); } diff --git a/test/test.cpp b/test/test.cpp index 7b3ca77..4de3d22 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -32,16 +32,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "kul/assert.hpp" -#include "kul/cli.hpp" -#include "kul/io.hpp" -#include "kul/log.hpp" -#include "kul/math.hpp" -#include "kul/os.hpp" -#include "kul/proc.hpp" -#include "kul/threads.hpp" -#include "kul/span.hpp" -#include "kul/tuple.hpp" +#include "mkn/kul/assert.hpp" +#include "mkn/kul/cli.hpp" +#include "mkn/kul/io.hpp" +#include "mkn/kul/log.hpp" +#include "mkn/kul/math.hpp" +#include "mkn/kul/os.hpp" +#include "mkn/kul/proc.hpp" +#include "mkn/kul/threads.hpp" +#include "mkn/kul/span.hpp" +#include "mkn/kul/tuple.hpp" #ifdef _WIN32 #define bzero ZeroMemory @@ -51,7 +51,7 @@ auto tryCatch = [](std::vector> funcs, bool katch) { for (const auto &func : funcs) try { func(); ASSERT_TRUE(!katch); - } catch (const kul::Exception &e) { + } catch (const mkn::kul::Exception &e) { if (!katch) KOUT(NON) << e.debug(); ASSERT_TRUE(katch); } diff --git a/test/test/cli.ipp b/test/test/cli.ipp index 93b56b4..55f013f 100644 --- a/test/test/cli.ipp +++ b/test/test/cli.ipp @@ -2,7 +2,7 @@ TEST(CLI_Test, ParseCommandLineArguments) { std::vector v; - kul::cli::asArgs("/path/to \"words in quotes\" words\\ not\\ in\\ quotes end", v); + mkn::kul::cli::asArgs("/path/to \"words in quotes\" words\\ not\\ in\\ quotes end", v); EXPECT_EQ((size_t)4, v.size()); EXPECT_EQ("/path/to", v[0]); EXPECT_EQ("words in quotes", v[1]); diff --git a/test/test/except.ipp b/test/test/except.ipp index 0215f28..2355551 100644 --- a/test/test/except.ipp +++ b/test/test/except.ipp @@ -3,7 +3,7 @@ TEST(Exception, String) { std::string full = "FAILURE"; try { - KEXCEPT(kul::Exception, "FAIL") << "URE"; + KEXCEPT(mkn::kul::Exception, "FAIL") << "URE"; } catch (std::exception const& e) { EXPECT_EQ(e.what(), full); } diff --git a/test/test/io.ipp b/test/test/io.ipp index 35e08c2..cc734eb 100644 --- a/test/test/io.ipp +++ b/test/test/io.ipp @@ -1,7 +1,7 @@ TEST(IO_Test, ReadFileLine) { - kul::io::Reader r("LICENSE.md"); + mkn::kul::io::Reader r("LICENSE.md"); const char* c = r.readLine(); std::string s1 = c, s2; while ((c = r.readLine())) s2 = c; @@ -11,9 +11,9 @@ TEST(IO_Test, ReadFileLine) { TEST(IO_Test, ReadFile) { char c[20] = {0}; bzero(c, 20); - kul::File file("LICENSE.md"); - if (!file) KEXCEPT(kul::Exception, "ReadFile: FileNotFound: ") << file.full(); - kul::io::Reader r("LICENSE.md"); + mkn::kul::File file("LICENSE.md"); + if (!file) KEXCEPT(mkn::kul::Exception, "ReadFile: FileNotFound: ") << file.full(); + mkn::kul::io::Reader r("LICENSE.md"); r.read(c, 20); std::string s1 = c; std::stringstream ss; @@ -28,7 +28,7 @@ TEST(IO_Test, ReadFile) { // Travis has a tough time with this one #if defined(_MKN_TEST_BINARY_READING_) TEST(IO_Test, ReadBinaryFileLine) { - kul::io::BinaryReader r("LICENSE.md"); + mkn::kul::io::BinaryReader r("LICENSE.md"); const char* c = r.readLine(); std::string s1 = c, s2; while ((c = r.readLine())) s2 = c; @@ -38,7 +38,7 @@ TEST(IO_Test, ReadBinaryFileLine) { TEST(IO_Test, ReadBinaryFile) { char c[20] = {0}; bzero(c, 20); - kul::io::BinaryReader r("LICENSE.md"); + mkn::kul::io::BinaryReader r("LICENSE.md"); r.read(c, 20); std::string s1 = c; KLOG(INF) << s1.size(); diff --git a/test/test/math.ipp b/test/test/math.ipp index ed2e845..a779a2c 100644 --- a/test/test/math.ipp +++ b/test/test/math.ipp @@ -4,10 +4,10 @@ template void do_math() { T beta = 2; T a[2] = {1, 2}, b[2] = {3, 4}; - kul::math::dot_matrix_vector_incr(2, 2, 2, &a[0], &b[0], beta, &b[0]); - kul::math::dot(2u, &a[0], &b[0]); - kul::math::scale(2u, 2u, &a[0]); - kul::math::mult_incr(2u, 2u, &a[0], &b[0]); + mkn::kul::math::dot_matrix_vector_incr(2, 2, 2, &a[0], &b[0], beta, &b[0]); + mkn::kul::math::dot(2u, &a[0], &b[0]); + mkn::kul::math::scale(2u, 2u, &a[0]); + mkn::kul::math::mult_incr(2u, 2u, &a[0], &b[0]); } template @@ -16,9 +16,9 @@ void do_math_has_atomics() { std::atomic b[2]; b[0] = 3; b[1] = 4; - kul::math::dot(2u, &a[0], &b[0]); - kul::math::scale(2u, 2u, &a[0]); - kul::math::mult_incr(2u, 2u, &a[0], &b[0]); + mkn::kul::math::dot(2u, &a[0], &b[0]); + mkn::kul::math::scale(2u, 2u, &a[0]); + mkn::kul::math::mult_incr(2u, 2u, &a[0], &b[0]); } TEST(Math, double) { do_math(); } diff --git a/test/test/os.ipp b/test/test/os.ipp index e215814..6a8b1fc 100644 --- a/test/test/os.ipp +++ b/test/test/os.ipp @@ -1,14 +1,14 @@ TEST(OperatingSystemTests, HasRAMUsageSupport) { - ASSERT_TRUE(kul::this_proc::physicalMemory()); - ASSERT_TRUE(kul::this_proc::virtualMemory()); + ASSERT_TRUE(mkn::kul::this_proc::physicalMemory()); + ASSERT_TRUE(mkn::kul::this_proc::virtualMemory()); } class TimeStampHandler { private: - kul::File f; - kul::fs::TimeStamps fts; + mkn::kul::File f; + mkn::kul::fs::TimeStamps fts; TimeStampHandler() : f("mkn.yaml"), fts(f.timeStamps()) {} public: @@ -17,7 +17,7 @@ class TimeStampHandler { return i; } bool is() { return f.is(); } - const kul::fs::TimeStamps& timeStamps() { return fts; } + const mkn::kul::fs::TimeStamps& timeStamps() { return fts; } }; TEST(OperatingSystemTests, HasFileAccessedTimeStampSupport) { diff --git a/test/test/proc.ipp b/test/test/proc.ipp index 2d00502..468301c 100644 --- a/test/test/proc.ipp +++ b/test/test/proc.ipp @@ -1,7 +1,7 @@ TEST(Process_Test, LaunchProcess) { - kul::Process p("bash"); + mkn::kul::Process p("bash"); p << "-c" << "\"seq" << "1" @@ -16,8 +16,8 @@ TEST(Process_Test, LaunchProcess) { TEST(Process_Test, CaptureProcess) { std::string lines; - kul::Process p("bash"); - kul::ProcessCapture pc(p); + mkn::kul::Process p("bash"); + mkn::kul::ProcessCapture pc(p); p << "-c" << "\"seq" << "1" @@ -28,7 +28,7 @@ TEST(Process_Test, CaptureProcess) { ASSERT_TRUE(lines.size()); ASSERT_FALSE(pc.errs().size()); uint8_t i = 0; - for (auto s : kul::String::LINES(lines)) { + for (auto s : mkn::kul::String::LINES(lines)) { EXPECT_EQ(s, std::to_string(++i)); } } catch (...) { diff --git a/test/test/span.ipp b/test/test/span.ipp index 6832fab..20e9134 100644 --- a/test/test/span.ipp +++ b/test/test/span.ipp @@ -2,23 +2,23 @@ TEST(Span, init) { { std::vector v{1, 2, 3}; - kul::Span span0{v}; + mkn::kul::Span span0{v}; double i = 1; for (auto const& d0 : span0) EXPECT_EQ(d0, i++); - kul::Span span1{span0}; + mkn::kul::Span span1{span0}; i = 1; for (auto const& d0 : span1) EXPECT_EQ(d0, i++); } std::vector const v{1, 2, 3}; - kul::Span span{v}; + mkn::kul::Span span{v}; double i = 1; for (auto const& d0 : span) EXPECT_EQ(d0, i++); } TEST(SpanSet, containsCorrectData) { - kul::SpanSet spanset{std::vector{2, 2, 2}}; - kul::Span raw = spanset.raw(); + mkn::kul::SpanSet spanset{std::vector{2, 2, 2}}; + mkn::kul::Span raw = spanset.raw(); std::vector vals{1, 5, 5, 3, 4, 5}; for (size_t i = 0; i < 6; i++) raw[i] = vals[i]; size_t i = 0; diff --git a/test/test/string.ipp b/test/test/string.ipp index 4989061..937d939 100644 --- a/test/test/string.ipp +++ b/test/test/string.ipp @@ -2,7 +2,7 @@ TEST(StringOperations, SplitByChar) { std::vector v; - kul::String::SPLIT("split - by - char - dash", '-', v); + mkn::kul::String::SPLIT("split - by - char - dash", '-', v); EXPECT_EQ((size_t)4, v.size()); EXPECT_EQ("split ", v[0]); EXPECT_EQ(" by ", v[1]); @@ -12,7 +12,7 @@ TEST(StringOperations, SplitByChar) { TEST(StringOperations, SplitByString) { std::vector v; - kul::String::SPLIT("split - by - char - dash", "-", v); + mkn::kul::String::SPLIT("split - by - char - dash", "-", v); EXPECT_EQ((size_t)4, v.size()); EXPECT_EQ("split ", v[0]); EXPECT_EQ(" by ", v[1]); @@ -22,7 +22,7 @@ TEST(StringOperations, SplitByString) { TEST(StringOperations, SplitByEscapedChar) { std::vector v; - kul::String::ESC_SPLIT("split \\- by - char - dash", '-', v); + mkn::kul::String::ESC_SPLIT("split \\- by - char - dash", '-', v); EXPECT_EQ((size_t)3, v.size()); EXPECT_EQ("split - by ", v[0]); EXPECT_EQ(" char ", v[1]); @@ -32,51 +32,51 @@ TEST(StringOperations, SplitByEscapedChar) { TEST(StringOperations, String_2_UInt16_t_invalid_tooLarge) { tryCatch( {// toolarge - []() { kul::String::UINT16(std::to_string((std::numeric_limits::max)() + 10)); }}, + []() { mkn::kul::String::UINT16(std::to_string((std::numeric_limits::max)() + 10)); }}, true); } TEST(StringOperations, String_2_UInt16_t_invalid_tooNegative) { tryCatch( {// tooNegative - []() { kul::String::UINT16("-1"); }}, + []() { mkn::kul::String::UINT16("-1"); }}, true); } TEST(StringOperations, String_2_UInt16_t_invalid_hasLetters) { tryCatch({// contains letters * 3 - []() { kul::String::UINT16("a2c"); }, []() { kul::String::UINT16("1bc"); }, - []() { kul::String::UINT16("ab3"); }}, + []() { mkn::kul::String::UINT16("a2c"); }, []() { mkn::kul::String::UINT16("1bc"); }, + []() { mkn::kul::String::UINT16("ab3"); }}, true); } TEST(StringOperations, String_2_UInt16_t_valid) { tryCatch( {// valid - []() { kul::String::UINT16("100"); }}, + []() { mkn::kul::String::UINT16("100"); }}, false); } TEST(StringOperations, String_2_Int16_t_invalid_tooLarge) { tryCatch( {// toolarge - []() { kul::String::INT16(std::to_string((std::numeric_limits::max)() + 10)); }}, + []() { mkn::kul::String::INT16(std::to_string((std::numeric_limits::max)() + 10)); }}, true); } TEST(StringOperations, String_2_Int16_t_invalid_tooNegative) { tryCatch( {// tooNegative []() { - kul::String::INT16(std::to_string(((std::numeric_limits::max)() + 10) * -1)); + mkn::kul::String::INT16(std::to_string(((std::numeric_limits::max)() + 10) * -1)); }}, true); } TEST(StringOperations, String_2_Int16_t_invalid_hasLetters) { tryCatch({// contains letters * 3 - []() { kul::String::INT16("a2c"); }, []() { kul::String::INT16("1bc"); }, - []() { kul::String::INT16("ab3"); }}, + []() { mkn::kul::String::INT16("a2c"); }, []() { mkn::kul::String::INT16("1bc"); }, + []() { mkn::kul::String::INT16("ab3"); }}, true); } TEST(StringOperations, String_2_Int16_t_valid) { tryCatch({// valid - []() { kul::String::INT16("100"); }, []() { kul::String::INT16("-100"); }}, + []() { mkn::kul::String::INT16("100"); }, []() { mkn::kul::String::INT16("-100"); }}, false); } @@ -86,26 +86,26 @@ TEST(StringOperations, String_2_UInt32_t_invalid_tooLarge) { []() { uint64_t val = (std::numeric_limits::max)(); val += 10; - kul::String::UINT32(std::to_string(val)); + mkn::kul::String::UINT32(std::to_string(val)); }}, true); } TEST(StringOperations, String_2_UInt32_t_invalid_tooNegative) { tryCatch( {// tooNegative - []() { kul::String::UINT32(std::to_string(-1)); }}, + []() { mkn::kul::String::UINT32(std::to_string(-1)); }}, true); } TEST(StringOperations, String_2_UInt32_t_invalid_hasLetters) { tryCatch({// contains letters * 3 - []() { kul::String::UINT32("a2c"); }, []() { kul::String::UINT32("1bc"); }, - []() { kul::String::UINT32("ab3"); }}, + []() { mkn::kul::String::UINT32("a2c"); }, []() { mkn::kul::String::UINT32("1bc"); }, + []() { mkn::kul::String::UINT32("ab3"); }}, true); } TEST(StringOperations, String_2_UInt32_t_valid) { tryCatch( {// valid - []() { kul::String::UINT32("100"); }}, + []() { mkn::kul::String::UINT32("100"); }}, false); } @@ -115,7 +115,7 @@ TEST(StringOperations, String_2_Int32_t_invalid_tooLarge) { []() { int64_t val = (std::numeric_limits::max)(); val += 10; - kul::String::INT32(std::to_string(val)); + mkn::kul::String::INT32(std::to_string(val)); }}, true); } @@ -125,19 +125,19 @@ TEST(StringOperations, String_2_Int32_t_invalid_tooNegative) { []() { int64_t val = (std::numeric_limits::max)(); val += 10; - kul::String::INT32("-" + std::to_string(val)); + mkn::kul::String::INT32("-" + std::to_string(val)); }}, true); } TEST(StringOperations, String_2_Int32_t_invalid_hasLetters) { tryCatch({// contains letters * 3 - []() { kul::String::INT32("a2c"); }, []() { kul::String::INT32("1bc"); }, - []() { kul::String::INT32("ab3"); }}, + []() { mkn::kul::String::INT32("a2c"); }, []() { mkn::kul::String::INT32("1bc"); }, + []() { mkn::kul::String::INT32("ab3"); }}, true); } TEST(StringOperations, String_2_Int32_t_valid) { tryCatch({// valid - []() { kul::String::INT32("100"); }, []() { kul::String::INT32("-100"); }}, + []() { mkn::kul::String::INT32("100"); }, []() { mkn::kul::String::INT32("-100"); }}, false); } @@ -146,7 +146,7 @@ TEST(StringOperations, String_2_UInt64_t_invalid_tooLarge) { {// toolarge []() { uint64_t val = (std::numeric_limits::max)(); - kul::String::UINT64(std::to_string(val) + "0"); + mkn::kul::String::UINT64(std::to_string(val) + "0"); }}, true); } @@ -155,20 +155,20 @@ TEST(StringOperations, String_2_UInt64_t_invalid_tooNegative) { {// tooNegative []() { uint64_t val = (std::numeric_limits::max)(); - kul::String::UINT64("-" + std::to_string(val) + "0"); + mkn::kul::String::UINT64("-" + std::to_string(val) + "0"); }}, true); } TEST(StringOperations, String_2_UInt64_t_invalid_hasLetters) { tryCatch({// contains letters * 3 - []() { kul::String::UINT64("a2c"); }, []() { kul::String::UINT64("1bc"); }, - []() { kul::String::UINT64("ab3"); }}, + []() { mkn::kul::String::UINT64("a2c"); }, []() { mkn::kul::String::UINT64("1bc"); }, + []() { mkn::kul::String::UINT64("ab3"); }}, true); } TEST(StringOperations, String_2_UInt64_t_valid) { tryCatch( {// valid - []() { kul::String::UINT64(std::to_string((std::numeric_limits::max)())); }}, + []() { mkn::kul::String::UINT64(std::to_string((std::numeric_limits::max)())); }}, false); } @@ -176,18 +176,18 @@ TEST(StringOperations, String_2_Int64_t_invalid) { tryCatch({// toolarge []() { uint64_t val = (std::numeric_limits::max)(); - kul::String::INT64(std::to_string(val) + "0"); + mkn::kul::String::INT64(std::to_string(val) + "0"); }, // tooNegative - []() { kul::String::INT64(std::to_string(-1)); }, + []() { mkn::kul::String::INT64(std::to_string(-1)); }, // contains letters * 3 - []() { kul::String::INT64("a2c"); }, []() { kul::String::INT64("1bc"); }, - []() { kul::String::INT64("ab3"); }}, + []() { mkn::kul::String::INT64("a2c"); }, []() { mkn::kul::String::INT64("1bc"); }, + []() { mkn::kul::String::INT64("ab3"); }}, true); } TEST(StringOperations, String_2_Int64_t_valid) { tryCatch( {// valid - []() { kul::String::INT64(std::to_string((std::numeric_limits::max)())); }}, + []() { mkn::kul::String::INT64(std::to_string((std::numeric_limits::max)())); }}, false); } diff --git a/test/usage.cpp b/test/usage.cpp index 81ad741..6d162c9 100644 --- a/test/usage.cpp +++ b/test/usage.cpp @@ -31,23 +31,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define KUL_FORCE_TRACE #include -#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/signal.hpp" -#include "kul/string.hpp" -#include "kul/threads.hpp" -#include "kul/time.hpp" -#include "kul/tuple.hpp" -#include "kul/wstring.hpp" - +#include "mkn/kul/asio/log.hpp" +#include "mkn/kul/assert.hpp" +#include "mkn/kul/cli.hpp" +#include "mkn/kul/dbg.hpp" +#include "mkn/kul/io.hpp" +#include "mkn/kul/ipc.hpp" +#include "mkn/kul/log.hpp" +#include "mkn/kul/math.hpp" +#include "mkn/kul/os.hpp" +#include "mkn/kul/proc.hpp" +#include "mkn/kul/signal.hpp" +#include "mkn/kul/span.hpp" +#include "mkn/kul/string.hpp" +#include "mkn/kul/threads.hpp" +#include "mkn/kul/time.hpp" +#include "mkn/kul/tuple.hpp" +#include "mkn/kul/wstring.hpp" + +namespace mkn { namespace kul { class Test; @@ -70,7 +72,7 @@ class TestThreadObject { KLOG(INF) << "CONST THREAD FINISHED"; } friend class Test; - friend class kul::Thread; + friend class mkn::kul::Thread; }; class TestThreadQueueObject { @@ -81,7 +83,7 @@ class TestThreadQueueObject { public: TestThreadQueueObject(Mutex &_mutex) : mutex(_mutex) {} void operator()() { - kul::ScopeLock lock(mutex); + mkn::kul::ScopeLock lock(mutex); KLOG(INF) << "THREAD RUNNING"; i++; KLOG(INF) << "THREAD FINISHED"; @@ -97,7 +99,7 @@ class TestThreadQueueQObject : public TestThreadQueueObject { TestThreadQueueQObject(Mutex &_mutex, std::queue &_q) : TestThreadQueueObject(_mutex), q(_q) {} void operator()() { - kul::ScopeLock lock(mutex); + mkn::kul::ScopeLock lock(mutex); KLOG(INF) << "THREAD RUNNING"; i++; q.pop(); @@ -111,13 +113,13 @@ class TestConcQueueQObject { TestConcQueueQObject() {} void operator()() { KLOG(INF) << "TestConcQueueQObject RUNNING"; - kul::this_thread::sleep(10); + mkn::kul::this_thread::sleep(10); } }; -class TestIPCServer : public kul::ipc::Server { +class TestIPCServer : public mkn::kul::ipc::Server { public: - TestIPCServer() : kul::ipc::Server("uuid", 1) {} // UUID CHECKS ONCE + TestIPCServer() : mkn::kul::ipc::Server("uuid", 1) {} // UUID CHECKS ONCE void handle(std::string const &s) { KLOG(INF) << "TestIPCServer " << s; } void operator()() { listen(); } }; @@ -126,10 +128,10 @@ class TestIPC { public: void run() { TestIPCServer ipc; - kul::Thread t(std::ref(ipc)); + mkn::kul::Thread t(std::ref(ipc)); t.run(); - kul::this_thread::sleep(1000); - kul::ipc::Client("uuid").send("TestIPCClient"); + mkn::kul::this_thread::sleep(1000); + mkn::kul::ipc::Client("uuid").send("TestIPCClient"); t.join(); } }; @@ -151,7 +153,7 @@ class Test { Test(int argc, char *argv[]) : s("LAMBDAS ALLOWED IN SIGNAL") { KUL_DBG_FUNC_ENTER; Catch c; - kul::Signal sig; // Windows: each thread requires own handler, static + mkn::kul::Signal sig; // Windows: each thread requires own handler, static // singleton otherwise so only ever one. sig.segv(std::bind(&Catch::print, std::ref(c), std::placeholders::_1)); // Vector of @@ -170,107 +172,107 @@ class Test { KLOG(INF) << "KLOG(INF)"; // KLOG=1 KLOG(ERR) << "KLOG(ERR)"; // KLOG=2 KLOG(DBG) << "KLOG(DBG)"; // KLOG=3 - KOUT(NON) << kul::Dir::SEP(); - KOUT(NON) << kul::env::SEP(); - KOUT(NON) << kul::env::CWD(); - KOUT(NON) << kul::user::home().path(); - KLOG(INF) << kul::user::home("maiken").path(); - - kul::File fo("TEST_WRITE_OUT"); - kul::File fe("TEST_WRITE_ERR"); + KOUT(NON) << mkn::kul::Dir::SEP(); + KOUT(NON) << mkn::kul::env::SEP(); + KOUT(NON) << mkn::kul::env::CWD(); + KOUT(NON) << mkn::kul::user::home().path(); + KLOG(INF) << mkn::kul::user::home("maiken").path(); + + mkn::kul::File fo("TEST_WRITE_OUT"); + mkn::kul::File fe("TEST_WRITE_ERR"); { - kul::io::Writer wo(fo); - kul::io::Writer we(fe); + mkn::kul::io::Writer wo(fo); + mkn::kul::io::Writer we(fe); auto lo = [&](std::string const &_s) { wo << _s; }; auto le = [&](std::string const &_s) { we << _s; }; - kul::LogMan::INSTANCE().setOut(lo); - kul::LogMan::INSTANCE().setErr(le); + mkn::kul::LogMan::INSTANCE().setOut(lo); + mkn::kul::LogMan::INSTANCE().setErr(le); KOUT(INF) << "KOUT(INF)"; KERR << "KOUT(ERR)"; // scoped for autoflush - segfault later drops stream } fo.rm(); fe.rm(); - kul::LogMan::INSTANCE().setOut(nullptr); - kul::LogMan::INSTANCE().setErr(nullptr); + mkn::kul::LogMan::INSTANCE().setOut(nullptr); + mkn::kul::LogMan::INSTANCE().setErr(nullptr); { - kul::File os_inc("os.ipp", kul::Dir("test")); - kul::File os_hpp("os.hpp", kul::Dir("inc/kul")); + mkn::kul::File os_inc("os.ipp", mkn::kul::Dir("test")); + mkn::kul::File os_hpp("os.hpp", mkn::kul::Dir("inc/kul")); if (!os_hpp || !os_inc) KEXCEPTION("UH OH!"); KLOG(INF) << os_inc.relative(os_hpp); KLOG(INF) << os_inc.relative(os_hpp.dir()); KLOG(INF) << os_inc.dir().relative(os_hpp.dir()); } - for (kul::Dir const &d : kul::Dir(kul::env::CWD()).dirs()) - for (kul::File const &f : d.files()) KOUT(NON) << d.join(f.name()); // or f.full() + for (mkn::kul::Dir const &d : mkn::kul::Dir(mkn::kul::env::CWD()).dirs()) + for (mkn::kul::File const &f : d.files()) KOUT(NON) << d.join(f.name()); // or f.full() try { - kul::Process("echo").arg("Hello").arg("World").start(); + mkn::kul::Process("echo").arg("Hello").arg("World").start(); - } catch (const kul::proc::ExitException &e) { + } catch (const mkn::kul::proc::ExitException &e) { KERR << e.stack(); KERR << e.code(); - } catch (const kul::proc::Exception &e) { + } catch (const mkn::kul::proc::Exception &e) { KERR << e.debug() << " : " << typeid(e).name(); KERR << "Error expected on windows without echo on path"; } { - std::vector argV{{kul::cli::Arg('f', "flag"), - kul::cli::Arg('m', "maybe_value", kul::cli::ArgType::MAYBE), - kul::cli::Arg('o', "option", kul::cli::ArgType::STRING)}}; - std::vector cmdV{{"COMMAND"}}; + std::vector argV{{mkn::kul::cli::Arg('f', "flag"), + mkn::kul::cli::Arg('m', "maybe_value", mkn::kul::cli::ArgType::MAYBE), + mkn::kul::cli::Arg('o', "option", mkn::kul::cli::ArgType::STRING)}}; + std::vector cmdV{{"COMMAND"}}; - kul::cli::Args args(cmdV, argV); + mkn::kul::cli::Args args(cmdV, argV); try { args.process(argc, argv); - } catch (const kul::cli::Exception &e) { + } catch (const mkn::kul::cli::Exception &e) { KEXIT(1, e.what()); } } for (std::string const &arg : - kul::cli::asArgs("/path/to \"words in quotes\" words\\ not\\ in\\ quotes end")) + mkn::kul::cli::asArgs("/path/to \"words in quotes\" words\\ not\\ in\\ quotes end")) KOUT(NON) << "ARG: " << arg; - for (std::string const &arg : kul::String::SPLIT("split - by - char - dash", '-')) + for (std::string const &arg : mkn::kul::String::SPLIT("split - by - char - dash", '-')) KOUT(NON) << "BIT: " << arg; - for (std::string const &arg : kul::String::SPLIT("split - by - string - dash", "-")) + for (std::string const &arg : mkn::kul::String::SPLIT("split - by - string - dash", "-")) KOUT(NON) << "BIT: " << arg; for (std::string const &arg : - kul::String::ESC_SPLIT("split \\- by - char - dash with escape backslash", '-')) + mkn::kul::String::ESC_SPLIT("split \\- by - char - dash with escape backslash", '-')) KOUT(NON) << "BIT: " << arg; - kul::hash::map::S2S sparse; + mkn::kul::hash::map::S2S sparse; sparse.insert("LEFT", "RIGHT"); #if defined(_MKN_WITH_GOOGLE_SPARSEHASH_) { - kul::dense::hash::map::S2S dense; + mkn::kul::dense::hash::map::S2S dense; dense.setEmptyKey(""); // unique non occuring key dense.insert("LEFT", "RIGHT"); } #endif - kul::File file("./write_access"); + mkn::kul::File file("./write_access"); if (file && !file.rm()) KERR << "CANNOT DELETE FILE " << file; if (!file && !file.mk()) KERR << "CANNOT CREATE FILE " << file; if (file && !file.rm()) KERR << "CANNOT DELETE FILE " << file; - KOUT(NON) << "kul::Now::MILLIS(); " << kul::Now::MILLIS(); - KOUT(NON) << "kul::Now::MICROS(); " << kul::Now::MICROS(); - KOUT(NON) << "kul::Now::NANOS(); " << kul::Now::NANOS(); + KOUT(NON) << "mkn::kul::Now::MILLIS(); " << mkn::kul::Now::MILLIS(); + KOUT(NON) << "mkn::kul::Now::MICROS(); " << mkn::kul::Now::MICROS(); + KOUT(NON) << "mkn::kul::Now::NANOS(); " << mkn::kul::Now::NANOS(); - KOUT(NON) << "kul::DateTime::NOW(); " << kul::DateTime::NOW(); + KOUT(NON) << "mkn::kul::DateTime::NOW(); " << mkn::kul::DateTime::NOW(); - KOUT(NON) << "CPU CORES: " << kul::cpu::cores(); - KOUT(NON) << "MAX THREADS: " << kul::cpu::threads(); + KOUT(NON) << "CPU CORES: " << mkn::kul::cpu::cores(); + KOUT(NON) << "MAX THREADS: " << mkn::kul::cpu::threads(); { - kul::SpanSet spanset{std::vector{3, 2, 1}}; - kul::Span raw = spanset.raw(); + mkn::kul::SpanSet spanset{std::vector{3, 2, 1}}; + mkn::kul::Span raw = spanset.raw(); std::vector vals{1, 5, 5, 3, 4, 5}; for (size_t i = 0; i < 6; i++) raw[i] = vals[i]; for (auto const &span : spanset) { @@ -281,37 +283,37 @@ class Test { { TestThreadObject tto1; - kul::Thread th(std::ref(tto1)); + mkn::kul::Thread th(std::ref(tto1)); th.join(); tto1.print(); th.join(); tto1.print(); TestThreadObject tto2; - kul::Thread th2(std::cref(tto2)); + mkn::kul::Thread th2(std::cref(tto2)); th2.join(); tto2.print(); TestThreadObject tto3; - kul::Thread th3(tto3); + mkn::kul::Thread th3(tto3); th3.join(); tto3.print(); - kul::Thread([&tto1]() { tto1(); }).join(); + mkn::kul::Thread([&tto1]() { tto1(); }).join(); tto1.print(); - kul::Thread([tto1]() { tto1(); }).join(); + mkn::kul::Thread([tto1]() { tto1(); }).join(); tto1.print(); } - kul::Mutex mutex; + mkn::kul::Mutex mutex; { - { kul::ScopeLock lock(mutex); } - kul::ScopeLock lock(mutex); + { mkn::kul::ScopeLock lock(mutex); } + mkn::kul::ScopeLock lock(mutex); } { KOUT(NON) << "LAUNCHING THREAD POOL"; TestThreadQueueObject ttpo1(mutex); - kul::ThreadQueue tp1(std::ref(ttpo1)); + mkn::kul::ThreadQueue tp1(std::ref(ttpo1)); tp1.setMax(4); tp1.detach(); tp1.join(); @@ -321,8 +323,8 @@ class Test { for (int i = 0; i < 10; i++) q.push(i); KOUT(NON) << "LAUNCHING PREDICATED THREAD POOL"; TestThreadQueueQObject ttpo2(mutex, q); - kul::PredicatedThreadQueue> tp2(std::ref(ttpo2), q); - tp2.setMax(kul::cpu::threads()); + mkn::kul::PredicatedThreadQueue> tp2(std::ref(ttpo2), q); + tp2.setMax(mkn::kul::cpu::threads()); tp2.detach(); tp2.join(); ttpo2.print(); @@ -332,42 +334,42 @@ class Test { ConcurrentThreadQueue ctq(5, 1); for (size_t i = 0; i < 10; i++) ctq.async(std::bind(&TestConcQueueQObject::operator(), std::ref(tcqqo))); - kul::this_thread::sleep(500); + mkn::kul::this_thread::sleep(500); ctq.stop().join(); { - kul::ConcurrentThreadPool<> ctp(5, 1); + mkn::kul::ConcurrentThreadPool<> ctp(5, 1); auto lambda = [](unsigned int a, unsigned int b) { KLOG(INF) << (a + b); }; ctp.async(std::bind(lambda, 2, 4)); auto lambdb = [](unsigned int a, unsigned int b) { KLOG(INF) << (a + b); KEXCEPTION("Exceptional!"); }; - auto lambex = [](const kul::Exception &e) { KLOG(ERR) << e.stack(); }; + auto lambex = [](const mkn::kul::Exception &e) { KLOG(ERR) << e.stack(); }; ctp.async(std::bind(lambdb, 2, 4), std::bind(lambex, std::placeholders::_1)); - kul::this_thread::sleep(500); + mkn::kul::this_thread::sleep(500); ctp.block().finish().join(); } { - kul::ChroncurrentThreadPool<> ctp(5, 1); + mkn::kul::ChroncurrentThreadPool<> ctp(5, 1); auto lambda = [](unsigned int a, unsigned int b) { KLOG(INF) << (a + b); }; ctp.async(std::bind(lambda, 2, 4)); auto lambdb = [](unsigned int a, unsigned int b) { KLOG(INF) << (a + b); - KEXCEPT(kul::Exception, "Exceptional!"); + KEXCEPT(mkn::kul::Exception, "Exceptional!"); }; - auto lambex = [](const kul::Exception &e) { KLOG(ERR) << e.stack(); }; + auto lambex = [](const mkn::kul::Exception &e) { KLOG(ERR) << e.stack(); }; ctp.async(std::bind(lambdb, 2, 4), std::bind(lambex, std::placeholders::_1)); - kul::this_thread::sleep(500); + mkn::kul::this_thread::sleep(500); ctp.block().finish().join(); } TestIPC().run(); - KOUT(NON) << "Phsical RAM used in KB: " << kul::this_proc::physicalMemory(); - KOUT(NON) << "Virtual RAM used in KB: " << kul::this_proc::virtualMemory(); - KOUT(NON) << "Total RAM used in KB: " << kul::this_proc::totalMemory(); + KOUT(NON) << "Phsical RAM used in KB: " << mkn::kul::this_proc::physicalMemory(); + KOUT(NON) << "Virtual RAM used in KB: " << mkn::kul::this_proc::virtualMemory(); + KOUT(NON) << "Total RAM used in KB: " << mkn::kul::this_proc::totalMemory(); KOUT(NON); KOUT(NON) << "SEG FAULTING MAIN THREAD!"; @@ -380,11 +382,12 @@ class Test { } }; } // namespace kul +} // namespace mkn int main(int argc, char *argv[]) { try { - kul::Test(argc, argv); - } catch (const kul::Exception &e) { + mkn::kul::Test(argc, argv); + } catch (const mkn::kul::Exception &e) { KERR << e.stack(); } catch (const std::exception &e) { KERR << e.what();