Skip to content
Extraits de code Groupes Projets
Valider 7b06c334 rédigé par Amar Takhar's avatar Amar Takhar
Parcourir les fichiers

Add missing headers and change StdioProgressSink() to use std::cout and friends.

Originally committed to SVN as r5314.
parent e27c3e15
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -19,7 +19,12 @@
/// @ingroup libaegisub
#ifndef LAG_PRE
#include <assert.h>
#include <string>
#include <iomanip>
#include <iostream>
#include <cmath>
#endif
#include "libaegisub/progress.h"
......@@ -42,14 +47,13 @@ ProgressSink * NullProgressSinkFactory::create_progress_sink(const std::string &
class StdioProgressSink : public ProgressSink {
private:
FILE *file;
std::string operation;
float progress;
void print();
public:
StdioProgressSink(FILE *file, const std::string &title);
StdioProgressSink(const std::string &title);
virtual ~StdioProgressSink();
virtual void set_progress(int steps, int max);
virtual void set_operation(const std::string &operation);
......@@ -57,21 +61,20 @@ public:
};
ProgressSink * StdioProgressSinkFactory::create_progress_sink(const std::string &title) const {
return new StdioProgressSink(file, title);
return new StdioProgressSink(title);
}
StdioProgressSink::StdioProgressSink(FILE *file, const std::string &title)
: file(file)
, operation(title)
StdioProgressSink::StdioProgressSink(const std::string &title)
: operation(title)
, progress(0) {
fprintf(file, "=== %s ===\n", title.c_str());
std::cout << title << ": ";
print();
}
StdioProgressSink::~StdioProgressSink()
{
fprintf(file, "\n -===-\n");
std::cout << "end" << std::endl;
}
......@@ -82,7 +85,7 @@ void StdioProgressSink::set_progress(int steps, int max) {
float old_progress = progress;
progress = (100.f * steps)/max;
if (fabs(progress-old_progress) > 0.8)
if (std::fabs(progress-old_progress) > 0.8)
{
print();
}
......@@ -96,7 +99,7 @@ void StdioProgressSink::set_operation(const std::string &operation) {
void StdioProgressSink::print() {
fprintf(file, "%s: %.1f%%\r", operation.c_str(), progress);
std::cout << operation << ": " << std::setprecision(2) << progress << std::endl;
}
......
......@@ -50,10 +50,9 @@ public:
class StdioProgressSinkFactory : public ProgressSinkFactory {
private:
FILE *file;
public:
StdioProgressSinkFactory(FILE *file) : file(file) { }
StdioProgressSinkFactory();
virtual ProgressSink * create_progress_sink(const std::string &title) const;
};
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter