mirror of https://github.com/PCSX2/pcsx2.git
... do the same thing for File_Reader.h as I did for Database_Loader.h in r3101 (translation: added semi-important C++ redtape syntax).
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3104 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
81c35c9fcc
commit
15ac11b82e
|
@ -74,7 +74,7 @@ public:
|
||||||
|
|
||||||
class DataBase_Loader {
|
class DataBase_Loader {
|
||||||
private:
|
private:
|
||||||
template<class T> string toString(T value) {
|
template<class T> string toString(const T& value) {
|
||||||
stringstream ss(ios_base::in | ios_base::out);
|
stringstream ss(ios_base::in | ios_base::out);
|
||||||
string tString;
|
string tString;
|
||||||
ss << value;
|
ss << value;
|
||||||
|
|
|
@ -28,16 +28,16 @@ private:
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
fstream* fs;
|
fstream* fs;
|
||||||
File_Reader(string filename) {
|
File_Reader(const string& filename) {
|
||||||
fs = new fstream(filename.c_str(), ios_base::in);
|
fs = new fstream(filename.c_str(), ios_base::in);
|
||||||
}
|
}
|
||||||
~File_Reader() {
|
virtual ~File_Reader() throw() {
|
||||||
if (fs) fs->close();
|
if (fs) fs->close();
|
||||||
delete fs;
|
delete fs;
|
||||||
}
|
}
|
||||||
template<class T> void read(T &t) {
|
template<class T> void read(T &t) {
|
||||||
long pos = fs->tellp();
|
long pos = fs->tellp();
|
||||||
string s = _read<string>();
|
string s( _read<string>() );
|
||||||
if (s.length() >= 2) {
|
if (s.length() >= 2) {
|
||||||
if (s[0] == '/' && s[1] == '/') {
|
if (s[0] == '/' && s[1] == '/') {
|
||||||
fs->seekp(pos);
|
fs->seekp(pos);
|
||||||
|
@ -80,19 +80,17 @@ public:
|
||||||
|
|
||||||
class File_Writer {
|
class File_Writer {
|
||||||
public:
|
public:
|
||||||
fstream* fs;
|
ScopedPtr<fstream> fs;
|
||||||
File_Writer(string filename) {
|
File_Writer(const string& filename) {
|
||||||
fs = new fstream(filename.c_str(), ios_base::out);
|
fs = new fstream(filename.c_str(), ios_base::out);
|
||||||
}
|
}
|
||||||
~File_Writer() {
|
virtual ~File_Writer() throw() { }
|
||||||
if (fs) fs->close();
|
|
||||||
delete fs;
|
template<class T> void write(const T& t) {
|
||||||
}
|
|
||||||
template<class T> void write(T t) {
|
|
||||||
(*fs) << t;
|
(*fs) << t;
|
||||||
}
|
}
|
||||||
void writeRaw(void* ptr, int size) {
|
void writeRaw(const void* ptr, int size) {
|
||||||
u8* p = (u8*)ptr;
|
const u8* p = (u8*)ptr;
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
write(p[i]);
|
write(p[i]);
|
||||||
}
|
}
|
||||||
|
@ -107,16 +105,16 @@ public:
|
||||||
String_Stream() {
|
String_Stream() {
|
||||||
ss = new stringstream(stringstream::in | stringstream::out);
|
ss = new stringstream(stringstream::in | stringstream::out);
|
||||||
}
|
}
|
||||||
String_Stream(string& str) {
|
String_Stream(const string& str) {
|
||||||
ss = new stringstream(str, stringstream::in | stringstream::out);
|
ss = new stringstream(str, stringstream::in | stringstream::out);
|
||||||
}
|
}
|
||||||
~String_Stream() {
|
virtual ~String_Stream() throw() {
|
||||||
delete ss;
|
delete ss;
|
||||||
}
|
}
|
||||||
template<class T> void write(T t) {
|
template<class T> void write(const T& t) {
|
||||||
(*ss) << t;
|
(*ss) << t;
|
||||||
}
|
}
|
||||||
template<class T> void read(T &t) {
|
template<class T> void read(T& t) {
|
||||||
(*ss) >> t;
|
(*ss) >> t;
|
||||||
}
|
}
|
||||||
string toString() {
|
string toString() {
|
||||||
|
@ -124,7 +122,7 @@ public:
|
||||||
}
|
}
|
||||||
string getLine() {
|
string getLine() {
|
||||||
ss->getline(buff, sizeof(buff));
|
ss->getline(buff, sizeof(buff));
|
||||||
return string(buff);
|
return buff;
|
||||||
}
|
}
|
||||||
wxString getLineWX() {
|
wxString getLineWX() {
|
||||||
ss->getline(buff, sizeof(buff));
|
ss->getline(buff, sizeof(buff));
|
||||||
|
@ -135,7 +133,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool fileExists(string file) {
|
static bool fileExists(const string& file) {
|
||||||
FILE *f = fopen(file.c_str(), "r");
|
FILE *f = fopen(file.c_str(), "r");
|
||||||
if (!f) return false;
|
if (!f) return false;
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
Loading…
Reference in New Issue