Pasha Bibko Util Library
|
Classes | |
struct | DefaultError |
Default error class for Uti::ReturnVal. More... | |
struct | FileReadError |
Error returned when PashaBibko::Util::ReadFile() fails. More... | |
struct | FunctionFail |
Class to create when a function fails. More... | |
class | ReturnVal |
Class to return a result from a function that can fail. More... | |
struct | StringLocation |
Location within a string. More... | |
struct | Vec |
Mathmatical vector class. More... | |
Enumerations | |
enum class | Colour : unsigned short { Default = 0x07 , Black = 0x00 , Blue = 0x01 , Green = 0x02 , Aqua = 0x03 , Red = 0x04 , Purple = 0x05 , Yellow = 0x06 , LightGray = 0x07 , LightBlue = 0x09 , LightGreen = 0x0a , LightAqua = 0x0b , LightRed = 0x0c , LightPurple = 0x0d , LightYellow = 0x0e , White = 0x0f } |
Representation of each color and its corresponding Win32 console color code. Other operating systems use a switch statement to translate the codes from Win32 to their values. More... | |
Functions | |
template<std::size_t len, typename LhsTy , typename RhsTy , typename ResTy = Internal::AddResultT<LhsTy, RhsTy>> requires Internal::CanAdd<LhsTy, RhsTy> | |
Vec< len, ResTy > | operator+ (const Vec< len, LhsTy > &lhs, const Vec< len, RhsTy > &rhs) |
Adds two vectors together. | |
template<std::size_t len, typename LhsTy , typename RhsTy , typename ResTy = Internal::SubResultT<LhsTy, RhsTy>> requires Internal::CanSub<LhsTy, RhsTy> | |
Vec< len, ResTy > | operator- (const Vec< len, LhsTy > &lhs, const Vec< len, RhsTy > &rhs) |
Subtracts the right vector by the left vector. | |
template<std::size_t len, typename LhsTy , typename RhsTy , typename ResTy = Internal::MulResultT<LhsTy, RhsTy>> requires Internal::CanMul<LhsTy, RhsTy> | |
Vec< len, ResTy > | operator* (const Vec< len, LhsTy > &lhs, const Vec< len, RhsTy > &rhs) |
Multiplies two vectors together. | |
template<std::size_t len, typename LhsTy , typename RhsTy , typename ResTy = Internal::SubResultT<LhsTy, RhsTy>> requires Internal::CanDiv<LhsTy, RhsTy> | |
Vec< len, ResTy > | operator/ (const Vec< len, LhsTy > &lhs, const Vec< len, RhsTy > &rhs) |
Divides the left vector by the right vector. | |
template<std::size_t len, typename LhsTy , typename RhsTy > requires Internal::CanEqualityCheck<LhsTy, RhsTy> | |
bool | operator== (const Vec< len, LhsTy > &lhs, const Vec< len, RhsTy > &rhs) |
Checks if two vectors are equal. | |
template<std::size_t len, typename LhsTy , typename RhsTy > requires Internal::CanEqualityCheck<LhsTy, RhsTy> | |
bool | operator!= (const Vec< len, LhsTy > &lhs, const Vec< len, RhsTy > &rhs) |
Checks if two vectors are not equal. | |
ReturnVal< std::string, FileReadError > | ReadFile (const std::filesystem::path &path) |
Reads a file to a string. | |
StringLocation | GetLocationAtStringIndex (const std::string &string, uint32_t index) |
Finds the location of [colummn, line] of a given index. | |
template<Colour colour = Colour::Default, typename... Args> requires (Internal::Logable<std::remove_cvref_t<Args>> && ...) | |
void | Print (Args &&... args) |
Prints the message to the console. | |
template<typename... Args> requires (Internal::Logable<std::remove_cvref_t<Args>> && ...) | |
void | Log (Args &&... args) |
Logs the message to the log file and console. | |
void | SetConsoleColor (Colour col) |
Sets the console to display text with a certain color. | |
void | TriggerBreakpoint () |
Triggers a breakpoint if there is a Debugger to attach to. | |
void | EndProcess (bool breakpoint=true) |
Ends the current process. | |
Representation of each color and its corresponding Win32 console color code. Other operating systems use a switch statement to translate the codes from Win32 to their values.
Ends the current process.
breakpoint | If true will trigger a breakpoint before exiting (defaults to true) |
StringLocation GetLocationAtStringIndex | ( | const std::string & | string, |
uint32_t | index | ||
) |
Finds the location of [colummn, line] of a given index.
string | The string that will be searched for the index. |
index | The index that the location will be returned. |
|
inline |
Logs the message to the log file and console.
See PashaBibko::Util::Print() for how different types can be logged. Log() also has a function overload for printing ranges. Any type that can be iterated over using begin() and end() such as std::array or std::vector. It also requires that type that is returned whilst iterating is also loggable. For example:
bool operator!= | ( | const Vec< len, LhsTy > & | lhs, |
const Vec< len, RhsTy > & | rhs | ||
) |
Checks if two vectors are not equal.
Requires both the == and != operators to be available for both types.
Vec< len, ResTy > operator* | ( | const Vec< len, LhsTy > & | lhs, |
const Vec< len, RhsTy > & | rhs | ||
) |
Multiplies two vectors together.
Requires the two types contained in the vector to be able to be multiplied together. The result type will also be the same type as when they are normally multiplied together.
Vec< len, ResTy > operator+ | ( | const Vec< len, LhsTy > & | lhs, |
const Vec< len, RhsTy > & | rhs | ||
) |
Adds two vectors together.
Requires the two types contained in the vector to be able to be added together. The result type will also be the same type as when they are normally added together.
Vec< len, ResTy > operator- | ( | const Vec< len, LhsTy > & | lhs, |
const Vec< len, RhsTy > & | rhs | ||
) |
Subtracts the right vector by the left vector.
Requires the two types contained in the vector to be able to be subtracted from each other The result type will also be the same type as when they are normally subtracted.
Vec< len, ResTy > operator/ | ( | const Vec< len, LhsTy > & | lhs, |
const Vec< len, RhsTy > & | rhs | ||
) |
Divides the left vector by the right vector.
Requires the two types contained in the vector to be able to be divided from each other. The result type will also be the same type as when they are normally divided together.
bool operator== | ( | const Vec< len, LhsTy > & | lhs, |
const Vec< len, RhsTy > & | rhs | ||
) |
Checks if two vectors are equal.
Requires both the == and != operators to be available for both types.
|
inline |
Prints the message to the console.
Types can be printed in 2 different ways. The first is if the type has a std::ostream& bit-shift operator overload defined. This is the operator that std::cout uses for outputting so will be used by all intergral types.
The second way is by having a LogStr() method that returns a string. Below are some examples of logging with these methods.
Instead of adding a new line('
') character at the end of the message you can use Util::PrintLn which will automatically apend it for you.
colour | (Optional) the color that it will print to the console in. |
ReturnVal< std::string, FileReadError > ReadFile | ( | const std::filesystem::path & | path | ) |
Reads a file to a string.
Will check if the file path is valid and will return a FileReadError with a relevant error if invalid.
path | File path to read from |
Sets the console to display text with a certain color.
Supported on Windows and UNIX based operating systems. If it is unable to set the color it will silently fail.
col | The color that the console will be set to. |
void TriggerBreakpoint | ( | ) |
Triggers a breakpoint if there is a Debugger to attach to.
Calls DebugBreak()
on Windows or std::raise(SIGTRAP)
on Linux based systems. On windows will check if there is a debugger attached but will not on Linux.