-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathprogress_bar.hpp
More file actions
46 lines (32 loc) · 865 Bytes
/
progress_bar.hpp
File metadata and controls
46 lines (32 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef _PROGRESS_BAR_
#define _PROGRESS_BAR_
#ifdef _WINDOWS
#include <windows.h>
#else
#include <sys/ioctl.h>
#endif
#include <iostream>
#include <iomanip>
#include <cstring>
#define TOTAL_PERCENTAGE 100.0
#define CHARACTER_WIDTH_PERCENTAGE 4
class ProgressBar{
public:
ProgressBar();
ProgressBar(unsigned long n_, const char *description_="", std::ostream& out_=std::cerr);
void SetFrequencyUpdate(unsigned long frequency_update_);
void SetStyle(const char* unit_bar_, const char* unit_space_);
void Progressed(unsigned long idx_);
private:
unsigned long n;
unsigned int desc_width;
unsigned long frequency_update;
std::ostream* out;
const char *description;
const char *unit_bar;
const char *unit_space;
void ClearBarField();
int GetConsoleWidth();
int GetBarLength();
};
#endif