MCPcopy Create free account
hub / github.com/Duet3D/RepRapFirmware / ParseNumber

Method ParseNumber

src/GCodes/GCodeBuffer/ExpressionParser.cpp:1369–1386  ·  view source on GitHub ↗

Parse a number. The initial character of the string is a decimal digit.

Source from the content-addressed store, hash-verified

1367
1368// Parse a number. The initial character of the string is a decimal digit.
1369void ExpressionParser::ParseNumber(ExpressionValue& rslt) noexcept
1370{
1371 NumericConverter conv;
1372 conv.Accumulate(CurrentCharacter(), NumericConverter::AcceptSignedFloat | NumericConverter::AcceptHex, [this]()->char { AdvancePointer(); return CurrentCharacter(); }); // must succeed because CurrentCharacter is a decimal digit
1373
1374 if (conv.FitsInInt32())
1375 {
1376 rslt.SetInt(conv.GetInt32());
1377 }
1378 else if (conv.FitsInUint32())
1379 {
1380 rslt.SetUnsigned(conv.GetUint32());
1381 }
1382 else
1383 {
1384 rslt.SetFloat(conv.GetFloat(), constrain<unsigned int>(conv.GetDigitsAfterPoint(), 1, MaxFloatDigitsDisplayedAfterPoint));
1385 }
1386}
1387
1388static void SetStrStrResult(ExpressionValue& e, const char *_ecv_array s1, const char *_ecv_array s2) noexcept
1389{

Callers

nothing calls this directly

Calls 3

SetIntMethod · 0.80
SetUnsignedMethod · 0.80
SetFloatMethod · 0.45

Tested by

no test coverage detected