eliminate using namespace

This commit is contained in:
Martin Michelsen
2026-05-25 16:38:31 -07:00
parent 4503d09c77
commit e9c2ac34a3
98 changed files with 6022 additions and 6531 deletions
+15 -17
View File
@@ -7,8 +7,6 @@
#include "Text.hh"
#include "Types.hh"
using namespace std;
template <bool BE>
struct GSLHeaderEntryT {
pstring<TextEncoding::ASCII, 0x20> filename;
@@ -30,13 +28,13 @@ void GSLArchive::load_t() {
}
uint64_t offset = static_cast<uint64_t>(entry.offset) * 0x800;
if (offset + entry.size > this->data->size()) {
throw runtime_error("GSL entry extends beyond end of data");
throw std::runtime_error("GSL entry extends beyond end of data");
}
this->entries.emplace(entry.filename.decode(), Entry{offset, entry.size});
}
}
GSLArchive::GSLArchive(shared_ptr<const string> data, bool big_endian) : data(data) {
GSLArchive::GSLArchive(std::shared_ptr<const std::string> data, bool big_endian) : data(data) {
if (big_endian) {
this->load_t<true>();
} else {
@@ -44,43 +42,43 @@ GSLArchive::GSLArchive(shared_ptr<const string> data, bool big_endian) : data(da
}
}
const unordered_map<string, GSLArchive::Entry> GSLArchive::all_entries() const {
const std::unordered_map<std::string, GSLArchive::Entry> GSLArchive::all_entries() const {
return this->entries;
}
pair<const void*, size_t> GSLArchive::get(const std::string& name) const {
std::pair<const void*, size_t> GSLArchive::get(const std::string& name) const {
try {
const auto& entry = this->entries.at(name);
return make_pair(this->data->data() + entry.offset, entry.size);
} catch (const out_of_range&) {
throw out_of_range("GSL does not contain file: " + name);
return std::make_pair(this->data->data() + entry.offset, entry.size);
} catch (const std::out_of_range&) {
throw std::out_of_range("GSL does not contain file: " + name);
}
}
string GSLArchive::get_copy(const string& name) const {
std::string GSLArchive::get_copy(const std::string& name) const {
try {
const auto& entry = this->entries.at(name);
return this->data->substr(entry.offset, entry.size);
} catch (const out_of_range&) {
throw out_of_range("GSL does not contain file: " + name);
} catch (const std::out_of_range&) {
throw std::out_of_range("GSL does not contain file: " + name);
}
}
phosg::StringReader GSLArchive::get_reader(const string& name) const {
phosg::StringReader GSLArchive::get_reader(const std::string& name) const {
try {
const auto& entry = this->entries.at(name);
return phosg::StringReader(this->data->data() + entry.offset, entry.size);
} catch (const out_of_range&) {
throw out_of_range("GSL does not contain file: " + name);
} catch (const std::out_of_range&) {
throw std::out_of_range("GSL does not contain file: " + name);
}
}
string GSLArchive::generate(const unordered_map<string, string>& files, bool big_endian) {
std::string GSLArchive::generate(const std::unordered_map<std::string, std::string>& files, bool big_endian) {
return big_endian ? GSLArchive::generate_t<true>(files) : GSLArchive::generate_t<false>(files);
}
template <bool BE>
string GSLArchive::generate_t(const unordered_map<string, string>& files) {
std::string GSLArchive::generate_t(const std::unordered_map<std::string, std::string>& files) {
phosg::StringWriter w;
// Make sure there's enough space for a blank header entry before any file's data pages begin