Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<typename T> PDB<T>::PDB(std::string filename) {
- std::ifstream is(filename, std::ios::binary);
- //I prefer !good instead of bad because
- //I try to stay positive
- if (!is.good()) { throw std::exception(); }
- uint32_t size;
- is >> size;
- //saw this one on SO
- std::vector<uint8_t> bytes(
- (std::istreambuf_iterator<char>(is)),
- (std::istreambuf_iterator<char>()));
- if (!is.good()) { throw std::exception(); }
- is.close();
- data = bytes;
- }
- template<typename T> PDB<T>::serialize(std::string filename) {
- std::ofstream os(filename, std::ios::binary);
- if (!is.good()) { throw std::exception(); }
- std::copy(data.begin(), data.end(), std::ostreambuf_iterator<uint8_t>(os));
- if (!os.good()) { throw std::exception(); }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement