Skip to content

Commit db184fe

Browse files
committed
create a float Pattern and reuse it
1 parent 1e4aa91 commit db184fe

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/dbc.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,21 @@
66

77
namespace {
88

9+
const auto floatPattern = "(-?\\d+\\.?(\\d+)?)"; // Can be negative
10+
911
const auto signalIdentifierPattern = "(SG_)";
1012
const auto namePattern = "(\\w+)";
1113
const auto bitStartPattern = "(\\d+)"; // Cannot be negative
1214
const auto lengthPattern = "(\\d+)"; // Cannot be negative
1315
const auto byteOrderPattern = "([0-1])";
1416
const auto signPattern = "(\\+|\\-)";
15-
const auto scalePattern = "(\\d+\\.?(\\d+)?)";
16-
const auto offsetPattern = "(-?\\d+\\.?(\\d+)?)"; // Can be negative
17+
const auto scalePattern = "(\\d+\\.?(\\d+)?)"; // Non negative float
18+
const auto offsetPattern = floatPattern;
1719
const auto offsetScalePattern = std::string("\\(") + scalePattern + "\\," + offsetPattern + "\\)";
18-
const auto minPattern = "(-?\\d+\\.?(\\d+)?)";
19-
const auto maxPattern = "(-?\\d+\\.?(\\d+)?)";
20+
const auto minPattern = floatPattern;
21+
const auto maxPattern = floatPattern;
2022
const auto minMaxPattern = std::string("\\[") + minPattern + "\\|" + maxPattern + "\\]";
21-
const auto unitPattern = "\"(\\w*)\"";
23+
const auto unitPattern = "\"(\\w*)\""; // Random string
2224
const auto receiverPattern = "([\\w\\,]+|Vector__XXX)*";
2325
const auto whiteSpace = "\\s";
2426

0 commit comments

Comments
 (0)