eliminate using namespace
This commit is contained in:
+10
-13
@@ -9,10 +9,7 @@
|
||||
|
||||
#include "Text.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
AFSArchive::AFSArchive(shared_ptr<const string> data)
|
||||
: data(data) {
|
||||
AFSArchive::AFSArchive(std::shared_ptr<const std::string> data) : data(data) {
|
||||
struct FileHeader {
|
||||
be_uint32_t magic;
|
||||
le_uint32_t num_files;
|
||||
@@ -26,7 +23,7 @@ AFSArchive::AFSArchive(shared_ptr<const string> data)
|
||||
phosg::StringReader r(*this->data);
|
||||
const auto& header = r.get<FileHeader>();
|
||||
if (header.magic != 0x41465300) { // 'AFS\0'
|
||||
throw runtime_error("file is not an AFS archive");
|
||||
throw std::runtime_error("file is not an AFS archive");
|
||||
}
|
||||
|
||||
while (this->entries.size() < header.num_files) {
|
||||
@@ -35,21 +32,21 @@ AFSArchive::AFSArchive(shared_ptr<const string> data)
|
||||
}
|
||||
}
|
||||
|
||||
pair<const void*, size_t> AFSArchive::get(size_t index) const {
|
||||
std::pair<const void*, size_t> AFSArchive::get(size_t index) const {
|
||||
const auto& entry = this->entries.at(index);
|
||||
if (entry.offset > this->data->size()) {
|
||||
throw out_of_range("entry begins beyond end of archive");
|
||||
throw std::out_of_range("entry begins beyond end of archive");
|
||||
}
|
||||
if (entry.offset + entry.size > this->data->size()) {
|
||||
throw out_of_range("entry extends beyond end of archive");
|
||||
throw std::out_of_range("entry extends beyond end of archive");
|
||||
}
|
||||
|
||||
return make_pair(this->data->data() + entry.offset, entry.size);
|
||||
return std::make_pair(this->data->data() + entry.offset, entry.size);
|
||||
}
|
||||
|
||||
string AFSArchive::get_copy(size_t index) const {
|
||||
std::string AFSArchive::get_copy(size_t index) const {
|
||||
auto ret = this->get(index);
|
||||
return string(reinterpret_cast<const char*>(ret.first), ret.second);
|
||||
return std::string(reinterpret_cast<const char*>(ret.first), ret.second);
|
||||
}
|
||||
|
||||
phosg::StringReader AFSArchive::get_reader(size_t index) const {
|
||||
@@ -57,12 +54,12 @@ phosg::StringReader AFSArchive::get_reader(size_t index) const {
|
||||
return phosg::StringReader(ret.first, ret.second);
|
||||
}
|
||||
|
||||
string AFSArchive::generate(const vector<string>& files, bool big_endian) {
|
||||
std::string AFSArchive::generate(const std::vector<std::string>& files, bool big_endian) {
|
||||
return big_endian ? AFSArchive::generate_t<true>(files) : AFSArchive::generate_t<false>(files);
|
||||
}
|
||||
|
||||
template <bool BE>
|
||||
string AFSArchive::generate_t(const vector<string>& files) {
|
||||
std::string AFSArchive::generate_t(const std::vector<std::string>& files) {
|
||||
phosg::StringWriter w;
|
||||
w.put_u32b(0x41465300); // 'AFS\0'
|
||||
w.put<U32T<BE>>(files.size());
|
||||
|
||||
Reference in New Issue
Block a user