From f9f1955748a3b369f0a015405af131c9b6e3285c Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sat, 4 Oct 2025 16:53:57 +0200 Subject: namespace for logger, strops, locales --- include/log.hpp | 42 ------------------------------------------ include/logger.hpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ include/strops.hpp | 26 +++++++++++++++----------- 3 files changed, 61 insertions(+), 53 deletions(-) delete mode 100644 include/log.hpp create mode 100644 include/logger.hpp (limited to 'include') diff --git a/include/log.hpp b/include/log.hpp deleted file mode 100644 index bff3d05..0000000 --- a/include/log.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/* -* Copyright (c) 2025 Aldrik Ramaekers -* -* Permission to use, copy, modify, and/or distribute this software for any -* purpose with or without fee is hereby granted, provided that the above -* copyright notice and this permission notice appear in all copies. -* -* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -#pragma once - -#include "timer.h" -#include "imgui.h" -#include "config.hpp" -#include "administration.hpp" - -#define MAX_LEN_LOG_HISTORY 256 -#define MAX_LEN_LOG_TXT 128 - -typedef struct { - u32 write_cursor; - u32 history_length; - char history[MAX_LEN_LOG_HISTORY][MAX_LEN_LOG_TXT]; - ImVec4 colors[MAX_LEN_LOG_HISTORY]; -} program_log; - -#define STOPWATCH_START tick_t timestamp_start = timer_current(); -#define STOPWATCH_TIME (timer_elapsed(timestamp_start)*1000.0f) - -program_log* get_log(); - -void log_clear(); -void log_aerr(a_err errors); -void log_info(const char* fmt, ...) IM_FMTARGS(2); -void log_error(const char* fmt, ...) IM_FMTARGS(2); \ No newline at end of file diff --git a/include/logger.hpp b/include/logger.hpp new file mode 100644 index 0000000..b191ecb --- /dev/null +++ b/include/logger.hpp @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2025 Aldrik Ramaekers +* +* Permission to use, copy, modify, and/or distribute this software for any +* purpose with or without fee is hereby granted, provided that the above +* copyright notice and this permission notice appear in all copies. +* +* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#pragma once + +#include "timer.h" +#include "imgui.h" +#include "config.hpp" +#include "administration.hpp" + +#define STOPWATCH_START tick_t timestamp_start = timer_current(); +#define STOPWATCH_TIME (timer_elapsed(timestamp_start)*1000.0f) + +namespace logger { + + static const u32 MAX_LEN_LOG_HISTORY = 256; + static const u32 MAX_LEN_LOG_TXT = 128; + + typedef struct { + u32 write_cursor; + u32 history_length; + char history[MAX_LEN_LOG_HISTORY][MAX_LEN_LOG_TXT]; + ImVec4 colors[MAX_LEN_LOG_HISTORY]; + } program_log; + + program_log* get(); + + void clear(); + void aerr(a_err errors); + void info(const char* fmt, ...) IM_FMTARGS(2); + void error(const char* fmt, ...) IM_FMTARGS(2); + +} \ No newline at end of file diff --git a/include/strops.hpp b/include/strops.hpp index d11f0c2..ec3dcdd 100644 --- a/include/strops.hpp +++ b/include/strops.hpp @@ -18,14 +18,18 @@ #include -size_t strops_copy(char *dst, const char *src, size_t size); -char* strops_stristr(char* a, char* b); -void strops_replace(char *buf, size_t buf_size, const char *search, const char *replace); -void strops_replace_int32(char *buf, size_t buf_size, const char *search, int32_t number); -void strops_replace_int64(char *buf, size_t buf_size, const char *search, int64_t number); -void strops_replace_float(char *buf, size_t buf_size, const char *search, float number, int decimals); -bool strops_prefix(const char *pre, const char *str); -char* strops_get_json_value(const char *json, const char *key, char *out, size_t out_size, int nth = 0); -char* strops_get_filename(const char* path); -char* strops_prep_str_for_json(const char *input, size_t buffer_size); -char* strops_unprep_str_from_json(char *input); \ No newline at end of file +namespace strops { + + size_t copy(char *dst, const char *src, size_t size); + char* contains(char* a, char* b); + void replace(char *buf, size_t buf_size, const char *search, const char *replace); + void replace_int32(char *buf, size_t buf_size, const char *search, int32_t number); + void replace_int64(char *buf, size_t buf_size, const char *search, int64_t number); + void replace_float(char *buf, size_t buf_size, const char *search, float number, int decimals); + bool prefix(const char *pre, const char *str); + char* get_json_value(const char *json, const char *key, char *out, size_t out_size, int nth = 0); + char* get_filename(const char* path); + char* prep_str_for_json(const char *input, size_t buffer_size); + char* unprep_str_from_json(char *input); + +} \ No newline at end of file -- cgit v1.2.3-70-g09d2