-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathactionSaver.cpp
58 lines (45 loc) · 1 KB
/
actionSaver.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "actionSaver.h"
#include <QFile>
#include <QTextStream>
ActionSaver::ActionSaver(const int &freq, const int &numOfDOF, const QString &fileName)
{
mFile.setFileName(fileName);
mFile.open(QFile::WriteOnly | QFile::Truncate);
mStream.setDevice(&mFile);
writePropertiesData(freq, numOfDOF);
}
ActionSaver::~ActionSaver()
{
mFile.close();
}
void ActionSaver::writeData(const QList<int> &data)
{
const int size = data.size();
for (int i = 0; i < size; i++) {
mStream << data.at(i);
if (i != (size - 1)) {
mStream << " ";
}
}
mStream << "\n";
}
void ActionSaver::stopRecord()
{
mStream << ActionFileStructure::endActionKeyWord();
mFile.close();
}
void ActionSaver::writePropertiesData(const int &freq, const int &numOfDOF)
{
mStream << ActionFileStructure::header()
<< "\n"
<< ActionFileStructure::freqKeyWord()
<< " "
<< freq
<< "\n"
<< ActionFileStructure::DOFKeyWord()
<< " "
<< numOfDOF
<< "\n"
<< ActionFileStructure::startActionKeyWord()
<< "\n";
}