44 template<
typename T1,
typename T2>
inline
45 void read_endian(T1& st, T2& data,
bool switch_endian =
false)
47 int bytes =
sizeof(T2);
48 char *c =
reinterpret_cast<char *
>(&data);
52 for (
int i = bytes - 1; i >= 0; i--)
57 template<
typename T1,
typename T2>
inline
60 int bytes =
sizeof(T2);
61 char *c =
reinterpret_cast<char *
>(&data);
65 for (
int i = bytes - 1; i >= 0; i--)
71 bool exist(
const std::string& name)
73 bool file_exists =
false;
74 ifstream file(name.c_str(), ios::in);
87 switch_endianity(false),
99 bfstream_base(e), ofstream(name.c_str(), ios::out | ios::binary) {}
120 put(static_cast<char>(a));
174 write(a, strlen(a) + 1);
180 write(a.c_str(), a.size() + 1);
189 bfstream_base(e), ifstream(name.c_str(), ios::in | ios::binary) {}
204 std::streampos pos1, len;
282 std::getline(*
this, a,
'\0');
291 bfstream_base(e), fstream(name.c_str(), ios::in | ios::out | ios::binary)
307 fstream::open(name.c_str(), ios::in | ios::out | ios::binary);
321 std::streampos pos1, len;
337 put(static_cast<char>(a));
391 write(a, strlen(a) + 1);
397 write(a.c_str(), a.size() + 1);
472 std::getline(*
this, a,
'\0');