mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-14 08:47:57 -05:00
Replace FileAPI with c++ streams and std::filesystem
This commit is contained in:
@ -1,16 +1,12 @@
|
||||
#include "StringFileDumper.h"
|
||||
#include <regex>
|
||||
|
||||
StringFileDumper::StringFileDumper(Zone* zone, FileAPI::File* file)
|
||||
StringFileDumper::StringFileDumper(Zone* zone, std::ostream& stream)
|
||||
: m_zone(zone),
|
||||
m_stream(stream),
|
||||
m_language_caps("ENGLISH"),
|
||||
m_wrote_header(false)
|
||||
{
|
||||
m_zone = zone;
|
||||
m_file = file;
|
||||
|
||||
m_config_file = "";
|
||||
m_notes = "";
|
||||
m_language_caps = "ENGLISH";
|
||||
|
||||
m_wrote_header = false;
|
||||
}
|
||||
|
||||
void StringFileDumper::SetLanguageName(std::string language)
|
||||
@ -31,11 +27,11 @@ void StringFileDumper::SetNotes(std::string notes)
|
||||
|
||||
void StringFileDumper::WriteHeader()
|
||||
{
|
||||
m_file->Printf("// Dumped from fastfile \"%s\".\n", m_zone->m_name.c_str());
|
||||
m_file->Printf("// In their original format the strings might have been separated in multiple files.\n");
|
||||
m_file->Printf("VERSION \"1\"\n");
|
||||
m_file->Printf("CONFIG \"%s\"\n", m_config_file.c_str());
|
||||
m_file->Printf("FILENOTES \"%s\"\n", m_notes.c_str());
|
||||
m_stream << "// Dumped from fastfile \"" << m_zone->m_name << "\".\n";
|
||||
m_stream << "// In their original format the strings might have been separated in multiple files.\n";
|
||||
m_stream << "VERSION \"1\"\n";
|
||||
m_stream << "CONFIG \"" << m_config_file << "\"\n";
|
||||
m_stream << "FILENOTES \"" << m_notes << "\"\n";
|
||||
|
||||
m_wrote_header = true;
|
||||
}
|
||||
@ -45,13 +41,13 @@ void StringFileDumper::WriteLocalizeEntry(const std::string& reference, const st
|
||||
if (!m_wrote_header)
|
||||
WriteHeader();
|
||||
|
||||
m_file->Printf("\n");
|
||||
m_file->Printf("REFERENCE %s\n", reference.c_str());
|
||||
m_stream << "\n";
|
||||
m_stream << "REFERENCE " << reference <<"\n";
|
||||
|
||||
const std::string escapedValue = std::regex_replace(value, std::regex("\n"), "\\n");
|
||||
const auto escapedValue = std::regex_replace(value, std::regex("\n"), "\\n");
|
||||
|
||||
const std::string valueSpacing = std::string(15 - m_language_caps.length(), ' ');
|
||||
m_file->Printf("LANG_%s%s\"%s\"\n", m_language_caps.c_str(), valueSpacing.c_str(), escapedValue.c_str());
|
||||
const auto valueSpacing = std::string(15 - m_language_caps.length(), ' ');
|
||||
m_stream << "LANG_" << m_language_caps << valueSpacing << "\"" << escapedValue << "\"\n";
|
||||
}
|
||||
|
||||
void StringFileDumper::Finalize()
|
||||
@ -59,5 +55,5 @@ void StringFileDumper::Finalize()
|
||||
if (!m_wrote_header)
|
||||
WriteHeader();
|
||||
|
||||
m_file->Printf("\nENDMARKER");
|
||||
}
|
||||
m_stream << "\nENDMARKER";
|
||||
}
|
||||
|
Reference in New Issue
Block a user