diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100644 new mode 100755 index 4cc750d..e56d29d --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,8 @@ option(BLT_ENABLE_WARN "Enable blt::logging BLT_WARN macro" ON) option(BLT_ENABLE_ERROR "Enable blt::logging BLT_ERROR macro" ON) option(BLT_ENABLE_FATAL "Enable blt::logging BLT_FATAL macro" ON) +configure_file(include/blt/config.h.in config/blt/config.h @ONLY) + if(${BUILD_STD} OR ${BUILD_PROFILING}) file(GLOB_RECURSE STD_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/blt/std/*.cpp") else() @@ -50,8 +52,6 @@ message("Profiler Files ${PROFILING_FILES}") message("Source: ${CMAKE_SOURCE_DIR}") message("Current Source: ${CMAKE_CURRENT_SOURCE_DIR}") -configure_file(include/blt/config.h.in config/blt/config.h @ONLY) - add_library(BLT ${STD_FILES} ${PROFILING_FILES} ${NBT_FILES}) target_include_directories(BLT PUBLIC include/) diff --git a/CMakeSettings.json b/CMakeSettings.json old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/design.txt b/design.txt old mode 100644 new mode 100755 diff --git a/icon.png b/icon.png old mode 100644 new mode 100755 diff --git a/icon_large.png b/icon_large.png old mode 100644 new mode 100755 diff --git a/icon_small.png b/icon_small.png old mode 100644 new mode 100755 diff --git a/include/blt/config.h.in b/include/blt/config.h.in old mode 100644 new mode 100755 diff --git a/include/blt/math/averages.h b/include/blt/math/averages.h old mode 100644 new mode 100755 diff --git a/include/blt/math/log_util.h b/include/blt/math/log_util.h old mode 100644 new mode 100755 diff --git a/include/blt/math/math.h b/include/blt/math/math.h old mode 100644 new mode 100755 diff --git a/include/blt/math/matrix.h b/include/blt/math/matrix.h old mode 100644 new mode 100755 index cd607bd..28fd7db --- a/include/blt/math/matrix.h +++ b/include/blt/math/matrix.h @@ -96,7 +96,7 @@ namespace blt { m00(m00() * x); m11(m11() * y); - m22(m11() * z); + m22(m22() * z); *this = *this * scale_mat; diff --git a/include/blt/math/vectors.h b/include/blt/math/vectors.h old mode 100644 new mode 100755 diff --git a/include/blt/nbt/nbt.h b/include/blt/nbt/nbt.h old mode 100644 new mode 100755 diff --git a/include/blt/nbt/nbt_block.h b/include/blt/nbt/nbt_block.h old mode 100644 new mode 100755 diff --git a/include/blt/profiling/profiler.h b/include/blt/profiling/profiler.h old mode 100644 new mode 100755 diff --git a/include/blt/std/binary_tree.h b/include/blt/std/binary_tree.h old mode 100644 new mode 100755 diff --git a/include/blt/std/filesystem.h b/include/blt/std/filesystem.h old mode 100644 new mode 100755 diff --git a/include/blt/std/format.h b/include/blt/std/format.h old mode 100644 new mode 100755 diff --git a/include/blt/std/hash_map.h b/include/blt/std/hash_map.h old mode 100644 new mode 100755 diff --git a/include/blt/std/loader.h b/include/blt/std/loader.h old mode 100644 new mode 100755 diff --git a/include/blt/std/logging.h b/include/blt/std/logging.h old mode 100644 new mode 100755 diff --git a/include/blt/std/map.h b/include/blt/std/map.h old mode 100644 new mode 100755 diff --git a/include/blt/std/memory.h b/include/blt/std/memory.h old mode 100644 new mode 100755 diff --git a/include/blt/std/queue.h b/include/blt/std/queue.h old mode 100644 new mode 100755 diff --git a/include/blt/std/random.h b/include/blt/std/random.h old mode 100644 new mode 100755 diff --git a/include/blt/std/string.h b/include/blt/std/string.h old mode 100644 new mode 100755 index 69412dc..e2e1542 --- a/include/blt/std/string.h +++ b/include/blt/std/string.h @@ -16,6 +16,41 @@ namespace blt::string { + class StringBuffer { + private: + const size_t BLOCK_SIZE = 4096; + size_t front = 0; + size_t size = 0; + char* characterBuffer = nullptr; + + void expand(); + public: + void trim(); + std::string str(); + + StringBuffer(){ + characterBuffer = static_cast(malloc(BLOCK_SIZE)); + size = BLOCK_SIZE; + } + + StringBuffer& operator<<(char c); + StringBuffer& operator<<(const std::string& str) { + for (char c : str) + *this << c; + return *this; + } + + template + inline StringBuffer& operator<<(T t) { + *this << std::to_string(t); + return *this; + } + + ~StringBuffer() { + free(characterBuffer); + } + }; + static inline bool starts_with(const std::string& string, const std::string& search){ if (search.length() > string.length()) return false; @@ -153,6 +188,7 @@ namespace blt::string { trim(s); return s; } + } #endif //BLT_STRING_H diff --git a/include/blt/std/system.h b/include/blt/std/system.h old mode 100644 new mode 100755 diff --git a/include/blt/std/time.h b/include/blt/std/time.h old mode 100644 new mode 100755 diff --git a/include/blt/window/window.h b/include/blt/window/window.h old mode 100644 new mode 100755 diff --git a/src/blt/nbt/nbt.cpp b/src/blt/nbt/nbt.cpp old mode 100644 new mode 100755 diff --git a/src/blt/nbt/nbt_block.cpp b/src/blt/nbt/nbt_block.cpp old mode 100644 new mode 100755 diff --git a/src/blt/profiling/profiler.cpp b/src/blt/profiling/profiler.cpp old mode 100644 new mode 100755 diff --git a/src/blt/std/filesystem.cpp b/src/blt/std/filesystem.cpp old mode 100644 new mode 100755 diff --git a/src/blt/std/format.cpp b/src/blt/std/format.cpp old mode 100644 new mode 100755 diff --git a/src/blt/std/loader.cpp b/src/blt/std/loader.cpp old mode 100644 new mode 100755 diff --git a/src/blt/std/logging.cpp b/src/blt/std/logging.cpp old mode 100644 new mode 100755 diff --git a/src/blt/std/string.cpp b/src/blt/std/string.cpp new file mode 100755 index 0000000..2ce5dd7 --- /dev/null +++ b/src/blt/std/string.cpp @@ -0,0 +1,29 @@ +// +// Created by brett on 7/9/23. +// +#include + +void blt::string::StringBuffer::expand() { + size_t multiplier = size / BLOCK_SIZE; + auto newSize = BLOCK_SIZE * (multiplier * 2); + characterBuffer = static_cast(realloc(characterBuffer, newSize)); + size = newSize; +} + +void blt::string::StringBuffer::trim() { + characterBuffer = static_cast(realloc(characterBuffer, front+1)); + size = front+1; + characterBuffer[front] = '\0'; +} + +blt::string::StringBuffer& blt::string::StringBuffer::operator<<(char c) { + characterBuffer[front++] = c; + if (front > size) + expand(); + return *this; +} + +std::string blt::string::StringBuffer::str() { + trim(); + return std::string{characterBuffer}; +} diff --git a/src/blt/std/system.cpp b/src/blt/std/system.cpp old mode 100644 new mode 100755 diff --git a/src/blt/window/window.cpp b/src/blt/window/window.cpp old mode 100644 new mode 100755 diff --git a/src/tests/binary_trees.h b/src/tests/binary_trees.h old mode 100644 new mode 100755 diff --git a/src/tests/hashmap_tests.h b/src/tests/hashmap_tests.h old mode 100644 new mode 100755 diff --git a/src/tests/logging.h b/src/tests/logging.h old mode 100644 new mode 100755 diff --git a/src/tests/main.cpp b/src/tests/main.cpp old mode 100644 new mode 100755 diff --git a/src/tests/nbt_tests.h b/src/tests/nbt_tests.h old mode 100644 new mode 100755 diff --git a/src/tests/profiling_tests.h b/src/tests/profiling_tests.h old mode 100644 new mode 100755 diff --git a/src/tests/queue_tests.h b/src/tests/queue_tests.h old mode 100644 new mode 100755