Header only File Lib
This commit is contained in:
1 parent
9deae93fdd
commit
46214e9dc3
20 files changed
+396
-590
No files matched your search
@@ -0,0 +1,56 @@
|
||||
#ifndef GERMANAIRLINESVA_FILE_RECORDING_RECORDING_H
|
||||
#define GERMANAIRLINESVA_FILE_RECORDING_RECORDING_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
#include "constants.h"
|
||||
#include "recordingEntry.hpp"
|
||||
|
||||
namespace germanairlinesva
|
||||
{
|
||||
namespace file
|
||||
{
|
||||
namespace recording
|
||||
{
|
||||
/*
|
||||
* Path Recording (6 + n * 24)
|
||||
* HEADER | SEGMENTS
|
||||
|
||||
* Header (6)
|
||||
* CHAR[5] | UINT8
|
||||
* --------+--------
|
||||
* VGAR | VERSION
|
||||
|
||||
* Path Segments (n)
|
||||
* PATHSEGMENT[]
|
||||
*/
|
||||
class Recording
|
||||
{
|
||||
private:
|
||||
std::vector<RecordingEntry> entries;
|
||||
|
||||
public:
|
||||
template <class... Args> inline void addEntry(Args &&...args)
|
||||
{
|
||||
this->entries.emplace_back(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
inline void toFile(std::string fileName) const
|
||||
{
|
||||
std::ofstream out(BASE_DIRECTORY RECORDING_DIRECTORY + fileName,
|
||||
std::fstream::binary);
|
||||
char header[] = {'V', 'G', 'A', 'R', '\0', 1};
|
||||
out.write(header, 6);
|
||||
for (const RecordingEntry &entry : this->entries) {
|
||||
entry.toFile(out);
|
||||
}
|
||||
out.close();
|
||||
}
|
||||
};
|
||||
} // namespace recording
|
||||
} // namespace file
|
||||
} // namespace germanairlinesva
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user