Repository navigation
[refactor] Replace std::stof with parse_float - #368
Conversation
Replace the throwing std::stof calls with the non-throwing
rta::helpers::parse_float helper (based on std::from_chars) across
spectral_data.cpp, exiftool.cpp, and the UsageTimer test. The helper
lives in src/cpp/misc/helpers.{h,cpp} and is wired into the relevant
CMakeLists.txt files. A non-numeric input now returns false instead of
throwing, letting callers handle malformed input gracefully.
Assisted-by: nemotron-3.5-super-vl-free
Signed-off-by: Anton Dukhovnikov <antond@wetafx.co.nz>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #368 +/- ##
==========================================
- Coverage 92.04% 91.96% -0.08%
==========================================
Files 17 18 +1
Lines 3959 3970 +11
Branches 591 597 +6
==========================================
+ Hits 3644 3651 +7
- Misses 315 319 +4
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
| { | ||
| *error_message = "Error: Failed to parse wavelength '" + | ||
| bin_wavelength + "' in " + path + "."; | ||
| } |
There was a problem hiding this comment.
you reckon this error handling and error adding can be integrated into helper ... I guess not, you'd need to pass error message in as a ref. and all that. ignore me.
There was a problem hiding this comment.
/nit I feel like now when we have opened that flood gate of "util" or "helper" place we can drop here bunch stuff from other places.
There was a problem hiding this comment.
Which is a good thing, right?
rawtoaces_util is a public target containing image conversion functionality (poorly named in my opinion). The whole reason for adding helpers was that it's not util.
There was a problem hiding this comment.
Which is a good thing, right?
yeah. I meant it as a good think. Though,utilandhelperare all similar in my mind. Anyway, good. Let's move some more here.
Add a test_parse_float unit test to Test_Misc covering valid decimal,
integer, negative, and prefix-parsing inputs, plus non-numeric inputs
that must return false without throwing. Wire src/cpp/misc/helpers.{h,cpp}
into the Test_Misc target so rta::helpers::parse_float is available.
Assisted-by: nemotron-3.5-super-vl-free
Signed-off-by: Anton Dukhovnikov <antond@wetafx.co.nz>
Replace the throwing std::stof calls with the non-throwing rta::helpers::parse_float helper (based on std::from_chars) across spectral_data.cpp, exiftool.cpp, and the UsageTimer test. The helper lives in src/cpp/misc/helpers.{h,cpp} and is wired into the relevant CMakeLists.txt files. A non-numeric input now returns false instead of throwing, letting callers handle malformed input gracefully.
Assisted-by: nemotron-3.5-super-vl-free
Description
Tests
Checklist:
and if I used AI coding assistants, I have an
Assisted-by: TOOL / MODELline in the pull request description above.
need to update the documentation, for example if this is a bug fix that
doesn't change the API.)
(adding new test cases if necessary).
already run clang-format before submitting, I definitely will look at the CI
test that runs clang-format and fix anything that it highlights as being
nonconforming.