mirror of
https://github.com/trabucayre/openFPGALoader.git
synced 2026-08-31 10:16:11 +02:00
add configBitstreamParser an base class for all bitstream file parser
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#include <iostream>
|
||||
#include <stdint.h>
|
||||
#include <strings.h>
|
||||
|
||||
#include "configBitstreamParser.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
ConfigBitstreamParser::ConfigBitstreamParser(string filename, int mode):
|
||||
_filename(filename), _bit_length(0),
|
||||
_file_size(0), _fd(filename,
|
||||
ifstream::in | (ios_base::openmode)mode), _bit_data()
|
||||
{
|
||||
if (!_fd.is_open()) {
|
||||
cerr << "Error: fail to open " << _filename << endl;
|
||||
throw std::exception();
|
||||
}
|
||||
_fd.seekg(0, _fd.end);
|
||||
_file_size = _fd.tellg();
|
||||
_fd.seekg(0, _fd.beg);
|
||||
|
||||
_bit_data.reserve(_file_size);
|
||||
}
|
||||
|
||||
ConfigBitstreamParser::~ConfigBitstreamParser()
|
||||
{
|
||||
_fd.close();
|
||||
}
|
||||
Reference in New Issue
Block a user