Expunge remaining references to <fstream> and <iostream>

This commit is contained in:
Thomas Goyne 2014-03-21 14:23:52 -07:00
parent db7c8f49cb
commit 53188cca47
21 changed files with 13 additions and 35 deletions

View File

@ -9,7 +9,6 @@ Author: Terry Caton
#include "libaegisub/cajun/writer.h"
#include <cmath>
#include <iostream>
#include <iomanip>
/*

View File

@ -30,7 +30,6 @@
#include <boost/algorithm/string/join.hpp>
#include <boost/range/adaptor/map.hpp>
#include <cmath>
#include <fstream>
#include <tuple>
namespace agi {

View File

@ -30,17 +30,16 @@
namespace agi {
namespace io {
std::unique_ptr<std::ifstream> Open(fs::path const& file, bool binary) {
std::unique_ptr<std::istream> Open(fs::path const& file, bool binary) {
LOG_D("agi/io/open/file") << file;
acs::CheckFileRead(file);
std::unique_ptr<std::ifstream> stream(
new boost::filesystem::ifstream(file, (binary ? std::ios::binary : std::ios::in)));
auto stream = util::make_unique<boost::filesystem::ifstream>(file, (binary ? std::ios::binary : std::ios::in));
if (stream->fail())
throw IOFatal("Unknown fatal error as occurred");
return stream;
return std::unique_ptr<std::istream>(stream.release());
}
Save::Save(fs::path const& file, bool binary)
@ -63,7 +62,7 @@ Save::Save(fs::path const& file, bool binary)
}
Save::~Save() {
fp->close(); // Need to close before rename on Windows to unlock the file
fp.reset(); // Need to close before rename on Windows to unlock the file
for (int i = 0; i < 10; ++i) {
try {
fs::Rename(tmp_name, file_name);

View File

@ -22,7 +22,6 @@
#include "libaegisub/keyframe.h"
#include <algorithm>
#include <fstream>
#include "libaegisub/io.h"
#include "libaegisub/line_iterator.h"
@ -78,14 +77,14 @@ char x264(std::string const& line) {
namespace agi { namespace keyframe {
void Save(agi::fs::path const& filename, std::vector<int> const& keyframes) {
io::Save file(filename);
std::ofstream& of = file.Get();
std::ostream& of = file.Get();
of << "# keyframe format v1" << std::endl;
of << "fps " << 0 << std::endl;
boost::copy(keyframes, std::ostream_iterator<int>(of, "\n"));
}
std::vector<int> Load(agi::fs::path const& filename) {
std::unique_ptr<std::ifstream> file(io::Open(filename));
auto file = io::Open(filename);
std::istream &is(*file);
std::string header;

View File

@ -28,8 +28,6 @@
#include "libaegisub/option.h"
#include "libaegisub/option_value.h"
#include <fstream>
namespace agi {
MRUManager::MRUManager(agi::fs::path const& config, std::pair<const char *, size_t> default_config, agi::Options *options)

View File

@ -34,7 +34,6 @@
#include <boost/interprocess/streams/bufferstream.hpp>
#include <boost/range/adaptor/map.hpp>
#include <cassert>
#include <fstream>
#include <memory>
namespace {

View File

@ -28,8 +28,6 @@
#include <boost/phoenix/operator/comparison.hpp>
#include <boost/phoenix/core/argument.hpp>
#include <fstream>
using boost::phoenix::placeholders::_1;
namespace agi {

View File

@ -29,7 +29,6 @@
#include <boost/interprocess/streams/bufferstream.hpp>
#include <boost/range/algorithm.hpp>
#include <cmath>
#include <fstream>
#include <functional>
#include <iterator>
#include <list>

View File

@ -10,7 +10,6 @@ Author: Terry Caton
#include "elements.h"
#include <iostream>
#include <vector>
namespace json

View File

@ -29,17 +29,17 @@ namespace agi {
DEFINE_BASE_EXCEPTION_NOINNER(IOError, Exception)
DEFINE_SIMPLE_EXCEPTION_NOINNER(IOFatal, IOError, "io/fatal")
std::unique_ptr<std::ifstream> Open(fs::path const& file, bool binary = false);
std::unique_ptr<std::istream> Open(fs::path const& file, bool binary = false);
class Save {
std::unique_ptr<std::ofstream> fp;
std::unique_ptr<std::ostream> fp;
const fs::path file_name;
const fs::path tmp_name;
public:
Save(fs::path const& file, bool binary = false);
~Save();
std::ofstream& Get() { return *fp; }
std::ostream& Get() { return *fp; }
};
} // namespace io

View File

@ -37,10 +37,8 @@
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <locale>

View File

@ -24,7 +24,6 @@
#include <boost/algorithm/string/predicate.hpp>
#include <boost/range/iterator_range.hpp>
#include <fstream>
AssAttachment::AssAttachment(AssAttachment const& rgt)
: entry_data(rgt.entry_data)

View File

@ -44,7 +44,6 @@
#include <libaegisub/util.h>
#include <boost/algorithm/string/predicate.hpp>
#include <fstream>
AssStyleStorage::~AssStyleStorage() { }
void AssStyleStorage::clear() { style.clear(); }
@ -67,7 +66,7 @@ void AssStyleStorage::Load(agi::fs::path const& filename) {
clear();
try {
std::unique_ptr<std::ifstream> in(agi::io::Open(file));
auto in = agi::io::Open(file);
for (auto const& line : agi::line_iterator<std::string>(*in)) {
try {
style.emplace_back(agi::util::make_unique<AssStyle>(line));

View File

@ -54,7 +54,6 @@
#include <libaegisub/path.h>
#include <algorithm>
#include <fstream>
AudioController::AudioController(agi::Context *context)
: context(context)
@ -373,7 +372,7 @@ void AudioController::SaveClip(agi::fs::path const& filename, TimeRange const& r
if (filename.empty() || start_sample > provider->GetNumSamples() || range.length() == 0) return;
agi::io::Save outfile(filename, true);
std::ofstream& out(outfile.Get());
std::ostream& out(outfile.Get());
size_t bytes_per_sample = provider->GetBytesPerSample() * provider->GetChannels();
size_t bufsize = (end_sample - start_sample) * bytes_per_sample;

View File

@ -52,7 +52,6 @@
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/filesystem.hpp>
#include <fstream>
namespace {
agi::fs::path cache_dir() {
@ -103,7 +102,7 @@ void HDAudioProvider::FillBuffer(void *buf, int64_t start, int64_t count) const
memcpy(buf, file->read(start, count), count);
}
void HDAudioProvider::FillCache(AudioProvider *src, std::ofstream *out, agi::ProgressSink *ps) {
void HDAudioProvider::FillCache(AudioProvider *src, std::ostream *out, agi::ProgressSink *ps) {
ps->SetMessage(from_wx(_("Reading to Hard Disk cache")));
int64_t block = 65536;

View File

@ -49,7 +49,7 @@ class HDAudioProvider final : public AudioProviderWrapper {
/// @param src Audio data to cache
/// @param file File to write to
/// @param ps Sink for progress reporting
void FillCache(AudioProvider *src, std::ofstream *file, agi::ProgressSink *ps);
void FillCache(AudioProvider *src, std::ostream *file, agi::ProgressSink *ps);
void FillBuffer(void *buf, int64_t start, int64_t count) const override;

View File

@ -46,7 +46,6 @@
#include <libaegisub/cajun/writer.h>
#include <algorithm>
#include <fstream>
#include <vector>
#include <wx/listbox.h>

View File

@ -65,7 +65,6 @@
#include <libaegisub/path.h>
#include <libaegisub/util.h>
#include <boost/filesystem/fstream.hpp>
#include <boost/format.hpp>
#include <boost/interprocess/streams/bufferstream.hpp>
#include <boost/locale.hpp>

View File

@ -34,7 +34,6 @@
#include <boost/format.hpp>
#include <boost/range/algorithm.hpp>
#include <fstream>
#include <hunspell/hunspell.hxx>
HunspellSpellChecker::HunspellSpellChecker()

View File

@ -39,7 +39,6 @@
#include <libaegisub/line_wrap.h>
#include <boost/algorithm/string/replace.hpp>
#include <fstream>
namespace
{

View File

@ -30,7 +30,6 @@
#include <boost/algorithm/string/predicate.hpp>
#include <boost/filesystem.hpp>
#include <fstream>
TextFileWriter::TextFileWriter(agi::fs::path const& filename, std::string encoding)
: file(new agi::io::Save(filename, true))