/file_serializor.cpp Secret
Created
January 16, 2014 22:08
file serializor implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "file_serializor.h" | |
namespace io { | |
file_serializor::file_serializor(): | |
output_stream(new std::ofstream) {} | |
void file_serializor::do_write_object(const std::string &obj) { | |
(*output_stream) << obj; | |
} | |
void file_serializor::do_open(std::string name) { | |
output_stream->exceptions( std::ifstream::failbit | std::ifstream::badbit); | |
if (name == "") | |
throw std::runtime_error(doh::FAIL + doh::BAD_NAME); | |
try { | |
output_stream->open(name); | |
} | |
catch (std::ofstream::failure& e) { | |
throw std::runtime_error(doh::FAIL + doh::NO_RESOURCE); | |
} | |
} | |
void file_serializor::do_close() { | |
output_stream->close(); | |
} | |
file_serializor::~file_serializor() { | |
if (output_stream) | |
delete output_stream; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment