Introducing ALib: Your Cross-Platform C++ Utility Library
Tags: cpp, library, crossplatform, utility
Published: 2023-09-11 09:46:04

I'm Mushfiqur Rahman Abir, a computer science student, and I'd like to introduce you to ALib, a powerful cross-platform C++ header-only library I've been developing. ALib is the result of my passion for simplifying software development by providing a collection of commonly used utility functions that can save you time and effort. I want to emphasize that ALib is still in its early stages of development, and I'm actively seeking contributions from the community to help expand its functionality.

It is mainly a small library that can make your c++ coding a lot easier by giving you some great usefull functions that you won't need to implement every time in every project as these functions abilities are much common in need.

## Features
ALib offers several key features that make it a valuable addition to your C++ projects:
- **Cross-Platform Compatibility:** ALib works seamlessly on Windows, Linux, and macOS, ensuring your code functions consistently across different environments.
- **Modular Extensibility:** ALib's modular, function-based structure allows you to easily modify or extend its features to meet your project's specific requirements.
- **Colored Text Decorations:** ALib leverages the rang library to support colored text output, adding visual appeal to your terminal displays.

## Provided Functions
Within ALib, you'll find a range of functions designed to simplify various tasks in your C++ projects. These functions include:
- `clrscr` for clearing the screen.
- `consoleWidth` and `consoleHeight` to determine terminal dimensions.
- `countdown` for creating dynamic countdowns.
- `showLoadingScreen` for displaying loading screens.
- `horizontalLine` and `verticalLine` to draw lines within the terminal.

I have planned to add some more functions in future.

## Why Use These Functions from the Library?

You might be wondering why you should consider incorporating the functions provided by ALib into your C++ projects. Here are some compelling reasons:

1. **Saves Development Time:** ALib eliminates the need to reinvent the wheel by offering a collection of utility functions commonly used in various projects. This saves you valuable development time that can be better spent on implementing your project's core logic.

2. **Cross-Platform Compatibility:** ALib is designed to work seamlessly on Windows, Linux, and macOS. By using ALib functions, you ensure that your code behaves consistently across different operating systems, reducing the risk of platform-specific issues.

3. **Modular and Extensible:** ALib's modular architecture allows you to pick and choose the functions you need, keeping your codebase clean and organized. Additionally, you can easily extend or modify these functions to tailor them to your specific project requirements.

4. **Enhanced User Experience:** ALib's support for colored text decorations through the rang library enables you to create visually appealing and informative terminal displays. This can enhance the user experience of your command-line applications.

5. **Beginner-Friendly:** ALib is designed to be beginner-friendly, making it accessible to developers of all skill levels. If you're new to C++ or programming in general, ALib can serve as a valuable resource to kickstart your projects.

6. **Community Contributions:** By using ALib, you become part of a growing community of developers contributing to and improving the library. Your feedback and contributions can help shape the future of ALib and benefit the entire community.

In summary, ALib simplifies the development process, promotes code reusability, and enhances the functionality of your C++ projects. Whether you're a seasoned developer or just starting your coding journey, ALib offers valuable tools to make your programming tasks easier and more efficient.

### Time for an Example

#### Without Using ALib
So we often want to make the title of our project a bit fancy when we are making some terminal based application in cpp. So to do that we have to write the code somewhat like this -

```c++
#include <iostream>
#include <string>

// Function to decorate text with asterisks above and below
std::string decorateText(const std::string& text) {
    int textLength = text.length();
    std::string decoration(textLength + 4, '*');
    return decoration + "\n* " + text + " *\n" + decoration;
}

int main() {
    // Input text
    std::string inputText = "My project";

    // Decorate the text
    std::string decoratedText = decorateText(inputText);

    // Print the decorated text
    std::cout << decoratedText << std::endl;

    return 0;
}
```

And you have to write this every time you do a project to just add a bit changes.

#### With ALib
You can do the same thing in just one line and also customize the banner/title as you want without the need to chnage the core function code

```c++
include "Alib"
int main(){
decorateMe("ALib", 2, "_");
}
```

Done ✅. And you will get an output like this 

```bash
______________________________
ALib
______________________________
```

Of course this saves time and effort. You can view more examples by running the [_test_](https://github.com/Abir-Tx/ALib/blob/main/test/alibTest.cpp) file present in the repo.

## Installation Guide

### Windows
1. To use ALib on Windows, download the `alib.hpp` header file from the [ALib GitHub repository](https://github.com/Abir-Tx/ALib/releases).
2. Place the downloaded `alib.hpp` file in the directory where you're working on your C++ project.
3. You can now include `alib.hpp` in your C++ code and start using the ALib functions in your Windows project.

### Linux & Mac OS
1. Download the `alib.hpp` header file from the [ALib GitHub repository](https://github.com/Abir-Tx/ALib/releases).
2. Copy the `alib.hpp` file to `/usr/include`
3. You can now use the linrary in your project code or in IDE/Editor of choice using the 
```
#include "alib.hpp"
```

### Arch Linux 
Arch users can install the library from AUR easily using yay/paru
```bash
yay -S alib
```

## Contributing
I welcome contributions from the community to help make ALib even more valuable. It's designed to be beginner-friendly, making it accessible for developers of all levels. Whether you're reporting a bug, fixing an issue, or adding new features to this library, your contributions are highly appreciated. You can learn more about how to get involved by reading the [contribution documentation](https://github.com/Abir-Tx/ALib/blob/main/docs/CONTRIBUTING.md).

## Conclusion
In conclusion, ALib is your go-to solution for simplifying C++ development across various platforms. Since it's still in its early stages, your contributions are essential in making it even more valuable to the developer community. I invite you to explore the ALib GitHub repository to get started and to join our community of contributors.

Mushfiqur Rahman Abir
_Computer Science Engineer_