Initial Commit

This commit is contained in:
Aria 2023-05-06 03:05:17 -07:00
parent 2174872b77
commit be49470a72
3 changed files with 62 additions and 0 deletions

4
source/CMakeLists.txt Normal file
View file

@ -0,0 +1,4 @@
project(aria)
add_library(aria SHARED Progress.cpp Progress.h)

32
source/Progress.cpp Normal file
View file

@ -0,0 +1,32 @@
//
// Created by tara on 5/6/23.
//
#include <sstream>
#include <cstdlib>
#include <stdio.h>
#include <stdlib.h>
#include "Progress.h"
namespace libac {
int Progress::getPercentOf(int cur, int max) {
return (cur*100/max);
}
void Progress::increment() {
this->current++;
if(this->current >= this->max) this->current=this->max;
}
int Progress::getPercent() {
return (this->current*100/this->max);
}
std::string Progress::getProgressStr() {
auto *str = new std::stringstream();
auto buf = new char[128];
auto count = sprintf(buf, "%d%", getPercent());
str->write(buf, count);
return str->str();
}
} // libac

26
source/Progress.h Normal file
View file

@ -0,0 +1,26 @@
//
// Created by tara on 5/6/23.
//
#ifndef LIBAC_CPP_PROGRESS_H
#define LIBAC_CPP_PROGRESS_H
#include <iostream>
#include <string>
namespace libac {
class Progress {
private:
int ticks = 0;
int current = 0;
int max = 100;
public:
static int getPercentOf(int cur, int max);
int getPercent();
void increment();
std::string getProgressStr();
};
} // libac
#endif //LIBAC_CPP_PROGRESS_H