2024-09-24 20:37:54 -04:00
# **BLT v0.20**
2024-04-09 18:03:33 -04:00
A C++17 common utilities library to make thing easy!
2023-01-24 15:57:52 -05:00
![Icon ](icon_large.png )
2023-07-21 22:45:23 -04:00
---
2023-01-24 15:57:52 -05:00
2024-04-09 18:03:33 -04:00
# ***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
2024-04-09 18:24:34 -04:00
- Provides a 64bit fixed point number with 2^32 bits of precision on each side of the decimal
- Mostly optimal assembly, avoids sign extension by using 64 bit numbers
- Requires your compiler to support 128 bit numbers
- Docs: TODO
- ### fixed_point_vector.h
- Not finished due to complications in the vector type, this is a TODO
- ### log_util.h
- provides overloads for logging math types
- ### math.h
- blt::toRadians
- to radians function (from deg)
- blt::f_randi
- fast random integer from seed
- blt::fsqrt
- fast inverse square root algorithm, floats only
- blt::pow
- power function
- blt::round_up
- rounds up to a variable number of decimal places
2024-04-09 18:03:33 -04:00
2023-07-21 22:45:23 -04:00
# Specialties
## blt::logging.v2
Found in the header file `include/std/logging.h` , blt::logging is a fast and simple
single header logging library which can be used independently of BLT. Just include
the header file anywhere in your project and in ONE cpp file define `#define BLT_LOGGING_IMPLEMENTATION` .
If you are using BLT as a CMake library (as you should!) this is done for you.
- ### Compile Time Config
- Using CMake
2023-07-22 12:30:07 -04:00
- Several options are provided which disable various logging contexts, as such global logging can be disabled by passing `-DBLT_DISABLE_LOGGING:BOOL=ON`
- Options follow the pattern of `BLT_DISABLE_LEVEL` where level is one of `TRACE` ,`DEBUG`,`INFO`,`WARN`,`ERROR`, or `FATAL` .
2024-09-04 16:03:13 -04:00
- This allows for individual_t logging levels to be disabled while leaving the others functional. These options can be combined.
2023-07-22 12:30:07 -04:00
- See CMakeLists.txt for a complete list of options.
- Standalone
- The CMake options define global variables in a config file. If you are using logging standalone you will need to remove the config include.
- Macros can be used in the same pattern of `BLT_DISABLE_LEVEL` to disable the various logging levels
2023-10-05 02:07:17 -04:00
## blt::arg_parse
blt::arg_parse found in `blt/parse/argparse.h` is an attempt at a near 1:1 replication of Python's argparse in C++.
Python's argparse is one of the best command line argument parsing solutions with some of the best documentation I've seen.
The goal was to create an API which would function exactly as the Python docs described, simplifying how much I needed to remember and document for this library.
## 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
2024-04-09 18:03:33 -04:00
compatability. Due to changes in the API the `BLT_PRINT_PROFILE` macro deletes the internal profiles and intervals AND takes arguments which match
2023-10-05 02:07:17 -04:00
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)
2023-07-21 22:45:23 -04:00
---
# **Features / Examples**
2023-01-24 15:57:52 -05:00
- ## Data Structures
- Queue / Stack
- faster than std::queue / std::stack
2023-07-24 02:39:03 -04:00
- backed by a contiguous array
2023-01-24 15:57:52 -05:00
- ## Utility
2023-07-24 02:39:03 -04:00
- Simple Random Wrapper Interface
- Simple random functions based on the PCG Hash
2023-01-24 15:57:52 -05:00
- ### String Functions
- starts_with
- ends_with
- contains
- toLowerCase
- toUpperCase
- split
- trim
- Logging
2023-07-24 02:39:03 -04:00
- See blt::logging section above
2023-01-24 15:57:52 -05:00
- Time
- Current time in nanoseconds (without all the c++ gobbledygook)
2023-07-24 02:39:03 -04:00
- Java's currentTimeMilliseconds
- nanoTime as well
- `std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count()` becomes `blt::system::nanoTime()`
2023-01-24 15:57:52 -05:00
- Formatted time string with year/month/date + current time
- ## Profiling
2024-09-24 20:37:54 -04:00
- Basic profiler with history and formatted output