25#include "bitpit_common.hpp"
27#include "binary_archive.hpp"
41const std::string BinaryArchive::EXTENSION_DEFAULT =
"dat";
80 : m_version(VERSION_UNDEFINED)
103 ios_base::openmode mode,
int block)
110 std::fstream::open(m_path.c_str(), std::ios::binary | mode);
112 throw std::runtime_error(
"Unable to open the binary archive \"" +
getPath() +
"\".");
162IBinaryArchive::IBinaryArchive(
const std::string &name,
int block)
164 open(name, EXTENSION_DEFAULT, block);
175IBinaryArchive::IBinaryArchive(
const std::string &name,
const std::string &extension,
int block)
177 open(name, extension, block);
190 open(name, EXTENSION_DEFAULT, block);
211 std::vector<char> rawHeader(HEADER_SIZE);
213 m_header = std::string(rawHeader.begin(), rawHeader.end());
238 return (version == m_version);
258OBinaryArchive::OBinaryArchive(
const std::string &name,
int version,
int block)
260 open(name, EXTENSION_DEFAULT, version,
"", block);
273OBinaryArchive::OBinaryArchive(
const std::string &name,
int version,
274 const std::string &header,
int block)
276 open(name, EXTENSION_DEFAULT, version, header, block);
288OBinaryArchive::OBinaryArchive(
const std::string &name,
const std::string &extension,
289 int version,
int block)
291 open(name, extension, version,
"", block);
306OBinaryArchive::OBinaryArchive(
const std::string &name,
const std::string &extension,
307 int version,
const std::string &header,
int block)
309 open(name, extension, version, header, block);
323 open(name, EXTENSION_DEFAULT, version,
"", block);
338 const std::string &header,
int block)
340 open(name, EXTENSION_DEFAULT, version, header, block);
354 int version,
int block)
356 open(name, extension, version,
"", block);
372 int version,
const std::string &header,
int block)
382 std::string archiveHeader(header);
383 archiveHeader.resize(HEADER_SIZE,
' ');
std::string getHeader() const
static std::string generatePath(const std::string &name, int block=-1)
void open(const std::string &name, const std::string &extension, ios_base::openmode mode, int block=-1)
std::string getPath() const
Creates file names and checks status.
std::string getPath() const
void setParallel(bool p_)
bool checkVersion(int version)
void open(const std::string &name, int block=-1)
std::istream & getStream()
void open(const std::string &name, const int version, int block=-1)
std::ostream & getStream()
void write(std::ostream &stream, const std::vector< bool > &container)
void read(std::istream &stream, std::vector< bool > &container)