mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 21:25:36 -04:00
Apply clang-format on entire source
This commit is contained in:
parent
4c17061a1d
commit
1bc2bd8460
181 changed files with 7372 additions and 6952 deletions
|
|
@ -1,17 +1,19 @@
|
|||
|
||||
#include "openmc/progress_bar.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#if defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))
|
||||
#if defined(__unix__) || defined(__unix) || \
|
||||
(defined(__APPLE__) && defined(__MACH__))
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#define BAR_WIDTH 72
|
||||
|
||||
bool is_terminal() {
|
||||
bool is_terminal()
|
||||
{
|
||||
#ifdef _POSIX_VERSION
|
||||
return isatty(STDOUT_FILENO) != 0;
|
||||
#else
|
||||
|
|
@ -19,15 +21,17 @@ bool is_terminal() {
|
|||
#endif
|
||||
}
|
||||
|
||||
ProgressBar::ProgressBar() {
|
||||
ProgressBar::ProgressBar()
|
||||
{
|
||||
// initialize bar
|
||||
set_value(0.0);
|
||||
}
|
||||
|
||||
void
|
||||
ProgressBar::set_value(double val) {
|
||||
void ProgressBar::set_value(double val)
|
||||
{
|
||||
|
||||
if (!is_terminal()) return;
|
||||
if (!is_terminal())
|
||||
return;
|
||||
|
||||
// set the bar percentage
|
||||
if (val >= 100.0) {
|
||||
|
|
@ -50,17 +54,19 @@ ProgressBar::set_value(double val) {
|
|||
} else if (val < 0.0) {
|
||||
bar.append(remaining_width, ' ');
|
||||
} else {
|
||||
int width = (int)((double)remaining_width*val/100);
|
||||
int width = (int)((double)remaining_width * val / 100);
|
||||
bar.append(width, '=');
|
||||
bar.append(1, '>');
|
||||
bar.append(remaining_width-width-1, ' ');
|
||||
bar.append(remaining_width - width - 1, ' ');
|
||||
}
|
||||
|
||||
bar.append("|+");
|
||||
|
||||
// write the bar
|
||||
std::cout << '\r' << bar << std::flush;
|
||||
if (val >= 100.0) { std::cout << "\n"; }
|
||||
if (val >= 100.0) {
|
||||
std::cout << "\n";
|
||||
}
|
||||
|
||||
// reset the bar value
|
||||
bar = "";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue