diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100644 new mode 100755 index e126a88..04af8bd --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,8 @@ option(BUILD_NBT "Build the BLT NBT + eNBT extension" ON) option(BUILD_TESTS "Build the BLT test set" OFF) option(BLT_ENABLE_LOGGING "Enable blt::logging" 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() @@ -44,8 +46,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 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..cea9f6a --- a/include/blt/std/string.h +++ b/include/blt/std/string.h @@ -16,6 +16,30 @@ 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 toString(); + + StringBuffer(){ + characterBuffer = static_cast(malloc(BLOCK_SIZE)); + size = BLOCK_SIZE; + } + + StringBuffer& operator<<(char c); + + ~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 +177,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..0dba300 --- /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::toString() { + 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