Slight refactor of DAN parse code

Mostly NFC; this commit is mainly to get familiar with the codebase and to meet
the people who will review these changes.

I hope to make some changes to the DAN parsing code to eventually extract more
metainfo from my aqualung divecomputer's `.zxu` formatted logs. To do so, and
for me to be able to work on this efficiently, I've refactored the DAN parsing
code using a bit more modern C++-style, as well as being more true-to-spec wrt.
the (...ancient) DAN file format documentation that i could dig up... hopefully
that's an alright tradeoff for the project.

This more true-to-spec parsing also fixed a bug with the number being parsed
from the incorrect index in the ZDH vector (or, atleast i consider it a bug -
the "Export sequence" number was being used as the dive number, instead of the
"Internal Dive Sequence" number. The latter, described in the spec as: `The
sequence number assigned to the dive by the recording computer`).

Also contains some unrelated formatting changes; i tried to keep these minimal
(i presume these files haven't been touched in a while by `clang-format`).

Signed-off-by: Morten Borup Petersen <morten_bp@live.dk>
This commit is contained in:
Morten Borup Petersen 2024-11-02 18:23:59 +01:00 committed by Michael Keller
parent e2b0851ddc
commit d59eb9bdfa
5 changed files with 238 additions and 137 deletions

View file

@ -5,12 +5,12 @@
#include "core/divelog.h"
#include "core/divesite.h"
#include "core/errorhelper.h"
#include "core/trip.h"
#include "core/file.h"
#include "core/import-csv.h"
#include "core/parse.h"
#include "core/qthelper.h"
#include "core/subsurface-string.h"
#include "core/trip.h"
#include "core/xmlparams.h"
#include <QTextStream>
@ -224,7 +224,8 @@ void TestParse::testParseNewFormat()
"/dives/")
.append(files.at(i))
.toLatin1()
.data(), &divelog),
.data(),
&divelog),
0);
QCOMPARE(divelog.dives.size(), i + 1);
}
@ -452,7 +453,11 @@ void TestParse::parseDL7()
QCOMPARE(parse_csv_file(SUBSURFACE_TEST_DATA "/dives/DL7.zxu",
&params, "DL7", &divelog),
0);
QCOMPARE(divelog.dives.size(), 3);
QCOMPARE(divelog.dives[0]->number, 1);
QCOMPARE(divelog.dives[1]->number, 2);
QCOMPARE(divelog.dives[2]->number, 3);
QCOMPARE(save_dives("./testdl7out.ssrf"), 0);
FILE_COMPARE("./testdl7out.ssrf",