Merge remote-tracking branch 'github/main'
commit
f5069859c5
|
@ -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/)
|
||||
|
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 118 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
@ -96,7 +96,7 @@ namespace blt {
|
|||
|
||||
m00(m00() * x);
|
||||
m11(m11() * y);
|
||||
m22(m11() * z);
|
||||
m22(m22() * z);
|
||||
|
||||
*this = *this * scale_mat;
|
||||
|
||||
|
|
|
@ -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<char*>(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<typename T>
|
||||
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
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
//
|
||||
// Created by brett on 7/9/23.
|
||||
//
|
||||
#include <blt/std/string.h>
|
||||
|
||||
void blt::string::StringBuffer::expand() {
|
||||
size_t multiplier = size / BLOCK_SIZE;
|
||||
auto newSize = BLOCK_SIZE * (multiplier * 2);
|
||||
characterBuffer = static_cast<char*>(realloc(characterBuffer, newSize));
|
||||
size = newSize;
|
||||
}
|
||||
|
||||
void blt::string::StringBuffer::trim() {
|
||||
characterBuffer = static_cast<char*>(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};
|
||||
}
|
Loading…
Reference in New Issue