From 0a5e1c8169068f7c94815c03a8cb6689c5b7f86a Mon Sep 17 00:00:00 2001 From: karutoh Date: Thu, 1 Feb 2024 01:24:00 -0800 Subject: [PATCH] First commit. --- README.md | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/README.md b/README.md index e69de29..fced706 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,67 @@ +# Compiling + +## Prerequisites +### Windows +- [Visual Studio Community](https://visualstudio.microsoft.com/vs/community/) +- [CMake](https://cmake.org/) + +### Linux +- **Arch Linux**: `sudo pacman -S gcc cmake` +- **Debian Linux**: `sudo apt install gcc cmake` + +## Building +### Linux +1. `cmake -DCMAKE_BUILD_TYPE=Release -DLINUX_WINDOW_SYSTEM:STRING=XCB /path/to/source` +2. `cmake --build /path/to/build --config Release` + +# Simple Example +```c++ +#include +#include + +void LogRaised(const ehs::Log& log) +{ + ehs::Array tags = log.GetTags(); // Retrieves the tags from the log such as line number, function, etc... + + ehs::Str_8 result = "{"; + + for (ehs::UInt_32 i = 0; i < tags.Size(); ++i) + { + result += tags[i]; + if (i != tags.Size() - 1) + result += ", "; + } + + result += "} (" + ehs::Str_8::FromNum(log.GetCode()) + "): " + log.GetMsg(); // Adds the error code and message from the log. + + ehs::Console::Write_8(result); +} + +ehs::SInt_32 Main(ehs::Str_8* appName, ehs::Str_8* appVerId, ehs::Version* appVer) +{ + // Simple identifying meta-data for the logger. + *appName = "Simple Example App"; // The application's name + *appVerId = "Release"; // The app's version prefix; i.e. Alpha, Beta or Release as an example. + *appVer = {1, 0, 0}; // The app's version major, minor and patch number. + + ehs::Console::Attach(); // Attach to the console. + + ehs::Log::SetCallback(LogRaised); // Sets the log callback function for outputting the information to console. + + ehs::Console::Write_8("How old are you?"); // Write to the console in UTF_8 character encoding. + + ehs::Str_8 response = ehs::Console::Read_8(); // Read from the console in UTF_8 character encoding. + + if (!response.IsNum()) + { + ehs::Console::Clear(); // Clear the console's buffer. + return Main(appName, appVerId, appVer); // Repeat process if given response is not a number. + } + + ehs::UInt_8 age = response.ToDecimal(); // Converts the string number into a number based primitive. + + ehs::Console::Write("Your age is " + ehs::Str_8::FromNum(age) + "."); // Write the console with the age converted back to string. + + return 0; +} +``` \ No newline at end of file