MCPcopy Create free account
hub / github.com/aethersdr/AetherSDR / extractField

Function extractField

src/core/AdifParser.cpp:17–30  ·  view source on GitHub ↗

Extract the value of a named ADIF field from a block of text. ADIF field format: value (case insensitive)

Source from the content-addressed store, hash-verified

15// Extract the value of a named ADIF field from a block of text.
16// ADIF field format: <FIELDNAME:length>value (case insensitive)
17static QString extractField(const QString& block, const QString& fieldName)
18{
19 // e.g. <CALL:6>G3ABC or <CALL:6:S>G3ABC
20 // NOTE: do NOT make this regex static — the pattern depends on fieldName.
21 const QRegularExpression re(
22 R"(<)" + QRegularExpression::escape(fieldName) + R"((?::\d+(?::[A-Z])?)?:(\d+)>)",
23 QRegularExpression::CaseInsensitiveOption);
24 auto m = re.match(block);
25 if (!m.hasMatch()) return {};
26 int len = m.captured(1).toInt();
27 int start = m.capturedEnd(0);
28 if (start + len > block.length()) return {};
29 return block.mid(start, len);
30}
31
32QString AdifParser::normaliseMode(const QString& mode, const QString& submode)
33{

Callers 1

parseMethod · 0.85

Calls 2

escapeFunction · 0.85
capturedMethod · 0.80

Tested by

no test coverage detected