Replace boost::filesystem with std::filesystem

This allows us to use a header-only copy of Boost
This commit is contained in:
Daniel Wolf
2021-06-18 22:00:01 +02:00
parent 74822c4a84
commit 8a94fb7db0
29 changed files with 83 additions and 93 deletions

View File

@@ -5,7 +5,7 @@
#include <map>
#include <tuple>
#include "tools/platformTools.h"
#include <boost/filesystem/fstream.hpp>
#include <fstream>
#include "core/appInfo.h"
#include <cmath>
#include <gsl_util.h>
@@ -17,7 +17,7 @@ using std::map;
using std::tuple;
using std::get;
using std::endl;
using boost::filesystem::path;
using std::filesystem::path;
using Unigram = string;
using Bigram = tuple<string, string>;
@@ -151,7 +151,7 @@ void createLanguageModelFile(const vector<string>& words, const path& filePath)
map<Bigram, double> bigramBackoffWeights =
getBigramBackoffWeights(bigramCounts, bigramProbabilities, trigramCounts, discountMass);
boost::filesystem::ofstream file(filePath);
std::ofstream file(filePath);
file << "Generated by " << appName << " " << appVersion << endl << endl;
file << "\\data\\" << endl;
@@ -193,9 +193,9 @@ lambda_unique_ptr<ngram_model_t> createLanguageModel(
) {
path tempFilePath = getTempFilePath();
createLanguageModelFile(words, tempFilePath);
auto deleteTempFile = gsl::finally([&]() { boost::filesystem::remove(tempFilePath); });
auto deleteTempFile = gsl::finally([&]() { std::filesystem::remove(tempFilePath); });
return lambda_unique_ptr<ngram_model_t>(
ngram_model_read(decoder.config, tempFilePath.string().c_str(), NGRAM_ARPA, decoder.lmath),
ngram_model_read(decoder.config, tempFilePath.u8string().c_str(), NGRAM_ARPA, decoder.lmath),
[](ngram_model_t* lm) { ngram_model_free(lm); });
}