more docs
parent
26d215be0a
commit
a15ebfdd77
|
@ -1,7 +1,7 @@
|
|||
cmake_minimum_required(VERSION 3.5)
|
||||
include(cmake/color.cmake)
|
||||
|
||||
set(BLT_VERSION 0.16.5)
|
||||
set(BLT_VERSION 0.16.6)
|
||||
set(BLT_TEST_VERSION 0.0.1)
|
||||
|
||||
set(BLT_TARGET BLT)
|
||||
|
|
28
README.md
28
README.md
|
@ -1,10 +1,32 @@
|
|||
# **BLT v0.8.0a**
|
||||
A C++20 common utilities library to make thing easy!
|
||||
# **BLT v0.16**
|
||||
A C++17 common utilities library to make thing easy!
|
||||
|
||||
![Icon](icon_large.png)
|
||||
|
||||
---
|
||||
|
||||
# ***Features***
|
||||
- ## blt/fs
|
||||
- ### loader.h
|
||||
- std::string blt::fs::getFile(std::string_view path)
|
||||
- Gets the entire file as a string.
|
||||
- std::vector\<std::string> blt::fs::getLinesFromFile(std::string_view path)
|
||||
- Gets the entire file as a string, then splits on the new line character. Then returns a vector of those lines
|
||||
- std::vector\<std::string> blt::fs::recursiveInclude(std::string_view path, std::string include_header, std::vector<include_guard> guards);
|
||||
- Recursively include in order based on the include string (include_header) marked by the include guards
|
||||
- Defaults to C/C++/GLSL preprocessor style (Was designed for GLSL)
|
||||
- std::string blt::fs::loadBrainFuckFile(const std::string& path)
|
||||
- Load a brainfuck file recursively, uses ~ to mark the include path
|
||||
- ### nbt.h
|
||||
- probably needs to be remade (TODO)
|
||||
- ## blt/math
|
||||
- ### averages.h
|
||||
- blt::averagizer_o_matic
|
||||
- Computes a rolling average in a dynamically allocated array.
|
||||
- Useful for average FPS over a period of time
|
||||
- ### fixed_point.h
|
||||
-
|
||||
|
||||
# Specialties
|
||||
## blt::logging.v2
|
||||
Found in the header file `include/std/logging.h`, blt::logging is a fast and simple
|
||||
|
@ -27,7 +49,7 @@ The goal was to create an API which would function exactly as the Python docs de
|
|||
## blt::profile_t (v2)
|
||||
The newest version of my profiler solution now features a CPU cycle counter, CPU thread execution time, and wall time. It has more options for
|
||||
sorting and general printing while featuring a nicer codebase. It is an improvement over blt::profiling while maintaining (almost) complete backwards
|
||||
compatability. Due to changes in the ABI the `BLT_PRINT_PROFILE` macro deletes the internal profiles and intervals AND takes arguments which match
|
||||
compatability. Due to changes in the API the `BLT_PRINT_PROFILE` macro deletes the internal profiles and intervals AND takes arguments which match
|
||||
the new formatting options for profiling v2. However, `BLT_START_INTERVAL`, `BLT_WRITE_PROFILE`, and `BLT_END_INTERVAL` are still the same.
|
||||
Documentation for this is coming soon, along with more profiling features. the `BLT_*` macros can be disabled by the standard `BLT_DISABLE_PROFILING`
|
||||
from the v1 profiler. It is encouraged to use the new blt::* profile functions over the macros however these currently cannot be disabled. (TODO)
|
||||
|
|
|
@ -1,155 +0,0 @@
|
|||
/*
|
||||
* Created by Brett on 29/01/23.
|
||||
* Licensed under GNU General Public License V3.0
|
||||
* See LICENSE file for license detail
|
||||
*/
|
||||
|
||||
#ifndef BLT_FILESYSTEM_H
|
||||
#define BLT_FILESYSTEM_H
|
||||
|
||||
#include <fstream>
|
||||
#include <ios>
|
||||
#include "memory.h"
|
||||
|
||||
namespace blt::fs
|
||||
{
|
||||
|
||||
/**
|
||||
* A simple interface which provides a way of reading the next block of data from a resource.
|
||||
* The interface provides a single function "read" which will read a specified number of bytes into the buffer.
|
||||
* The implementation for this could be fstreams, zlib deflate, or any method filesystem access.
|
||||
* Reading of a large number of bytes ( > block size) is guaranteed to not significantly increase the read time and will likely result in a
|
||||
* direct passthrough to the underlying system. Small reads will be buffered, hence the name "block" reader.
|
||||
*/
|
||||
class block_reader
|
||||
{
|
||||
protected:
|
||||
// 32768 block size seems the fastest on my system
|
||||
unsigned long m_bufferSize;
|
||||
public:
|
||||
explicit block_reader(size_t bufferSize): m_bufferSize(bufferSize)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Reads bytes from the internal filesystem implementation
|
||||
* @param buffer buffer to copy the read bytes into
|
||||
* @param bytes number of bytes to read
|
||||
* @return status code. non-zero return codes indicates a failure has occurred.
|
||||
*/
|
||||
virtual int read(char* buffer, size_t bytes) = 0;
|
||||
|
||||
virtual size_t gcount() = 0;
|
||||
|
||||
virtual char get()
|
||||
{
|
||||
char c[1];
|
||||
read(c, 1);
|
||||
return c[0];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A buffered block writer without a definite backend implementation. Exactly the same as a block_reader but for writing to the filesystem.
|
||||
*/
|
||||
class block_writer
|
||||
{
|
||||
protected:
|
||||
unsigned long m_bufferSize;
|
||||
public:
|
||||
explicit block_writer(unsigned long bufferSize): m_bufferSize(bufferSize)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Writes the bytes to the filesystem backend implementation
|
||||
* @param buffer bytes to write
|
||||
* @param bytes number of bytes to write
|
||||
* @return non-zero code if failure
|
||||
*/
|
||||
virtual int write(char* buffer, size_t bytes) = 0;
|
||||
|
||||
virtual int put(char c)
|
||||
{
|
||||
char a[1];
|
||||
a[0] = c;
|
||||
return write(a, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the internal buffer is written to the filesystem.
|
||||
*/
|
||||
virtual void flush() = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* fstream implementation of the block reader.
|
||||
*/
|
||||
class fstream_block_reader : public block_reader
|
||||
{
|
||||
private:
|
||||
std::fstream& m_stream;
|
||||
char* m_buffer = nullptr;
|
||||
size_t readIndex = 0;
|
||||
public:
|
||||
explicit fstream_block_reader(std::fstream& stream, size_t bufferSize = 131072);
|
||||
|
||||
explicit fstream_block_reader(fstream_block_reader& copy) = delete;
|
||||
|
||||
explicit fstream_block_reader(fstream_block_reader&& move) = delete;
|
||||
|
||||
fstream_block_reader& operator=(const fstream_block_reader& copy) = delete;
|
||||
|
||||
fstream_block_reader& operator=(const fstream_block_reader&& move) = delete;
|
||||
|
||||
int read(char* buffer, size_t bytes) override;
|
||||
|
||||
size_t gcount() final
|
||||
{
|
||||
return m_stream.gcount();
|
||||
}
|
||||
|
||||
~fstream_block_reader()
|
||||
{
|
||||
delete[] m_buffer;
|
||||
}
|
||||
};
|
||||
|
||||
class fstream_block_writer : public block_writer
|
||||
{
|
||||
private:
|
||||
std::fstream& m_stream;
|
||||
char* m_buffer;
|
||||
size_t writeIndex = 0;
|
||||
|
||||
void flush_internal();
|
||||
|
||||
public:
|
||||
explicit fstream_block_writer(std::fstream& stream, size_t bufferSize = 131072):
|
||||
block_writer(bufferSize), m_stream(stream), m_buffer(new char[bufferSize])
|
||||
{}
|
||||
|
||||
explicit fstream_block_writer(fstream_block_writer& copy) = delete;
|
||||
|
||||
explicit fstream_block_writer(fstream_block_writer&& move) = delete;
|
||||
|
||||
fstream_block_writer& operator=(const fstream_block_writer& copy) = delete;
|
||||
|
||||
fstream_block_writer& operator=(const fstream_block_writer&& move) = delete;
|
||||
|
||||
int write(char* buffer, size_t bytes) override;
|
||||
|
||||
inline void flush() override
|
||||
{
|
||||
flush_internal();
|
||||
}
|
||||
|
||||
~fstream_block_writer()
|
||||
{
|
||||
flush_internal();
|
||||
delete[] m_buffer;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif //BLT_FILESYSTEM_H
|
|
@ -52,34 +52,6 @@ namespace blt::fs
|
|||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static inline std::string loadShaderFile(std::string_view path)
|
||||
{
|
||||
std::stringstream stringStream;
|
||||
|
||||
auto lines = recursiveInclude(path);
|
||||
|
||||
for (const auto& line : lines)
|
||||
{
|
||||
// now process the defines, if they exist
|
||||
// if (line.starts_with("#define")) {
|
||||
// auto defineParts = String::split(line, " ");
|
||||
// // create a new define statement in the defines place but with the respective value.
|
||||
// if (defines.contains(defineParts[1])) {
|
||||
// stringStream << "#define ";
|
||||
// stringStream << defineParts[1] << " ";
|
||||
// stringStream << defines[defineParts[1]];
|
||||
// stringStream << "\n";
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
stringStream << line;
|
||||
stringStream << "\n";
|
||||
}
|
||||
|
||||
//tlog << stringStream.str();
|
||||
return stringStream.str();
|
||||
}
|
||||
}
|
||||
|
||||
#endif //BLT_TESTS_LOADER_H
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* <Short Description>
|
||||
* Copyright (C) 2024 Brett Terpstra
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef BLT_FIXED_POINT_VECTORS_H
|
||||
#define BLT_FIXED_POINT_VECTORS_H
|
||||
|
||||
#include <blt/math/fixed_point.h>
|
||||
#include <blt/math/vectors.h>
|
||||
|
||||
namespace blt
|
||||
{
|
||||
|
||||
using vec2fp = blt::vec<blt::fp64, 2>;
|
||||
using vec3fp = blt::vec<blt::fp64, 3>;
|
||||
using vec4fp = blt::vec<blt::fp64, 4>;
|
||||
|
||||
}
|
||||
|
||||
#endif //BLT_FIXED_POINT_VECTORS_H
|
|
@ -17,6 +17,8 @@
|
|||
namespace blt
|
||||
{
|
||||
|
||||
#define MSVC_COMPILER (!defined(__GNUC__) && !defined(__clang__))
|
||||
|
||||
constexpr float EPSILON = 0.0001f;
|
||||
|
||||
static inline constexpr bool f_equal(float v1, float v2)
|
||||
|
@ -24,8 +26,6 @@ namespace blt
|
|||
return v1 >= v2 - EPSILON && v1 <= v2 + EPSILON;
|
||||
}
|
||||
|
||||
#define MSVC_COMPILER (!defined(__GNUC__) && !defined(__clang__))
|
||||
|
||||
template<typename T, std::uint32_t size>
|
||||
struct vec
|
||||
{
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <blt/math/fixed_point.h>
|
||||
#include <blt/math/fixed_point_vectors.h>
|
||||
#include <blt/math/vectors.h>
|
||||
#include <blt/std/logging.h>
|
||||
#include <iostream>
|
||||
|
@ -25,8 +26,6 @@
|
|||
#include <iomanip>
|
||||
#include <limits>
|
||||
|
||||
using vec3fp = blt::vec<blt::fp64, 3>;
|
||||
|
||||
namespace blt::test
|
||||
{
|
||||
void print(fp64 v, const std::string& name = "")
|
||||
|
|
Loading…
Reference in New Issue