Repository navigation
replace String with std::string - #9450
Conversation
c0b09c9 to
ea8be8c
Compare
|
Expression (s is std::string) |
With StringUtils.h |
Without it | Verdict |
|---|---|---|---|
s = 65; (lvalue = int) |
"A" (len 1) |
"A" |
Silent corruption — UNFIXABLE (member operator=(char)) |
s += 65; (lvalue += int) |
"65" |
"A" |
Header-dependent: text vs char-append |
tmp += 65; (rvalue/temp on left) |
"A" |
"A" |
Silent — temp can't bind std::string&, falls to member +=(char) |
s + 65 |
"65" |
compile error | Safe (fails loud without header) |
65 + s |
compile error | compile error | Safe |
"x=" + 65 (const char* literal left) |
pointer arithmetic → UB | same | Silent corruption — NOT concat |
s = flag; / s += flag; (bool) |
0x01 / "1" |
0x01 / 0x01 |
Silent (see -Wconversion caveat below) |
s + 'A', s += 'A' (char literal) |
char-append | char-append | Always safe (intentional) |
unsigned int n = 1000; std::string s;
// s = n; // WRONG: one byte (0xE8), compiles silently
s = StringUtils::toStr(n); // RIGHT: "1000"
// return StringUtils::toStr(sign) += std::fabs(mass); // WRONG: temp += double → 1 char
return StringUtils::toStr(sign) + StringUtils::toStr(std::fabs(mass)); // RIGHT
// std::string r = "mz=" + n; // WRONG: const char* + int = pointer arithmetic (UB)
std::string r = "mz=" + StringUtils::toStr(n); // RIGHTReal shipped bugs this class produced (all fixed on the branch): SiriusMSConverter (cmpinfo.fid = feature_id, uint64→char), QcMLFile / ExperimentalDesign (qp.value, sample_name), SqliteConnector charge truncation.
Exceptions (the strict-cast trap)
The lenient String(const DataValue&) constructor was removed. The natural-looking line now binds to DataValue::operator std::string(), which throws Exception::ConversionError for any non-string value (Int, Double, list, Empty). ParamValue has the same strict cast. StringUtils::toStr(dv) instead calls DataValue::toString() — the old lenient behavior: stringifies numbers/lists, "" for Empty, no-op for genuine strings.
DataValue dv(42);
// std::string s = dv; // WRONG: compiles, THROWS at runtime
// std::string s = (std::string)dv; // WRONG: explicit cast is just as strict
// std::string s = mi.getMetaValue("k"); // WRONG
std::string s = StringUtils::toStr(dv); // RIGHT → "42", lenient
std::string s = StringUtils::toStr(mi.getMetaValue("k")); // RIGHTCaveat: the 2-arg getMetaValue("k", "") default only guards the missing-key case — a present-but-numeric value still throws when cast, so still wrap in toStr. A bare cast is only safe right after checking valueType() == DataValue::STRING_VALUE. About a dozen bare getMetaValue casts were left unwrapped by convention (keys "always" written as strings) — treat them as latent footguns and wrap when you touch them.
Other footguns
- Dangling
string_view:StringUtils::substr(view, …)andStringView::getString()return an owning temporary. Binding it to astd::string_viewis use-after-free — masked by SSO, so short tokens pass by luck. Use the view's own member.substrfor a zero-copy subview, or assign into an owningstd::string.// std::string_view t = StringUtils::substr(sv, i, n); // WRONG: dangles std::string_view t = sv.substr(i, n); // RIGHT: zero-copy (sv's member)
- In-place vs copy: the
StringUtilsfree functionstrim/toUpper/toLowermutate theirstd::string&argument in place; onlytrimmed/toUppered/toLowered/substitutedreturn a copy. SoStringUtils::trimmed(s);on its own is a no-op (the copy is discarded).remove/reverse/simplify/etc. are in-place only — copy first if you need the original. - Beginner friction:
StringUtils::must be qualified —using namespace OpenMS;does not expose it (the globaloperator+/+=are the exception, but still need the header in scope).- No bare
toInt→StringUtils::toInt32(throws on junk, like the old strict path). String::npos→std::string::npos;String::EMPTY→""/s.empty().ListUtils::concatenate(v, ',')→concatenate(v, ",")(the glue isconst std::string&; acharno longer constructs a string, so char glue won't compile).TEST_EQUAL/TEST_STRING_EQUALwith a numeric operand: wrap it inStringUtils::toStr(...), and thestd::stringmust be the first argument — the macro only stringifies the second operand when the first is astd::string.- Use
StringUtils::toStr(double)— notstd::to_string(6 fixed digits, no scientific notation, lowercasenan) — or you break file output and FuzzyDiff.toStrgives full precision, scientific for large/small,NaN.
How this is guarded
- A
-Wconversion"narrowing to'char'" sweep over every TU (compile_commands.json) catches narrowing from wider-integer variables/expressions — i.e. the real shipped bugs likeuint64 feature_id → char. But it is silent on small literal constants that fitchar(s = 65gets no warning) and blind tobool → char(a promotion, not a narrowing). Audit literal andboolassignments by hand. - Full
ctestis the only reliable arbiter — it's the same gap from the other side. An isolated_outtest does not run its generator, so FuzzyDiff compares against a stale.tmp→ false PASS or false FAIL. Never patch a reference file from an isolated_outresult; scope withrm -f OpenMS-build/tmp_path/<tool>_*.tmp.* && ctest -R "TOPP_<tool>_".
The inline StringUtils::toStr / strict-cast contract is also documented in code at DataValue::operator std::string() and StringUtils::toStr(const DataValue&).
Merged Recommendation: Fixing the
|
| Should have been in the original design | Cheapest high-value fix to apply NOW |
|---|---|
explicit on DataValue::operator std::string() (and list types) — C.164 |
Stock clang-tidy bugprone-string-integer-assignment gate (the s=num hole) |
[[nodiscard]] on every copy-returning helper — F.20 |
Add the missing rvalue operator+=(std::string&&, T) |
subview() returning a view; substr() clearly owning — F.42 |
[[nodiscard]] sweep (header-only, near-zero risk) |
Value-by-default naming (trim=copy, trimInPlace=mutate) |
explicit cast + sweep the 82 copy-init-from-getMetaValue sites to toStr |
The right column ships in days and is ABI-neutral. The left column is the principled end-state; some of it (the rename) is deliberately deferred as too expensive for its value.
3. Per-pain-point recommendation
#1 — s = num / s += num truncates to char
Diagnosis (verified): std::string c = 300; is already a hard compile error — there is no string(int) ctor. So #1 is purely an assignment/append problem via member operator=(char) / operator+=(char), not construction. I confirmed empirically:
-Wconversioncatchess = fid(uint64→char — the real SiriusMSConverter bug).-Wconversionis silent ons = 65(in-char-range literal) ands += b(bool→char).
Fix (merge of P3 mechanism, P2 tool, P1 rvalue gap):
-
Stock clang-tidy
bugprone-string-integer-assignmentas the gate. This check is purpose-built for exactlystd::basic_string::operator=/operator+=with a non-character integer RHS, and it does not exempt in-range literals orbool— so it covers precisely the-Wconversionblind spot (s=65,s+=b) and the un-overloadableoperator=that no type-system trick can reach.I flag Proposal 3's custom
openms-string-narrowingLLVM plugin as over-engineered. P3 builds a version-sensitive, perpetually-maintained Clang plugin on the premise that no stock check covers in-range-literal and bool→char string assignment. The stockbugprone-string-integer-assignmentcovers exactly those. (I could not run clang-tidy locally — it is not installed — so confirm in the CI lane; but this is the documented behavior of the upstream check, and it is one.clang-tidyline vs. a C++ plugin maintained against every LLVM bump. Lean stock.) -
Add the rvalue
operator+=(closes P1's confirmed temporary hole):inline std::string operator+=(std::string&& s, int i) { OpenMS::StringUtils::appendToStr(i, s); return std::move(s); } inline std::string operator+=(std::string&& s, double d) { OpenMS::StringUtils::appendToStr(d, s); return std::move(s); } // ... full numeric family, mirroring the existing lvalue set at StringUtils.h:996-1017
-
.clang-tidy(none exists today; verified):Checks: '-*,bugprone-string-integer-assignment,bugprone-dangling-handle' WarningsAsErrors: '' # phase in as warn first — the migration shipped violations CheckOptions: - { key: bugprone-dangling-handle.HandleClasses, value: 'std::basic_string_view' }
Run diff-only (
clang-tidy-diff.pyagainst PR base) as a new-code gate so existing violations don't block unrelated PRs and CI stays bounded. Backing: ES.46 (avoid lossy conversions) enforced mechanically, since the language cannot enforce it on a type you don't own.
#2 — global operator+/+= is an ADL/ODR smell
Severity, stated honestly (P1 is right, P2 overstates): this is legal — UB attaches only to extending namespace std, and these are in the global namespace. The real cost is ADL/ODR-hostility: any TU including StringUtils.h changes the meaning of string + int program-wide. A smell and an ambiguity hazard, not UB.
Fix: keep + quarantine. They are already single-header, inline, documented (StringUtils.h:988-994). Adding the rvalue += (from #1) closes the fixable half. For new code, steer message/diagnostic building to std::format (type-safe, namespaced, no operator ownership):
std::string msg = std::format("scan {} m/z {}", scan_id, mz); // no global operator neededHot-path carve-out (a stated constraint): keep Boost.Karma (StringUtils::toStr/appendToStr) in the mzML/mzXML serialization loops — std::format's float formatting differs from the tested BK_PrecPolicyFull 15-digit/NaN behavior and is slower. std::format is for non-hot diagnostics only; no blanket switch. Backing: C.161/C.168 (define operators in the operand's namespace) name why it smells; the pragmatic call is that deletion costs more than the contained smell.
#3 — DataValue's implicit std::string() cast is strict and throws
Diagnosis (verified): the cast (DataValue.h:135) is implicit and strict — std::string s = dv; compiles and throws ConversionError at runtime for any non-STRING_VALUE. The removed String(DataValue) ctor was lenient; StringUtils::toStr(dv) is the documented lenient replacement.
Fix: explicit (three of four proposals agree; reject P2's [[deprecated]]).
explicit operator std::string() const; // DataValue.h:135I verified the exact behavior by compilation:
| Call form | After explicit |
|---|---|
std::string s = dv; (the landmine) |
compile error |
static_cast<std::string>(dv) |
OK (explicit opt-in to strict) |
std::string s(dv); (direct-init) |
OK |
[[deprecated]] (P2) is strictly worse: it warns on the legitimate static_cast uses and never makes the dangerous copy-init a hard error. Pick explicit.
Scope discipline (critical): the pain point is the string cast. Lead with operator std::string() and the list types (StringList/IntList/DoubleList). Mark the numeric family (int x = dv;) a separate follow-on — blanket-breaking every numeric copy-init is churn the pain point doesn't motivate. Keep DataValue's constructors implicit — C.46 explicitly carves out variant/vocabulary types; only the operators (out-conversions) change. This direction-awareness is the thing the naive "make everything explicit" reading gets wrong.
ABI/pyOpenMS (verified): explicit-ness does not change a mangled name → no ABI break. The DataValue caster uses static_cast/toString() exclusively → zero binding change. Then sweep the 82 std::string … = …getMetaValue(…) copy-init sites (my count) to StringUtils::toStr(...) — compiler-found, bounded, one-time. Includes the live landmine at DBSuitability.cpp:479 and the test contract at DataValue_test.cpp (a deliberate, in-scope semantic edit, not a reference regeneration).
ParamValue is the parallel a maintainer will hit next. I confirmed
ParamValuealso declaresoperator std::string()(ParamValue.h:104) and its caster does copy-init (const std::string s = src;, line 486). If you extendexplicitto ParamValue later, that one line becomesstatic_cast<std::string>(src). Scope this PR to DataValue-first; name ParamValue as the identical follow-on.
Deferred (P1's
optionalaccessors):asInt()/asDouble()/asString() → std::optional<T>are a nice additive, non-throwing strict-query API, but they are not required to close #3 —explicit+ existingtoStr/toStringalready do. Enhancement tier, not the "now" list.
#4 — substr(string_view) returns an owning std::string → dangling view
Diagnosis (verified): StringUtils::substr(std::string_view, …) returns owning std::string (StringUtils.h:525-529); std::string_view sv = StringUtils::substr(view, …); dangles. No live bug in-tree, but a latent footgun. A facade does not fix this — String::substr returning String bound to a string_view dangles identically. This is purely a string_view lifetime issue.
Fix (P2/P4 merge): keep substr owning (matches std::string::substr intuition), add [[nodiscard]], and provide a clearly-named non-owning sibling so the verb carries the ownership contract:
[[nodiscard]] std::string substr(const std::string& s, size_t pos = 0, size_t n = npos); // owns
[[nodiscard]] constexpr std::string_view subview(std::string_view s OPENMS_LIFETIMEBOUND,
size_t pos, size_t n) noexcept
{ return s.substr(std::min(pos, s.size()), n); } // borrows, zero-allocOPENMS_LIFETIMEBOUND = [[clang::lifetimebound]]/[[msvc::lifetimebound]] (GCC ignores it harmlessly) → diagnoses subview(temporary()) at compile time. Add bugprone-dangling-handle (configured for std::string_view) as the static net and rely on an existing ASan lane as runtime backstop. Backing: F.42 / Lifetime profile — a view names non-ownership in its type.
#5 — discarding a copy-form (trimmed, toUppered, …) is a silent no-op
Diagnosis (verified): copy variants exist and are load-bearing (trimmed, toUppered, toLowered at StringUtils.h:570/584/586); no [[nodiscard]] anywhere. StringUtils::trimmed(x); as a statement silently does nothing.
Fix (all four agree — the highest-ROI, near-zero-cost item): [[nodiscard]] on every pure return-form:
[[nodiscard]] inline std::string trimmed(std::string s) { return std::move(trim(s)); }
[[nodiscard]] inline std::string toUppered(std::string s);
[[nodiscard]] inline std::string substr(const std::string& s, size_t pos = 0, size_t n = npos);
[[nodiscard]] inline std::string prefix(...); // + suffix/chop/concatenate/number/random/toStr familyDo NOT annotate the in-place mutators returning std::string& (trim, toUpper, reverse, …) — there the discard is legitimate (work landed in the argument). With the existing -Werror, discarded copies become build failures. ABI-neutral (attribute, no mangling change). Backing: F.20.
Deferred (the principled end-state): the deeper fix is value-by-default naming —
trim(s)→string(copy) andtrimInPlace(s&)→void. That is a 200+-site rename with ABI churn on non-inline forms; document as target, do not block on it.[[nodiscard]]alone converts the silent no-op into a diagnostic without touching a single call site.
#6 — StringUtils:: qualification friction
Diagnosis (verified): 5050 StringUtils:: qualified calls in source. ADL cannot help: std::string's associated namespace is std, not OpenMS. This is a papercut, not a footgun — do not over-invest.
Fix: document using namespace OpenMS::StringUtils; inside function bodies as the sanctioned escape hatch (it already works — StringUtils is a plain namespace). Optionally, P2's selective using-declarations for the top names (toStr, trim, split, hasPrefix) re-exported into namespace OpenMS. Caveat: an inline namespace is ABI-safe only if it contains using-declarations exclusively (definitions inside it shift mangled names) — fiddly enough that I'd treat it as optional polish, not a recommendation. The explicit StringUtils:: qualifier is also a mild feature: it visually distinguishes StringUtils::toStr(dv) (lenient, safe) from (std::string)dv (strict).
4. What I reject as impractical / over-engineered / ABI-breaking
- P4-B facade (and Option C): revert + ABI break + 215-line binding tail + C.35. Rejected.
- P2 deleting the global operators: hundreds of edits, zero safety gain (the lint covers the real hole). Rejected; keep + add rvalue
+=. - P3 custom
openms-string-narrowingLLVM plugin: over-engineered — stockbugprone-string-integer-assignmentcovers its entire claimed gap (in-range literals + bool→char) at one config line vs. a perpetually-maintained plugin. Cut it. - P2
[[deprecated]]on the DataValue cast: worse thanexplicit(warns on legitimatestatic_cast, never hard-errors the landmine). Rejected. - P1
optionalaccessors / value-by-default rename: good end-state, not required to close the pain points. Deferred, not "now." - Blanket
std::format: breaks hot-path format reproducibility/speed. Scope to non-hot diagnostics only.
5. Ordered action list (what to change first)
Tier 0 — ship now, ABI-neutral, ~hours, near-zero risk:
[[nodiscard]]on all copy-returningStringUtilshelpers (different icons and icon sizes for features and consensus features (DONE, Marc) [5] #5). F.20.- Add rvalue
operator+=(std::string&&, T)family (support chromatograms [1] #1 temporary hole). StringUtils.h ~1018. - Add
subview()(non-owning) +[[nodiscard]]onsubstr(Add an update mode for parameter files using -ini and -write_ini [4] #4). F.42. - Add project-root
.clang-tidywithbugprone-string-integer-assignment+bugprone-dangling-handle, warn-only, run diff-only in a new CI lane (support chromatograms [1] #1, Add an update mode for parameter files using -ini and -write_ini [4] #4). ES.46.
Tier 1 — the type-safety core, ABI-neutral, ~1 week, source-breaking by design:
5. explicit on DataValue::operator std::string() + the list-type operators (#3). C.164; keep ctors implicit per C.46.
6. Sweep the 82 std::string … = getMetaValue(…) copy-init sites → StringUtils::toStr(...); fix DBSuitability.cpp:479; update the DataValue_test.cpp contract. Compiler-found, bounded.
Tier 2 — contain + steer, no forced churn:
7. Document the global operators as intentional/quarantined; steer new non-hot code to std::format; keep Karma in serialization hot paths (#2).
8. Document using namespace OpenMS::StringUtils; as the #6 escape hatch.
Follow-on (named, deferred): ParamValue gets the identical explicit treatment (+ the one-line ParamValue caster fix at line 486); value-by-default trim/trimInPlace rename as the principled end-state; promote the clang-tidy lane to blocking after backlog burndown.
Core Guidelines / idioms backing the big calls: C.164 (avoid implicit conversion operators → explicit on the cast) · C.46 (the variant-type carve-out → DataValue constructors stay implicit) · ES.46/ES.48 (avoid lossy/narrowing conversions → the clang-tidy gate, since the language can't enforce it on a non-owned type) · F.20 ([[nodiscard]] on pure return-forms) · F.42 / Lifetime profile (subview view-names-non-ownership) · C.35 (the decisive strike against the facade) · C.161/C.168 (why the global operators smell).
Key files: src/openms/include/OpenMS/DATASTRUCTURES/StringUtils.h ([[nodiscard]] on copy-forms 543-586; substr/subview 519-529; rvalue += near 1018) · src/openms/include/OpenMS/DATASTRUCTURES/DataValue.h:135 (explicit) · src/openms/source/QC/DBSuitability.cpp:479 (live landmine) · src/openms/include/OpenMS/DATASTRUCTURES/ParamValue.h:104 + src/pyOpenMS/bindings/type_casters/openms_datavalue_caster.h:486 (ParamValue follow-on) · new .clang-tidy · cmake/compiler_flags.cmake:183 (optional -Wconversion GCC lane catches the wide→char half).
|
will do |
|
Addressed the
Left untouched on purpose:
To find the in-scope call sites by type rather than by grep, I temporarily marked the string One deliberate non-change: I kept the remaining |
…nversion + compile fixes Run the String->std::string conversion across the codebase and get it to compile: convert types, String(...) ctors, member calls, revert vendored extern/ and Qt/GUI interop mangles, wrap numeric/char emplace/insert in toStr. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Per-site corrections: split() delimiters corrupted to ', '; wrongly-converted member calls (.remove/.has on non-string objects); DataValue::operator std::string() kept strict; numeric->toStr; rvalue operator overloads (fillLeft/fillRight/ensureLastChar/substituted); String::npos/iterator; concatenate char-glue; TEST_EQUAL(std::string,numeric); GUI Qt-interop. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…tovers Fix the DataValue strict-vs-lenient, int/double-as-char, dangling StringView, in-place toUpper, and DataValue meta round-trip corruptions surfaced by the full ctest (EMPTY ref, MzTab parse, getDiffMonoMass, OMSFile, EnzymaticDigestion, MQEvidence, MzIdentML, SqliteConnector, ExperimentalDesign/IBSpectra, AbsoluteQuant, TransitionTSVFile charge, MSstats). Convert pyOpenMS bindings (caster dedup + 6 files), GUI apps, and doc tools the script skipped. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Audit-by-type-change (not diff-line) + -Wconversion char-narrowing sweep found silent corruptions tests missed: SiriusMSConverter cmpinfo.fid uint64->char, MzPAF tokenizer dangling string_view (15 use-after-free sites), 4 more '= numeric' truncations (qp.value/sample_name). Document the Class B DataValue strict-vs-lenient cast contract; wrap ~12 latent getMetaValue casts; fix 2 gated bare-String tests; valid RST in SpectrumRanges docstring. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
CI's clean multi-compiler build surfaced two missed-conversion sites that ccache masked in local incremental builds: - SageAdapter.cpp: std::map<String,String> -> std::map<std::string,std::string> (bare String the conversion missed; broke g++/clang/xcode). - 21 DataValue list-casts (StringList|IntList|DoubleList)getMetaValue(...) -> the portable named accessors .toStringList()/.toIntList()/.toDoubleList() across 9 files. The C-style cast compiles on g++/clang but MSVC rejects it; ProteinIdentification.cpp:437 was the one MSVC reached before failing fast. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Second CI round (8822) surfaced two more, both invisible on the local/Linux path: - File_test.cpp:343 is inside #ifdef OPENMS_WINDOWSPLATFORM, so only MSVC compiles it: StringUtils::suffix(find,7).toUpper() (member call on std::string) -> StringUtils::toUppered(StringUtils::suffix(find,7)) (copy variant; suffix returns a temporary). g++/clang/xcode never compile this gated branch. - ILPDCWrapper.h:95 doc comment '@ref String' referenced the deleted String class -> unresolved-reference doxygen warning that fails Doxygen_Warning_test on CI (which has graphviz/dot). Changed to '@c std::string'. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
C++23 makes std::string_view fully available, so the hand-rolled StringView (a pre-C++17 boost::string_ref shim) is redundant. Replace it with std::string_view across all 22 users and delete StringView.h/.cpp. Behavior-preserving notes: - SimpleSearchEngineAlgorithm: StringView::operator< was shortlex (length first, then lexicographic) whereas std::string_view is lexicographic. AnnotatedHit_::hasBetterScore() tie-breaks equal-score PSMs on the sequence, and PeptideIdentification::sort() is a stable_sort by score only, so that tie order reaches the idXML. Reproduced the shortlex order explicitly (size-then-lexicographic) so output stays byte-for-byte identical. (This tie path is not exercised by the references, so it is inspection-verified.) - The 3 ordered dedup containers (2x set, 1x multimap) only gate contains()/insert(); key-equivalence is content-equality under both comparators, so dedup results are identical and order is never observed. - .getString() -> std::string(view); dropped the now-redundant std::string_view() wrappers at digestUnmodified call sites (std::string converts implicitly). pyOpenMS: removed the pyopenms.StringView class binding (it was default-constructible-only, never returned/accepted elsewhere, unusable) and its existence test. EnzymaticDigestion.digestUnmodified's Python API is unchanged (str in, list[str] out). IDScoreGetterSetter: the edited getPickedProteinScores_ is dead code (commented out); updated only for consistency (also the correct, non-dangling form should it ever be revived). Verified: full build recompiled all EnzymaticDigestion.h dependents; EnzymaticDigestion/FragmentIndex/OPXLHelper/PeptideAndProteinQuant unit tests plus TOPP_SimpleSearchEngine_DDA / OpenNuXL / OpenPepXL / ProteinInference pass; pyOpenMS builds, imports, digestUnmodified works, API tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Per @cbielow's review, replace unnecessary StringUtils::toStr() wrapping with std::string / the bare expression: - toStr("literal") -> std::string("literal") (string-literal anchors) - toStr(<char*/std::string/string_view expr>) -> std::string(...) (e.g. construct std::string directly from getenv(), char buffers, etc.) - Drop the wrapper entirely for the provably-redundant identity cases std::string(x.str()/.dump()/.toStdString()/.get<std::string>()) -> x...() The toStr->std::string rename is type-identical (toStr(const char*) is literally `return std::string(s)`), so behaviour is unchanged. Numeric, DataValue and ParamValue toStr overloads are left untouched (genuinely needed), as are the generic-T stringifiers in ListUtils/ListUtilsIO/ ElementDB/ClassTest where toStr is the polymorphic conversion and std::string(T) would not compile for numeric T. Detected the in-scope call sites with a [[deprecated]] probe on the string toStr overloads so the compiler flagged them by type; full build is clean and the affected unit tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
5c1cfcd to
8729f84
Compare
Per @cbielow's review, `std::string x = "";` is needlessly noisy — a default-constructed std::string is already empty. Simplify the variable-declaration form to `std::string x;` (also the {""} / ("") forms). Behaviour is unchanged. Function parameter defaults (`f(std::string x = "")`) are intentionally left as-is, since `std::string x;` is not valid there. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…tChar StringUtils::ensureLastChar has only (std::string&) and (std::string&&) overloads, so argv[1] (char*) implicitly converts to a temporary std::string that binds to the && overload — the explicit std::string(...) wrapper is redundant. Behaviour is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Per @cbielow's review, add a convenience overload template <std::ranges::range Container> std::string concatenate(const Container& c, const std::string& glue = "") so callers can write `StringUtils::concatenate(container, ", ")` instead of the iterator form `concatenate(s, container.begin(), container.end(), ", ")`. The std::ranges::range constraint keeps it from competing with the existing iterator overloads (verified: no ambiguity at any call site). Migrate the iterator-style call sites to the new form, merging with the preceding `std::string x;` declaration into a single statement where applicable. Genuine sub-range calls (end()-n, begin()+2) are left as-is. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Per @cbielow's review (#3): in `std::string("min: ") + StringUtils::toStr(x)` the std::string() wrapper is only there to anchor the concatenation, but the right-hand side StringUtils::toStr(...) is already a std::string, so `const char* + std::string` works without it. Drop the wrapper: std::string("min: ") + StringUtils::toStr(it->min_float) -> "min: " + StringUtils::toStr(it->min_float) Restricted to LEFT-operand position (the literal is the left side of its '+'), so there is never a `char* + "LIT"` or pointer-arithmetic `int + "LIT"` hazard; the right-hand toStr() guarantees std::string concatenation. Mid-chain anchors (right operands) are intentionally left as-is. Verified: no bare `const char* + <int>` sites exist, and all touched TUs still compile. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…rs (#9468) Following the String -> std::string migration (PR #9450), the headers String.h, StringConversions.h and StringUtilsSimple.h (and their .cpp counterparts) became empty backward-compat shims that just forwarded to StringUtils.h. Remove them and point all includers directly at StringUtils.h. - Delete the 6 shim files (.h/.cpp for String, StringConversions, StringUtilsSimple); String.cpp was an empty stub. - Rewrite all #include <OpenMS/DATASTRUCTURES/String.h> (and the two remaining StringUtilsSimple.h includes) to StringUtils.h across the source tree. - Drop the deduped duplicate includes this created (FASTAContainer.h, SwathWindowLoader.cpp, PeptideIdentification_test.cpp). - Remove the stale entries from the DATASTRUCTURES sources.cmake files. The StringConversions namespace lives on inside StringUtils.h and is unaffected. Verified: cmake reconfigure + full libOpenMS build succeed. Co-authored-by: Claude Fable 5 <[email protected]>
…agingGeometry reuse Follow-up to the rebase of the imzML PR onto develop, making it compile and correct against current develop and integrating it with the IMAGING module. Migration (post OpenMS#9450 / OpenMS#9468, which removed OpenMS::String): - Port all imzML sources, the FileHandler imzML helpers, the pyOpenMS bindings and the tests to std::string + StringUtils/StringConversions. Correctness fixes: - ImzMLHandler: only snapshot per-spectrum IMS state for spectra MzMLHandler actually delivers (gate on !skip_spectrum_) — fixes silent coordinate/.ibd offset corruption when PeakFileOptions skip any spectrum. - ImzMLFile: add an advisory .ibd UUID integrity check (16-byte header vs IMS:1000080); accept dashed and brace-wrapped UUIDs. - Reject negative IMS:1000102/1000103 offset/count values (std::stoull wraps). - Thread the .ibd path override through loadSpectraIndex so the override file (not an inferred sibling) is the one validated and read. - Regenerate the malformed continuous test fixture: prepend the 16-byte UUID header, shift external offsets by 16, fix the declared md5 and dataset hash. OnDiscImzMLExperiment: reuse the shared IMAGING module instead of a bespoke coordinate map. - Build an MSImagingGeometry eagerly in open() (in-memory pass; only peak decode stays lazy) and route getSpectrumAtCoord through it; delete PixelKey/coord_map_. - Add getGeometry() (+ pyOpenMS binding) returning the 0-based 2D geometry. Lenient loading: a UUID mismatch, an out-of-grid pixel, or a <1 coordinate are now warnings (the dataset still loads); duplicate coordinates remain a hard error. Cleanup: remove dev scaffolding (demo_imzML_*.py, run_imzML_metadata_demo.sh); relocate test_data_paths.py into tests/unittests with depth-independent resolution. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Two issues addressed: 1. Serialize TOPP_MSGFPlusAdapter_2 after TOPP_MSGFPlusAdapter_1 in CTest (DEPENDS). Both tests share the same proteins.fasta and spectra.mzML; MSGF+ creates temp/cache files alongside those inputs, causing file-access conflicts on Windows when the two tests run in parallel. Parallel execution was never safe for these tests — they were just never co-scheduled until test 2 was added in #9461. 2. Fix scan-number extraction from SpecID in the legacy TSV fallback path (MSGFPlusAdapter.cpp). PR #9450 changed elements[1] from OpenMS::String to std::string and replaced `elements[1].suffix('=').toInt()` with `StringUtils::toInt32(elements[1])`. For SpecIDs of the form "controllerType=0 controllerNumber=1 scan=17" the old call extracted the integer after the last '='; the new call tries to convert the whole string and throws ConversionError. Restore the correct behaviour with rfind('=') + substr. https://claude.ai/code/session_01RjUeua8ecNatvyBSSjfeGe Co-authored-by: Claude <[email protected]>
PR #9450 dropped the implicit suffix('=') when migrating String->std::string, turning a SpecID like "controllerType=0 controllerNumber=1 scan=17" into a ConversionError. With suffix(char) now returning the whole string when the delimiter is absent, the original intent is expressed in a single line and also handles a bare-integer SpecID gracefully. https://claude.ai/code/session_01TzmuvTWtGMmc5hhH8kXK7Y
* [FEATURE,TEST,API] Add imzML read and write support Add ImzMLFile with full load, streaming, on-disc random access, RAM pixel lookup, and export via store() (float32 external arrays, UUID-linked .ibd); register FileTypes::IMZML at end of enum with FileHandler integration; expose pyOpenMS bindings, tests, tutorial, and demo. Harden IBD I/O, IMS CV parsing, imaging metadata, schema validation, and on-disc thread safety. Address review feedback across multiple rounds: coordinate/z lookups, test guards, batched consumer docs, SAX file parsing, full ImzMLMeta on load, WRITEABLE file type, big-endian fix, UUID .ibd header, collision-safe pixel map, streaming MD5, RAII .ibd writes, continuous-mode validation, hybrid array decode, required pixel coords, compressed imzML detection, mzML XML ordering, safe move semantics, and balanced Xerces init/terminate. Co-authored-by: Cursor <[email protected]> * [FEATURE,TEST] Extend ImzML writer with options, metadata, precision Apply PeakFileOptions on store (filtering, sort, metadata-only), round-trip imaging metadata and spectrum RT/MS level, and support float32/float64 .ibd export via getMz32Bit/getIntensity32Bit with MD5 and SHA-1 checksums. Co-authored-by: Cursor <[email protected]> * [TEST,DOC] Add imzML dataset metadata tests and demo scripts Verify ImzMLMeta is mirrored on MSExperiment for continuous and processed reference fixtures. Add demo_imzML_metadata.py, a shell runner, and extend Tutorial_ImzMLFile to print dataset metadata after load. Co-authored-by: Cursor <[email protected]> * [DOC] Correct imzML export precision documentation Clarify that ImzMLFile::store() supports float32/float64 via PeakFileOptions, not float32-only. Update scan_direction CV comment. Co-authored-by: Cursor <[email protected]> * [FIX,TEST] Fix imzML max_dim export and align modes tests Correct max_dim_x/y scaling on export (micrometer units). Align Python all_modes tests with ImzMLFile_all_modes_test.cpp and assert max_dim round-trip in C++ and Python metadata store tests. Co-authored-by: Cursor <[email protected]> * [DOC] Fix max_dim unit label in imzML metadata demo Use micrometers (um) for max_dim_x/y output to match imzML convention and ImzMLWriter export units. Co-authored-by: Cursor <[email protected]> * [FIX] Remove incorrect noexcept from OnDiscImzMLExperiment moves Moved-from state allocates a new Impl via make_unique, which may throw; do not mark move ctor/assignment as noexcept. Co-authored-by: Cursor <[email protected]> * [FIX,TEST] Hash imzML and companion ibd in FileHandler When rewrite_source_file and compute_hash are enabled, imzML datasets now get a SHA1 over both the .imzML XML and its .ibd binary file, matching the two-file nature of the format. Co-authored-by: Cursor <[email protected]> * [FIX] Throw on null .ibd handle in ImzML binary writer writeFloat32Array and writeFloat64Array no longer treat a null FILE* as success; invalid handles fail fast instead of producing broken .imzML/.ibd file pairs. Co-authored-by: Cursor <[email protected]> * [FIX] Reject partially parsed UUID hex bytes in ImzMLWriter uuidStringToBytes_ now requires strtoul to consume the full two-character hex byte, rejecting inputs like "1g" instead of silently truncating. Co-authored-by: Cursor <[email protected]> * [FIX] Reject mixed empty/non-empty spectra for continuous imzML spectraShareMz_ now returns false when any spectrum is empty, preventing continuous export from assigning a shared m/z count to empty pixels. Co-authored-by: Cursor <[email protected]> * [FIX] Remove broken GlobalLogSilencer from ImzMLFile load The guard removed global WARN/ERROR sinks but only restored std::cerr, which could drop user-configured log destinations. It also did not suppress handler warnings because OPENMS_LOG_* uses thread-local streams. Co-authored-by: Cursor <[email protected]> * [FIX] Release Xerces error messages in ImzMLFile parse failures Use Internal::StringManager::convert() for XML/SAX exception text so transcoded Xerces buffers are released on parse error paths. Co-authored-by: Cursor <[email protected]> * [FIX] Check open state in OnDiscImzMLExperiment::getSpectrumAtCoord Throw FileNotFound when the .ibd is not open before coordinate lookup, matching getSpectrum() instead of misleading ElementNotFound errors. Co-authored-by: Cursor <[email protected]> * [FIX] Release GIL during ImzMLFile index load and validation loadSpectraIndex and isValid now use gil_scoped_release for blocking C++ I/O, consistent with the other ImzMLFile pyOpenMS bindings. Co-authored-by: Cursor <[email protected]> * [FIX] Use _fseeki64 for imzML .ibd seeks on Windows MSVC does not provide POSIX fseeko; use _fseeki64 on WIN32 and keep fseeko elsewhere. Also include cstdio explicitly in the .cpp translation unit. Co-authored-by: Cursor <[email protected]> * Fix MSVC C4100 in ImzMLHandlerHelper decodeLittleEndian_ Mark data and count as [[maybe_unused]] because they are only referenced inside the OPENMS_IS_BIG_ENDIAN branch; on Windows (little-endian) MSVC treats the unused parameters as errors. Co-authored-by: Cursor <[email protected]> * imzML: rebase fixups — std::string migration, correctness fixes, MSImagingGeometry reuse Follow-up to the rebase of the imzML PR onto develop, making it compile and correct against current develop and integrating it with the IMAGING module. Migration (post #9450 / #9468, which removed OpenMS::String): - Port all imzML sources, the FileHandler imzML helpers, the pyOpenMS bindings and the tests to std::string + StringUtils/StringConversions. Correctness fixes: - ImzMLHandler: only snapshot per-spectrum IMS state for spectra MzMLHandler actually delivers (gate on !skip_spectrum_) — fixes silent coordinate/.ibd offset corruption when PeakFileOptions skip any spectrum. - ImzMLFile: add an advisory .ibd UUID integrity check (16-byte header vs IMS:1000080); accept dashed and brace-wrapped UUIDs. - Reject negative IMS:1000102/1000103 offset/count values (std::stoull wraps). - Thread the .ibd path override through loadSpectraIndex so the override file (not an inferred sibling) is the one validated and read. - Regenerate the malformed continuous test fixture: prepend the 16-byte UUID header, shift external offsets by 16, fix the declared md5 and dataset hash. OnDiscImzMLExperiment: reuse the shared IMAGING module instead of a bespoke coordinate map. - Build an MSImagingGeometry eagerly in open() (in-memory pass; only peak decode stays lazy) and route getSpectrumAtCoord through it; delete PixelKey/coord_map_. - Add getGeometry() (+ pyOpenMS binding) returning the 0-based 2D geometry. Lenient loading: a UUID mismatch, an out-of-grid pixel, or a <1 coordinate are now warnings (the dataset still loads); duplicate coordinates remain a hard error. Cleanup: remove dev scaffolding (demo_imzML_*.py, run_imzML_metadata_demo.sh); relocate test_data_paths.py into tests/unittests with depth-independent resolution. Co-Authored-By: Claude Opus 4.8 <[email protected]> * Tutorial_ImzMLFile: load bundled data via OPENMS_DOC_PATH Follow the existing code-examples convention instead of a bespoke mechanism. Other file-loading tutorials (Tutorial_FileIO_mzML, Tutorial_GaussFilter, ...) load a committed input from doc/code_examples/data/ via the global OPENMS_DOC_PATH macro and need no per-example build wiring. - Add the example dataset doc/code_examples/data/Tutorial_ImzMLFile.{imzML,ibd} (force-added; the dir is .gitignored like the other tutorial fixtures). - Use OPENMS_DOC_PATH + "/code_examples/data/Tutorial_ImzMLFile.imzML" as the default input (argv[1] still overrides); drop the OPENMS_IMZML_TUTORIAL_FILE macro and the now-dead usage/empty-path branch. - Remove the if(i STREQUAL "Tutorial_ImzMLFile") target_compile_definitions block from doc/code_examples/CMakeLists.txt -- it was the only per-example special-case in the examples loop. The no-argument ctest passes against the bundled dataset (all 7 imzML modes run). Co-Authored-By: Claude Opus 4.8 <[email protected]> * imzML: load only into MSImagingExperiment (treat imzML as an imaging format) imzML is a mass spectrometry imaging format, so its canonical in-memory target is MSImagingExperiment, matching BrukerTimsImagingFile (which is likewise imaging-only and not reachable through the generic FileHandler). Stop treating imzML as a flat mzML-like MSExperiment. - Remove ImzMLFile::load(const std::string&, MSExperiment&); load(MSImagingExperiment&) now decodes the spectra and builds the geometry directly. Callers that only need the flat spectra use MSImagingExperiment::getMSExperiment(). load(consumer), loadSpectraIndex() and store(MSExperiment) are unchanged. - FileHandler::loadExperiment() no longer loads imzML: it throws Exception::InvalidFileType with guidance to use ImzMLFile. Drop the imzML dataset-hash branch and its now-unused helpers (computeImzMLDatasetHash_, inferImzMLIbdPath_); FileHandler::getType / getTypeByContent still detect imzML. - pyOpenMS: drop the load(MSExperiment&) binding (keep load(MSImagingExperiment&)). - Update tests, the tutorial, and the Python tests: flat loads go through MSImagingExperiment::getMSExperiment(); FileHandler-loads-imzML cases now assert the InvalidFileType throw; the tutorial drops its FileHandler load mode. Co-Authored-By: Claude Opus 4.8 <[email protected]> * imzML: geometry-driven store(MSImagingExperiment); drop imzML store from FileHandler Make storing symmetric with loading and consistent with how the imaging model is populated. BrukerTimsImagingFile builds MSImagingGeometry directly (no imzml:* MetaValues); the imzML writer, however, reads coordinates from per-spectrum imzml:x/y MetaValues, so a geometry-only MSImagingExperiment (e.g. a Bruker-loaded one) could not be stored as imzML. - Add ImzMLFile::store(const std::string&, const MSImagingExperiment&): the geometry is the source of truth for pixel coordinates, grid dimensions and pixel size. They are derived from exp.getGeometry() onto a copy of the wrapped experiment, so this works for any MSImagingExperiment regardless of whether the spectra carry imzml:x/y MetaValues. The low-level store(MSExperiment&) (MetaValue-driven) stays for building imzML from raw spectra. - FileHandler::storeExperiment() no longer stores imzML: it throws Exception::InvalidFileType (symmetric with loadExperiment). imzML I/O now goes exclusively through ImzMLFile, matching BrukerTimsImagingFile (which is also absent from the generic FileHandler). Removed the now-unused ImzMLFile.h include from FileHandler.cpp. - pyOpenMS: bind store(MSImagingExperiment&). - Test: store a geometry-only MSImagingExperiment with NO imzml:x/y MetaValues and verify the coordinates round-trip from the geometry. Co-Authored-By: Claude Opus 4.8 <[email protected]> * imzML: build the imaging geometry directly from the parsed index (one shared builder) Make the geometry the source of truth on the read side too, like BrukerTimsImagingFile. Previously ImzMLFile::load(MSImagingExperiment&) reconstructed the geometry by reading imzml:x/y MetaValues back off the spectra, while OnDiscImzMLExperiment built it directly from the parsed index — two implementations, and an unnecessary MetaValue dependency. - Add ImzMLFile::buildImagingGeometry(const std::vector<ImzMLSpectrumIndex>&, const ImzMLMeta&, MSImagingGeometry&): derives the pixel grid straight from the per-spectrum coordinates captured during parsing (1-based -> 0-based, z==1 plane, dims/pixel-size from meta; out-of-grid/<1 coords warned and skipped, duplicates throw). No MetaValue reads. - ImzMLFile::load(MSImagingExperiment&) now captures the parsed index/meta and builds the geometry with that overload instead of buildImagingGeometry(MSExperiment&). - OnDiscImzMLExperiment::buildGeometry_ delegates to the shared builder (deletes its duplicated logic + now-unused includes), so the in-memory and on-disc paths cannot diverge. - Keep buildImagingGeometry(MSExperiment&) as a public utility for experiments that carry imzml:x/y MetaValues; disambiguate its pyOpenMS binding (now overloaded). - Test: build a geometry from a hand-built index with no MSExperiment and no imzml:* MetaValues. imzml:x/y MetaValues are still attached to spectra as per-spectrum provenance, but the geometry no longer depends on them — it is built directly from the parsed coordinates. Co-Authored-By: Claude Opus 4.8 <[email protected]> * imzML: document loadSpectraIndex ibd_path parameter (fix Doxygen_Warning_test) The ibd_path parameter added to ImzMLFile::loadSpectraIndex was missing a @PARAM entry, which Doxygen flags and Doxygen_Warning_test treats as a failure. Co-Authored-By: Claude Opus 4.8 <[email protected]> * [DOC] imzML: correct CHANGELOG entry for imaging-first API The imzML changelog line still described the pre-rework API. Update it to match the merged code: loads into MSImagingExperiment (imaging-only, like BrukerTimsImagingFile) with the geometry built from the parsed spectrum index; geometry-driven store(MSImagingExperiment) plus low-level store(MSExperiment); FileHandler detects imzML but rejects flat load/store. Co-authored-by: Cursor <[email protected]> * [DOC] imzML: drop stale load(MSExperiment&) from docstrings The ImzMLFile class-level "Loading modes" comment and the pyOpenMS ImzMLFile docstring still described a load-into-MSExperiment mode that was removed when imzML became imaging-only. Point both at load(MSImagingExperiment&) (with getMSExperiment() for the flat spectra), matching the current API. Co-authored-by: Cursor <[email protected]> * [FIX] ImzMLFile: don't call Xerces Terminate() from noexcept guard dtor The XercesPlatformGuard destructor called XMLPlatformUtils::Terminate(), which is not noexcept and may throw. Since destructors are implicitly noexcept, a throw during cleanup invoked std::terminate(), crashing the process. On Windows/MSVC this surfaced as a __fastfail with exit code 0xC0000409 (3221226505) during the pyOpenMS wheel tests, killing the run at the first in-memory imzML parse (test_imaging_experiment_ram_lookup); macOS and Linux wheels were unaffected because Terminate() does not throw there. It also tore down the process-global Xerces state shared with every other OpenMS XML reader. OpenMS initializes Xerces once process-wide via the guard in CONCEPT/Init.cpp (ticket #352), and no other parser pairs Initialize() with a per-operation Terminate(). Drop the per-load Terminate(); keep the idempotent, reference-counted Initialize() to match Internal::XMLFile. The existing test_imaging_experiment_ram_lookup covers the regression. Co-authored-by: Cursor <[email protected]> * [FIX] ImzMLHandler: suppress OpenMP log-race heap corruption on Windows imzML's companion .ibd files mean the inline <binary> elements are empty placeholders, yet the spectrum still declares defaultArrayLength = N (the external element count). MzMLHandler::populateSpectraWithData_() runs inside a `#pragma omp parallel for`; for every spectrum it compared the 0 decoded values against the declared N and emitted "array has size 0 but should have size N (defaultArrayLength)" via OPENMS_LOG_WARN. LogStreamBuf is not thread-safe (shared streambuf, static line buffer, incomplete_line_ string, message cache), so those concurrent writes from multiple OpenMP threads corrupt the heap — observed as a non-deterministic 0xC0000374 abort in both the Windows C++ class test (ImzMLFile_test) and the Windows pyOpenMS wheel tests. Fix: at binaryDataArray end, zero bin_data_.back().size for external arrays so decodeBase64Arrays sees a length-0 array (no mismatch, no warning). At spectrum end, zero default_array_length_ when either array is external — this is the value MzMLHandler snapshots into the batch before the parallel populate pass. ImzMLInterceptConsumer fills the real peaks from the .ibd afterwards using the external offsets/counts, which are independent of these fields. Co-authored-by: Cursor <[email protected]> --------- Co-authored-by: Cursor <[email protected]> Co-authored-by: Timo Sachsenberg <[email protected]> Co-authored-by: Claude Opus 4.8 <[email protected]>
PR #9450 dropped the implicit suffix('=') when migrating String->std::string, turning a SpecID like "controllerType=0 controllerNumber=1 scan=17" into a ConversionError. With suffix(char) now returning the whole string when the delimiter is absent, the original intent is expressed in a single line and also handles a bare-integer SpecID gracefully. https://claude.ai/code/session_01TzmuvTWtGMmc5hhH8kXK7Y
The String->std::string refactor (#9450) made DataValue::operator std::string() strict (throws on non-string types). The PeptideIdentification string accessors getSpectrumReference()/getBaseName()/getExperimentLabel() do `return getMetaValue(...)`, which previously used the lenient String(DataValue) stringification but now hit the strict operator. When spectrum_reference is stored as an integer (e.g. a scan index loaded from idparquet/mzIdentML), ProteomicsLFQ crashed during mzTab export with: "Could not convert non-string DataValue of type 'Int' and value '0' to string" The crash originated in MzTab's CMMzTabStream constructor via getMSRunSpectrumIdentifierType_(), which read spectrum_reference directly into a std::string; getSpectrumReference() (used in the peptide section) would have thrown next. A sibling site was already wrapped with StringUtils::toStr() in #9450, but these were missed. Restore the lenient stringification (the documented StringUtils::toStr replacement for the old String(DataValue) behavior) in the three accessors, and use getSpectrumReference() at the direct mzTab call site. Add a PeptideIdentification regression test for an integer spectrum_reference / base_name. Co-authored-by: Claude <[email protected]>
…ter absent (#9501) * StringUtils: make prefix/suffix(char) return whole string when delimiter absent prefix(s, delim) and suffix(s, delim) previously threw Exception::ElementNotFound when the delimiter was not present. Throwing a container-lookup exception from a string-slicing helper is surprising and forced callers to either guard every call or wrap it in try/catch. It was also the root cause of the MSGFPlusAdapter scan-number regression: the String->std::string migration dropped the implicit suffix('=') extraction, and the strict throw turned a benign input into a crash. Now the missing-delimiter case returns the whole string ("nothing to cut off -> you get the original back"), giving a simple, symmetric, no-surprises contract. Fixed the only two call sites that relied on the throw as control flow: - FileHandler::getTypeByFileName: explicit has('.') guard (preserves Bruker fid -> XMASS and UNKNOWN handling). - ImageCreator: explicit has('.') guard (preserves "nosuffix" fallback). All other char-delim callers either guarantee the delimiter is present or had no exception handling (so they would previously crash on missing input and now degrade gracefully). Updated String_test accordingly. https://claude.ai/code/session_01TzmuvTWtGMmc5hhH8kXK7Y * MSGFPlusAdapter: restore scan-number extraction via lenient suffix('=') PR #9450 dropped the implicit suffix('=') when migrating String->std::string, turning a SpecID like "controllerType=0 controllerNumber=1 scan=17" into a ConversionError. With suffix(char) now returning the whole string when the delimiter is absent, the original intent is expressed in a single line and also handles a bare-integer SpecID gracefully. https://claude.ai/code/session_01TzmuvTWtGMmc5hhH8kXK7Y * StringUtils: use @brief + detail Doxygen style for prefix/suffix(char) Conform to developer_coding_conventions: brief description, blank line, then detailed behavior (delimiter-absent case). https://claude.ai/code/session_01TzmuvTWtGMmc5hhH8kXK7Y * TOPPBase::parseRange_: require the ':' separator instead of silently misreading With StringUtils::prefix/suffix(.,':') now returning the whole string when the delimiter is absent, a colon-less range like "400" was silently interpreted as the degenerate range 400:400 instead of failing as before. Restore the loud failure: parseRange_ now throws Exception::ConversionError when the mandatory ':' separator (documented format "[min]:[max]") is missing. Valid input (which always contains ':', e.g. ":", "0:0", "600:5000") is unaffected. Adds a regression test. Co-Authored-By: Claude Opus 4.8 <[email protected]> * Guard remaining char-delimiter callers that relied on prefix/suffix throwing After making StringUtils::prefix/suffix(char) lenient, two broad-catch call sites silently changed behavior on malformed input. Restore the intended behavior explicitly: - RibonucleotideTSVDataProvider::parseRow_: an ambiguity entry whose 10th field lacks the space separator now throws ParseError (so the row is skipped, as before) instead of silently setting both alternative codes to the same single value. - TargetedSpectraExtractor: an identifier without a '_' now leaves PeptideRef empty (as the previous throw-and-catch did) instead of silently using the whole identifier; the dead try/catch is removed. Co-Authored-By: Claude Opus 4.8 <[email protected]> --------- Co-authored-by: Claude <[email protected]>
…9450) (#9724) PR #9450 removed the OpenMS::String class (and StringView) in favor of std::string / std::string_view but never added a CHANGELOG entry. Record it as a BREAKING change in the 3.6.0 General section next to the related Qt string-interop removal (#8940), noting the StringUtils free-function migration path and the follow-up shim-header removal (#9468). Co-authored-by: Claude Fable 5 <[email protected]>
…n exception in TOPPView). Follow up on #9450 (replace String with std::string)
…igration developer_cpp_guide.doxygen, developer_coding_conventions.doxygen and TargetedQuantitation.doxygen still taught/showed OpenMS::String and vector<String> as current API (PR #9450 removed String/StringView in favor of std::string, with StringUtils::toStr/toDouble replacing the former member helpers). The TargetedQuantitation snippet no longer compiled against AbsoluteQuantitation::optimizeCalibrationCurves(), whose signature now takes std::map<std::string, ...>.
… teach it (#10298) OpenMS 3.6 replaced OpenMS::String with std::string (#9450, #9468), but there was no migration guide, and several documents still showed the removed API. New page manual/develop/string-migration.md: the replacement for each member of the 3.5 String (checked against the 3.5 String.h and the current StringUtils.h), and the changes the compiler does not catch: - the DataValue/ParamValue conversion to std::string is strict and throws, where String(DataValue) was lenient (use StringUtils::toStr); - `s += 5` without StringUtils.h appends the character 5, and std::to_string writes six decimals; - StringUtils::prefix/suffix(s, c) return the whole string where String::prefix/suffix(c) threw ElementNotFound. Stale references fixed: developer_cpp_guide, coding conventions and TargetedQuantitation Doxygen pages, AGENTS.md and the Copilot instructions (the text of the unmerged 976e0dc), plus the developer FAQ (temporary directories via SystemSettings/TempDir instead of Qt), the new-tool page (ListUtils::create), and the pyOpenMS wrapping guides. Claude-Session: https://claude.ai/code/session_01YC1T2K9HQEUk2kQMZqC8h7 Co-authored-by: Claude <[email protected]>
develop removed OpenMS::String from these classes (#9450, #9468): stringListToIsotopeCorrectionMatrixSplit_() now takes std::string lists and uses StringUtils. It also accepts the single-parameter layout of OpenMS 3.6.0 (one 14-column row for every channel in correction_matrix), so INI files written by 3.6.0 keep working. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012GBvJZN8neGpv9RoUshwFL
Description
both the current inheritance and a possible change to composition are problematic when trying to ensure a smooth, efficient conversion (assignment, move assignment, move construction etc) between String and std::string.
So we just get rid of String entirely.
This stuff is not finished yet...
Checklist
How can I get additional information on failed tests during CI
Click to expand
If your PR is failing you can check outIf you click in the column that lists the failed tests you will get detailed error messages.
Advanced commands (admins / reviewer only)
Click to expand
/reformat(experimental) applies the clang-format style changes as additional commit. Note: your branch must have a different name (e.g., yourrepo:feature/XYZ) than the receiving branch (e.g., OpenMS:develop). Otherwise, reformat fails to push.rebuild jenkinswill retrigger Jenkins-based CI builds