Repository navigation
Make Xerces-C++ a private link dependency of libOpenMS - #9712
Conversation
…e SAX callbacks Introduce Internal::XMLAttributes, an opaque (void*-backed) Xerces-free view over a SAX attribute list, and add native onStartElement/onEndElement/onCharacters callbacks to XMLHandler (char16_t / std::u16string_view / XMLAttributes). The existing Xerces DefaultHandler overrides now forward to these native callbacks; subclasses still on the Xerces signatures are unaffected (the native path is dormant until they migrate). Attribute helper signatures switch to XMLAttributes (constructed transparently from xercesc::Attributes& via a constrained template ctor). No behavior change; libOpenMS still links Xerces PUBLIC. Co-Authored-By: Claude Fable 5 <[email protected]>
…native callbacks Migrate the ~28 SAX handler / *File / validator subclasses from the Xerces-typed callbacks (startElement/endElement/characters with const XMLCh*, xercesc::Attributes&, XMLSize_t) to the native onStartElement/onEndElement/onCharacters callbacks (char16_t / Internal::XMLAttributes / Size). Unused uri/localname args are dropped (the parser runs namespace-unaware, so localname is always empty). Raw attribute access (getValue/getIndex/getValue(index)) is rerouted through the XMLAttributes accessors (value/index/valueByIndex). Extra Xerces-typed private helpers (handleCVParam_, readRTMZCharge_, getLinkPosition_, getCVTerm_) are retyped to XMLAttributes. Subclass headers no longer name any Xerces type. Xerces still links PUBLIC (XMLHandler.h base cut happens in Phase C). All 18 parser round-trip tests pass unchanged. Co-Authored-By: Claude Fable 5 <[email protected]>
Remove Xerces from all public/installed OpenMS headers so it can become a PRIVATE
link dependency:
- XMLHandler no longer derives from xercesc::DefaultHandler. A new internal,
non-installed SAX2HandlerAdapter bridges the Xerces SAX2 interface to the
Xerces-free onStartElement/onEndElement/onCharacters callbacks and OpenMS-typed
error handlers. XMLFile.cpp and ImzMLFile.cpp install the adapter as the Xerces
content+error handler (EndParsingSoftly still unwinds through parse() unchanged).
- Extract StringManager into its own Xerces-free public header (char16_t API;
transcode bodies + doRelease_ specializations move to StringManager.cpp). The
shared/unique_xerces_ptr wrappers and CONST_XMLCH move with it; CONST_XMLCH is
now a plain u"" literal.
- XMLHandler's attribute helpers take XMLAttributes and use char16_t names; parseInt
is delegated to StringManager::parseInt; equal_ uses std::u16string_view compare.
- XMLValidator no longer derives xercesc::ErrorHandler; an internal
XMLValidatorErrorHandler_ bridge (in the .cpp) forwards to it.
- MzMLSpectrumDecoder's private handleBinaryDataArray_ takes void* (cast in .cpp)
instead of xercesc::DOMNode*, dropping the DOM include from its public header.
- MzIdentMLDOMHandler.h and the four Xerces input-source adapter headers are moved
to OpenMS_private_headers (compiled, never installed).
- Internal .cpp that genuinely use Xerces now include it directly; the common
`XMLString::transcode("lit")` statics become compile-time u"lit" literals.
- Drop the two pyOpenMS QcMLFile error/warning(SAXParseException) bindings.
- Update XMLHandler_test (StringManager) to the char16_t API.
Xerces still links PUBLIC (flipped in Phase D). All 26 parser/validator/handler
tests pass.
Co-Authored-By: Claude Fable 5 <[email protected]>
Move XercesC::XercesC (and the macOS CoreFoundation/CoreServices frameworks it needs) from OPENMS_DEP_LIBRARIES to OPENMS_DEP_PRIVATE_LIBRARIES. Xerces is now fully encapsulated: it appears in no installed OpenMS header, so downstream consumers (TOPP tools, GUI, pyOpenMS, third parties) neither include nor link it, while libOpenMS.so still links Xerces internally. The five class tests that exercise the internal Xerces InputSource / BinInputStream adapters directly now link XercesC::XercesC explicitly. Verified: FileInfo (previously pulled Xerces transitively via XMLHandler.h) recompiles with no Xerces include dir on its command line; libOpenMS.so still depends on libxerces-c. Co-Authored-By: Claude Fable 5 <[email protected]>
Address Codex + independent review feedback: - Replace XMLAttributes' SFINAE templated implicit constructor with an explicit XMLAttributes(const void*) ctor (removes the footgun of silently wrapping any type); the sole caller, SAX2HandlerAdapter, now passes &attrs as void*. - Refresh the now-stale UniProtXMLHandler comment that described a local_name fallback removed by the native-callback migration. - Strip trailing whitespace in XMLHandler_test.cpp. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (5)
📝 WalkthroughWalkthroughThis PR adds UTF-16 XML helper types, routes SAX parsing through an adapter, migrates XML handlers and validators to ChangesXerces decoupling and handler migration
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/openms/include/OpenMS/FORMAT/HANDLERS/XQuestResultXMLHandler.h (1)
172-177: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick winStale Doxygen comment still references Xerces.
getLinkPosition_'s parameter type was migrated fromxercesc::AttributestoXMLAttributes, but the doc comment at Line 174 still says@param[in] attributes XML attributes of Xerces.📝 Proposed fix
/** * `@brief` Gets the link location of a xQuest xlinkPositionString. - * `@param`[in] attributes XML attributes of Xerces. + * `@param`[in] attributes XML attributes. * `@param`[out] pair Pair to be populated with the xlinkposition in xQuest. */ void getLinkPosition_(const XMLAttributes & attributes, std::pair<SignedSize, SignedSize> & pair);As per path instructions,
src/openms/include/OpenMS/**/*.hrequires "update relevant documentation when modifying existing functionality."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/include/OpenMS/FORMAT/HANDLERS/XQuestResultXMLHandler.h` around lines 172 - 177, Update the stale Doxygen for getLinkPosition_ in XQuestResultXMLHandler so the `@param`[in] documentation no longer mentions Xerces and instead describes the current XMLAttributes parameter accurately. Keep the comment aligned with the current signature of getLinkPosition_(const XMLAttributes&, std::pair<SignedSize, SignedSize>&) and refresh any related wording in the same block if needed.Source: Path instructions
🧹 Nitpick comments (6)
src/openms/source/FORMAT/HANDLERS/StringManager.cpp (1)
117-159: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueNormalize indentation/brace style in
strLength.This function uses 4-space indentation and same-line opening braces (Lines 119, 134), unlike the 2-space, braces-on-own-line style used elsewhere in this file.
As per coding guidelines: "Use 2-space indentation for C++ code (no tabs)" and "Place opening and closing braces on their own lines".
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/source/FORMAT/HANDLERS/StringManager.cpp` around lines 117 - 159, The strLength function in StringManager.cpp uses inconsistent indentation and brace placement compared with the rest of the file. Update StringManager::strLength to follow the project’s C++ style by converting it to 2-space indentation and moving opening/closing braces onto their own lines, matching the surrounding formatting conventions in the file.Source: Coding guidelines
src/openms/source/FORMAT/HANDLERS/ConsensusXMLHandler.cpp (1)
486-486: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winInconsistent attribute lookup: bypasses
optionalAttributeAsString_used everywhere else in this method.This is the only attribute lookup in
onStartElementthat manually builds achar16_tname viasm_.convert(...).c_str()and callsXMLAttributes::value()directly, instead of theoptionalAttributeAsString_/attributeAsString_helpers used consistently for every other attribute (e.g. lines 143, 209, 337). Worth consolidating for consistency, though this mirrors the pre-existingattributes.getValue(...)pattern that was simply renamed during migration.♻️ Proposed refactor
- const char16_t* refs = attributes.value(sm_.convert("protein_refs").c_str()); - if (refs != nullptr) - { - std::string accession_string = sm_.convert(refs); - StringUtils::trim(accession_string); + std::string accession_string; + if (optionalAttributeAsString_(accession_string, attributes, "protein_refs")) + { + StringUtils::trim(accession_string);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/source/FORMAT/HANDLERS/ConsensusXMLHandler.cpp` at line 486, `ConsensusXMLHandler::onStartElement` has one inconsistent attribute fetch for `protein_refs` that bypasses the `optionalAttributeAsString_` helper used throughout the method. Replace the direct `attributes.value(sm_.convert(...).c_str())` lookup with the same optional string accessor pattern used for the other attributes in `onStartElement`, so the parsing logic stays consistent and centralized.src/openms/include/OpenMS/FORMAT/HANDLERS/SAX2HandlerAdapter.h (1)
46-46: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winType-erased
XMLAttributesconstruction via rawvoid*.
XMLAttributes(static_cast<const void*>(&attrs))discards all type information at the call site; nothing prevents a future caller from wrapping an unrelated pointer with the same constructor. Per the PR description, a follow-up commit already tightensXMLAttributesconstruction — flagging here for visibility since this specific file/commit still uses the loose form.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/include/OpenMS/FORMAT/HANDLERS/SAX2HandlerAdapter.h` at line 46, The `SAX2HandlerAdapter::startElement` call still constructs `XMLAttributes` from a raw `void*`, which keeps the API type-erased at the call site. Update this usage to the stricter `XMLAttributes` construction introduced elsewhere in the PR so the adapter passes a typed attribute object rather than `static_cast<const void*>(&attrs)`. Keep the change localized to the `handler_.onStartElement(...)` invocation in `SAX2HandlerAdapter`.src/openms/source/FORMAT/XTandemXMLFile.cpp (1)
267-270: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winRepeated per-element string conversion for the "z" attribute lookup.
sm_.convert("z")re-transcodes the same literal ASCII attribute name to UTF-16 on every<group type="model">element (once per protein group in the XTandem output, potentially large). Elsewhere in this same function, optional attribute lookups use the higher-leveloptionalAttributeAsUInt_/optionalAttributeAsDouble_helpers that presumably already handle this transcoding internally and more efficiently (e.g. line 150optionalAttributeAsUInt_(count, attributes, ion_count.c_str())).If an
optionalAttributeAsInt_-style helper exists for this case, consider using it instead of the manualindex()/valueByIndex()pattern to avoid the repeated conversion and improve consistency with the rest of the handler.Please confirm whether
Internal::XMLHandler(or its helpers) exposes anoptionalAttributeAsInt_(int&, const XMLAttributes&, const char*)overload analogous tooptionalAttributeAsUInt_, and whetherStringManager::convert()caches/optimizes repeated ASCII→UTF-16 conversions of short literals.♻️ Possible simplification (pending helper availability)
- Int index = attributes.index(sm_.convert("z").c_str()); - if (index >= 0) - { - current_charge_ = StringUtils::toInt32(std::string(sm_.convert(attributes.valueByIndex(index)))); - } + optionalAttributeAsInt_(current_charge_, attributes, "z");🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/source/FORMAT/XTandemXMLFile.cpp` around lines 267 - 270, The manual `attributes.index(sm_.convert("z").c_str())` lookup in `XTandemXMLFile::load` repeats the same ASCII-to-UTF-16 conversion for every model group; replace this pattern with an `optionalAttributeAsInt_`-style helper if `XMLHandler` exposes one, matching the existing `optionalAttributeAsUInt_`/`optionalAttributeAsDouble_` usage in this function. If no such overload exists, add or reuse a helper in `Internal::XMLHandler` to read the `z` attribute directly so the conversion happens once per lookup path and the code stays consistent with the other optional attribute reads.src/openms/source/FORMAT/HANDLERS/FeatureXMLHandler.cpp (1)
592-627: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winHoist the
protein_refsattribute name to a static UTF-16 literal.
sm_.convert("protein_refs").c_str()(Line 602) re-encodes the same string on everyPeptideHitelement, unlike every other attribute/tag lookup in this function which uses a pre-hoistedstatic const char16_t*(e.g.s_name,s_value,s_id). Consider also usingoptionalAttributeAsString_here to match the style used for the siblingaa_before/aa_after/start/endattributes just below, avoiding the manual null check on the rawXMLAttributes::value()pointer.♻️ Proposed fix
// TODO The next line should be removed in OpenMS 1.7 or so! static const char16_t* s_unique_id = u"unique_id"; + static const char16_t* s_protein_refs = u"protein_refs";//parse optional protein ids to determine accessions - const char16_t* refs = attributes.value(sm_.convert("protein_refs").c_str()); + const char16_t* refs = attributes.value(s_protein_refs);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/source/FORMAT/HANDLERS/FeatureXMLHandler.cpp` around lines 592 - 627, The PeptideHit parsing block repeatedly re-encodes the protein_refs attribute name and manually checks the raw attribute pointer, unlike the other lookups in this handler. Hoist the protein_refs key to a static UTF-16 literal near the existing tag/attribute symbols in FeatureXMLHandler::handleStartElement (or the equivalent PeptideHit parsing scope), then use that constant for the lookup and switch to optionalAttributeAsString_ to match the nearby aa_before/aa_after/start/end handling while preserving the current accession parsing and fatalError behavior in the PeptideHit branch.src/openms/source/FORMAT/HANDLERS/MzDataHandler.cpp (1)
240-247: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winHoist
completionTimeinto a static attribute literal. This block converts the same name twice for every<software>element; match the existings_*pattern used for the other attributes.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/source/FORMAT/HANDLERS/MzDataHandler.cpp` around lines 240 - 247, The <software> parsing block in MzDataHandler::load uses repeated conversion of "completionTime" on every element, unlike the existing static attribute pattern. Hoist that attribute name into a static literal alongside the other s_* attribute symbols and reuse it for both the index lookup and value access so the code avoids redundant conversions and matches the surrounding style.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/openms/include/OpenMS/FORMAT/HANDLERS/XMLHandler.h`:
- Around line 231-234: The helper equal_ currently constructs
std::u16string_view directly from its inputs, which will fail on null XMLCh
pointers. Update equal_(const char16_t * a, const char16_t * b) in XMLHandler to
check for null arguments before creating the views, matching the null-safe
behavior of XMLString::compareString. If either pointer is missing, handle that
case explicitly and only compare views when both values are present.
---
Outside diff comments:
In `@src/openms/include/OpenMS/FORMAT/HANDLERS/XQuestResultXMLHandler.h`:
- Around line 172-177: Update the stale Doxygen for getLinkPosition_ in
XQuestResultXMLHandler so the `@param`[in] documentation no longer mentions Xerces
and instead describes the current XMLAttributes parameter accurately. Keep the
comment aligned with the current signature of getLinkPosition_(const
XMLAttributes&, std::pair<SignedSize, SignedSize>&) and refresh any related
wording in the same block if needed.
---
Nitpick comments:
In `@src/openms/include/OpenMS/FORMAT/HANDLERS/SAX2HandlerAdapter.h`:
- Line 46: The `SAX2HandlerAdapter::startElement` call still constructs
`XMLAttributes` from a raw `void*`, which keeps the API type-erased at the call
site. Update this usage to the stricter `XMLAttributes` construction introduced
elsewhere in the PR so the adapter passes a typed attribute object rather than
`static_cast<const void*>(&attrs)`. Keep the change localized to the
`handler_.onStartElement(...)` invocation in `SAX2HandlerAdapter`.
In `@src/openms/source/FORMAT/HANDLERS/ConsensusXMLHandler.cpp`:
- Line 486: `ConsensusXMLHandler::onStartElement` has one inconsistent attribute
fetch for `protein_refs` that bypasses the `optionalAttributeAsString_` helper
used throughout the method. Replace the direct
`attributes.value(sm_.convert(...).c_str())` lookup with the same optional
string accessor pattern used for the other attributes in `onStartElement`, so
the parsing logic stays consistent and centralized.
In `@src/openms/source/FORMAT/HANDLERS/FeatureXMLHandler.cpp`:
- Around line 592-627: The PeptideHit parsing block repeatedly re-encodes the
protein_refs attribute name and manually checks the raw attribute pointer,
unlike the other lookups in this handler. Hoist the protein_refs key to a static
UTF-16 literal near the existing tag/attribute symbols in
FeatureXMLHandler::handleStartElement (or the equivalent PeptideHit parsing
scope), then use that constant for the lookup and switch to
optionalAttributeAsString_ to match the nearby aa_before/aa_after/start/end
handling while preserving the current accession parsing and fatalError behavior
in the PeptideHit branch.
In `@src/openms/source/FORMAT/HANDLERS/MzDataHandler.cpp`:
- Around line 240-247: The <software> parsing block in MzDataHandler::load uses
repeated conversion of "completionTime" on every element, unlike the existing
static attribute pattern. Hoist that attribute name into a static literal
alongside the other s_* attribute symbols and reuse it for both the index lookup
and value access so the code avoids redundant conversions and matches the
surrounding style.
In `@src/openms/source/FORMAT/HANDLERS/StringManager.cpp`:
- Around line 117-159: The strLength function in StringManager.cpp uses
inconsistent indentation and brace placement compared with the rest of the file.
Update StringManager::strLength to follow the project’s C++ style by converting
it to 2-space indentation and moving opening/closing braces onto their own
lines, matching the surrounding formatting conventions in the file.
In `@src/openms/source/FORMAT/XTandemXMLFile.cpp`:
- Around line 267-270: The manual `attributes.index(sm_.convert("z").c_str())`
lookup in `XTandemXMLFile::load` repeats the same ASCII-to-UTF-16 conversion for
every model group; replace this pattern with an `optionalAttributeAsInt_`-style
helper if `XMLHandler` exposes one, matching the existing
`optionalAttributeAsUInt_`/`optionalAttributeAsDouble_` usage in this function.
If no such overload exists, add or reuse a helper in `Internal::XMLHandler` to
read the `z` attribute directly so the conversion happens once per lookup path
and the code stays consistent with the other optional attribute reads.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 04b0747e-3626-43e7-8672-81e93f8ea526
📒 Files selected for processing (83)
src/openms/CMakeLists.txtsrc/openms/include/OpenMS/FORMAT/CVMappingFile.hsrc/openms/include/OpenMS/FORMAT/HANDLERS/ConsensusXMLHandler.hsrc/openms/include/OpenMS/FORMAT/HANDLERS/FeatureXMLHandler.hsrc/openms/include/OpenMS/FORMAT/HANDLERS/ImzMLHandler.hsrc/openms/include/OpenMS/FORMAT/HANDLERS/MascotXMLHandler.hsrc/openms/include/OpenMS/FORMAT/HANDLERS/MzDataHandler.hsrc/openms/include/OpenMS/FORMAT/HANDLERS/MzIdentMLHandler.hsrc/openms/include/OpenMS/FORMAT/HANDLERS/MzMLHandler.hsrc/openms/include/OpenMS/FORMAT/HANDLERS/MzMLSpectrumDecoder.hsrc/openms/include/OpenMS/FORMAT/HANDLERS/MzXMLHandler.hsrc/openms/include/OpenMS/FORMAT/HANDLERS/PTMXMLHandler.hsrc/openms/include/OpenMS/FORMAT/HANDLERS/ParamXMLHandler.hsrc/openms/include/OpenMS/FORMAT/HANDLERS/SAX2HandlerAdapter.hsrc/openms/include/OpenMS/FORMAT/HANDLERS/StringManager.hsrc/openms/include/OpenMS/FORMAT/HANDLERS/ToolDescriptionHandler.hsrc/openms/include/OpenMS/FORMAT/HANDLERS/TraMLHandler.hsrc/openms/include/OpenMS/FORMAT/HANDLERS/UniProtXMLHandler.hsrc/openms/include/OpenMS/FORMAT/HANDLERS/UnimodXMLHandler.hsrc/openms/include/OpenMS/FORMAT/HANDLERS/XMLAttributes.hsrc/openms/include/OpenMS/FORMAT/HANDLERS/XMLHandler.hsrc/openms/include/OpenMS/FORMAT/HANDLERS/XQuestResultXMLHandler.hsrc/openms/include/OpenMS/FORMAT/HANDLERS/sources.cmakesrc/openms/include/OpenMS/FORMAT/IdXMLFile.hsrc/openms/include/OpenMS/FORMAT/OMSSAXMLFile.hsrc/openms/include/OpenMS/FORMAT/PepXMLFile.hsrc/openms/include/OpenMS/FORMAT/PepXMLFileMascot.hsrc/openms/include/OpenMS/FORMAT/ProtXMLFile.hsrc/openms/include/OpenMS/FORMAT/QcMLFile.hsrc/openms/include/OpenMS/FORMAT/TransformationXMLFile.hsrc/openms/include/OpenMS/FORMAT/VALIDATORS/MzMLValidator.hsrc/openms/include/OpenMS/FORMAT/VALIDATORS/SemanticValidator.hsrc/openms/include/OpenMS/FORMAT/VALIDATORS/XMLValidator.hsrc/openms/include/OpenMS/FORMAT/XTandemXMLFile.hsrc/openms/include/OpenMS/FORMAT/sources.cmakesrc/openms/source/FORMAT/Bzip2InputStream.cppsrc/openms/source/FORMAT/CVMappingFile.cppsrc/openms/source/FORMAT/CompressedInputSource.cppsrc/openms/source/FORMAT/GzipInputStream.cppsrc/openms/source/FORMAT/HANDLERS/ConsensusXMLHandler.cppsrc/openms/source/FORMAT/HANDLERS/FeatureXMLHandler.cppsrc/openms/source/FORMAT/HANDLERS/ImzMLHandler.cppsrc/openms/source/FORMAT/HANDLERS/IndexedMzMLDecoder.cppsrc/openms/source/FORMAT/HANDLERS/MascotXMLHandler.cppsrc/openms/source/FORMAT/HANDLERS/MzDataHandler.cppsrc/openms/source/FORMAT/HANDLERS/MzIdentMLDOMHandler.cppsrc/openms/source/FORMAT/HANDLERS/MzIdentMLHandler.cppsrc/openms/source/FORMAT/HANDLERS/MzMLHandler.cppsrc/openms/source/FORMAT/HANDLERS/MzMLSpectrumDecoder.cppsrc/openms/source/FORMAT/HANDLERS/MzXMLHandler.cppsrc/openms/source/FORMAT/HANDLERS/PTMXMLHandler.cppsrc/openms/source/FORMAT/HANDLERS/ParamXMLHandler.cppsrc/openms/source/FORMAT/HANDLERS/StringManager.cppsrc/openms/source/FORMAT/HANDLERS/ToolDescriptionHandler.cppsrc/openms/source/FORMAT/HANDLERS/TraMLHandler.cppsrc/openms/source/FORMAT/HANDLERS/UniProtXMLHandler.cppsrc/openms/source/FORMAT/HANDLERS/UnimodXMLHandler.cppsrc/openms/source/FORMAT/HANDLERS/XMLAttributes.cppsrc/openms/source/FORMAT/HANDLERS/XMLHandler.cppsrc/openms/source/FORMAT/HANDLERS/XQuestResultXMLHandler.cppsrc/openms/source/FORMAT/HANDLERS/sources.cmakesrc/openms/source/FORMAT/IdXMLFile.cppsrc/openms/source/FORMAT/ImzMLFile.cppsrc/openms/source/FORMAT/MascotXMLFile.cppsrc/openms/source/FORMAT/OMSSAXMLFile.cppsrc/openms/source/FORMAT/PepXMLFile.cppsrc/openms/source/FORMAT/PepXMLFileMascot.cppsrc/openms/source/FORMAT/ProtXMLFile.cppsrc/openms/source/FORMAT/QcMLFile.cppsrc/openms/source/FORMAT/TransformationXMLFile.cppsrc/openms/source/FORMAT/UnimodXMLFile.cppsrc/openms/source/FORMAT/VALIDATORS/MzDataValidator.cppsrc/openms/source/FORMAT/VALIDATORS/MzIdentMLValidator.cppsrc/openms/source/FORMAT/VALIDATORS/MzMLValidator.cppsrc/openms/source/FORMAT/VALIDATORS/SemanticValidator.cppsrc/openms/source/FORMAT/VALIDATORS/TraMLValidator.cppsrc/openms/source/FORMAT/VALIDATORS/XMLValidator.cppsrc/openms/source/FORMAT/XMLFile.cppsrc/openms/source/FORMAT/XTandemXMLFile.cppsrc/openms/source/FORMAT/ZipInputStream.cppsrc/pyOpenMS/bindings/bind_misc.cppsrc/tests/class_tests/openms/CMakeLists.txtsrc/tests/class_tests/openms/source/XMLHandler_test.cpp
💤 Files with no reviewable changes (6)
- src/openms/source/FORMAT/VALIDATORS/MzIdentMLValidator.cpp
- src/openms/source/FORMAT/UnimodXMLFile.cpp
- src/openms/source/FORMAT/VALIDATORS/MzDataValidator.cpp
- src/openms/source/FORMAT/VALIDATORS/TraMLValidator.cpp
- src/openms/source/FORMAT/MascotXMLFile.cpp
- src/pyOpenMS/bindings/bind_misc.cpp
- XMLAttributes.h: use @c instead of @ref for XMLAttributes.cpp; a .cpp filename is not a valid Doxygen \ref target, which failed Doxygen_Warning_test on Linux/macOS/clang/arm. - StringManager.cpp: include <cmath> before SIMDe.h; MSVC needs std::isnormal/isnan/... in scope for simde-math.h. The new lean StringManager.h no longer pulls <cmath> transitively, breaking the Windows build and Windows wheel. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…aders Making XercesC PRIVATE removed the accidental propagation of Boost's include directory to consumers. The installed public header config.h includes <boost/current_function.hpp> (via Macros.h), but Boost was a PRIVATE dependency, so its include dir only ever reached consumers by riding on XercesC's (formerly PUBLIC) interface include dir. On the macOS wheel all deps share one vcpkg prefix, so once Xerces went private pyOpenMS could no longer find boost/current_function.hpp; Linux was unaffected because Boost lives in a standard system include path there. Fix the latent bug directly: make the header-only Boost::boost target a PUBLIC dependency so its include dir is exported. Only include dirs propagate (no extra linking); the compiled Boost components (date_time/iostreams/regex) stay PRIVATE. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…onfig Commit 37dbf2b made the header-only Boost::boost target a PUBLIC dependency so the installed config.h can pull in <boost/current_function.hpp>. That correctly exported Boost::boost into OpenMS's INTERFACE_LINK_LIBRARIES, but OpenMSConfig.cmake never ran a find_dependency for Boost, so the imported target was undefined when a consumer configured against the install tree. The pyOpenMS wheel builds (which use NO_DEPENDENCIES=ON) failed at generate time: OpenMSTargets.cmake: The link interface of target "OpenMS" contains: Boost::boost but the target was not found. Add find_dependency(Boost 1.81.0) alongside the existing CURL/XercesC lookups so the header-only Boost::boost target exists before the targets file is included. Only the header-only target is resolved here; the compiled Boost components (date_time/iostreams/regex) remain PRIVATE and are not needed by consumers. Co-Authored-By: Claude Opus 4.8 <[email protected]>
- XMLHandler::equal_: guard null char16_t* pointers before constructing std::u16string_view (u16string_view(nullptr) is UB). Restores the null tolerance of the previous XMLString::compareString (both null => equal, one null => unequal). No current caller passes null (qname is always non-null from Xerces SAX2, the compared literals are constexpr arrays), so this is defensive parity, not a live-bug fix. - Consensus/FeatureXMLHandler: use optionalAttributeAsString_ for the protein_refs lookup instead of a manual value()+convert()+null-check, matching the surrounding attribute accessors (behaviour-identical). - MzDataHandler: fetch completionTime via optionalAttributeAsString_, dropping the redundant index() probe and the double sm_.convert of the attribute name. - XQuestResultXMLHandler: drop the stale "of Xerces" wording in the getLinkPosition_ Doxygen now that it takes XMLAttributes. - StringManager::strLength: normalise to the file's 2-space / own-line brace style. Skipped (with reason): - SAX2HandlerAdapter void* XMLAttributes ctor: the void* handle is the intentional Xerces-free bridge; XMLAttributes exposes no typed ctor. - XTandemXMLFile "z" via optionalAttributeAsInt_: would swap StringUtils::toInt32 for XMLString::parseInt, a parser behaviour change. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
This is also a preparation for the splitting of an OpenMSIO library |
| find_dependency(CURL) | ||
| find_dependency(XercesC) | ||
| # Boost::boost (header-only) is part of OpenMS's PUBLIC link interface because | ||
| # the installed public header config.h includes <boost/current_function.hpp> |
There was a problem hiding this comment.
Ah interesting, I always wondered why!
Could be another cleanup here!
There was a problem hiding this comment.
do you have any idea what a proper cleanup would entail? finding out how it is used and get rid of it?
There was a problem hiding this comment.
The comment tells you how it is used. Current_function is used for the logging. For a compiler independent replacement of __PRETTY_FUNCTION__
We could probably easily handroll something ourselves if that is all that keeps us from also having boost private.
There was a problem hiding this comment.
There was a problem hiding this comment.
it its (of course) again implementation dependent :)
I will create a custom one
There was a problem hiding this comment.
Did the hand-roll in 6f609ff: OPENMS_PRETTY_FUNCTION is now defined directly via __PRETTY_FUNCTION__ (GCC/Clang) / __FUNCSIG__ (MSVC) / __func__ (fallback), and #include <boost/current_function.hpp> is gone from config.h. That's exactly what BOOST_CURRENT_FUNCTION expands to on every compiler we support, so the function-name strings in exceptions/logs are byte-identical. I skipped std::source_location::current().function_name() on purpose — its output is implementation-defined and on GCC/Clang is less detailed than __PRETTY_FUNCTION__, so it would churn exception-message strings (and any references that embed them) for no functional gain.
One caveat though: this on its own does not let us make Boost private. Auditing all installed headers, ~35 public headers still include header-only Boost — MetaInfo.h (boost/container/flat_map), all the METADATA/ID/* (boost/multi_index), MathFunctions.h (boost/math, boost/random), IDBoostGraph.h (boost/graph), plus dynamic_bitset, regex, heap, variant, … Those genuinely need Boost's include dir on the consumer's path, so Boost::boost has to stay a PUBLIC dependency and the find_dependency(Boost) here stays. current_function was just one of many leaks, so this is a nice decoupling of the near-universal config.h rather than the thing that unlocks private Boost.
|
Makes a lot of sense. I like it. I assume the small indirection has miniscule impact on runtime? |
OPENMS_PRETTY_FUNCTION was defined as BOOST_CURRENT_FUNCTION, which forced config.h -- a header included by almost every OpenMS translation unit -- to pull in <boost/current_function.hpp>. Define it directly via the compiler builtins instead: __PRETTY_FUNCTION__ (GCC/Clang), __FUNCSIG__ (MSVC), __func__ as the standard fallback. These are exactly what BOOST_CURRENT_FUNCTION expands to on every compiler OpenMS supports, so the produced function-name strings (which appear in exception messages and logs) are unchanged. This removes one Boost include from the public config header. Note it does NOT make Boost fully private: ~35 other installed public headers still include header-only Boost (multi_index, dynamic_bitset, container/flat_map, math, random, graph, regex, ...), so Boost::boost remains a PUBLIC dependency and find_dependency(Boost) stays in OpenMSConfig.cmake. Verified with a full libOpenMS recompile (config.h touches every TU): builds clean, no translation unit was relying on the transitive Boost include. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Confirmed by tracing the hot path — it's effectively free, and importantly there are no new copies on the data-heavy path. Peak/binary data (the megabyte-scale path) — zero added copies. In sm_.appendASCII(chars, length, bin_data_.back().base64); // SIMD UTF-16→ASCII, direct append
What the indirection actually adds — all O(nanoseconds):
All dwarfed by the XML tokenization + base64 decode + string building that dominate parse time. One costly primitive, kept off the hot path: Pre-existing per-element cost (not from this PR): It could be tightened (a reuse-capacity tag stack behind Happy to run an A/B wall-clock benchmark (develop vs this branch, large mzML load) if we want hard numbers — I'd expect the delta to be in the noise (<1%). |
Adds entries for PRs merged in the last couple of days that were missing changelog coverage: the TOPPView precursor-highlighting feature (#9715), the Xerces-C++ PRIVATE-linkage/XMLHandler API change (#9712, which also supersedes a stale note left by the LibSVM PRIVATE-linkage entry), the FragmentMassError variance fix (#9618), the PepXMLFile duplicate Comet metavalue fix (#9089), and the clang/OpenMP and TextExporter USI documentation additions (#9162, #9173). Co-authored-by: Claude <[email protected]>
…eaders) (#9737) * Make SQLite a fully private dependency (no SQLite type in installed headers) SQLite (via vendored SQLiteCpp) was already PRIVATE-linked, but SQLite types still leaked into installed public headers. This removes every sqlite3 / sqlite3_stmt / SQLite:: reference from the installed header set, so downstream consumers can build and link against libOpenMS without any SQLite headers on their include path. Mirrors the Xerces work in #9712. C API (SqliteConnector + Internal::SqliteHelper): - Pimpl the native handle: sqlite3* db_ -> void* db_, exposed via a doc-hidden void* nativeHandle(). - Move getDB(), the sqlite3*-based static helpers, and the whole Internal::SqliteHelper namespace into a new non-installed include/OpenMS/FORMAT/SqliteConnector_impl.h (registered on OpenMS_private_headers). Add SqliteHelper::getNativeHandle(SqliteConnector&) and a prepareStatement(SqliteConnector&, ...) convenience overload. SQLiteCpp C++ API (SQLite::Database/Statement): - OMSFileStore.h / OMSFileLoad.h are Internal:: helpers; de-install them (move to OpenMS_private_headers). Remove the unused OMSFileLoad.h include from FeatureFinderMetaboIdent.cpp (its only external includer). pyOpenMS-wrapped classes (must stay installed): - MzMLSqliteHandler.h / TransitionPQPFile.h exposed sqlite3* only in private methods -> change the parameter to void* and cast inside the .cpp. - MzMLSqliteSwathHandler.h: drop a stale, unused `struct sqlite3;`. Internal call sites now obtain the raw handle via SqliteHelper::getNativeHandle() and include the private impl header. SqliteConnector_test now covers the public, SQLite-free API only (a consumer test has no <sqlite3.h> on its include path, by design). Verified: libOpenMS + pyOpenMS build clean; 14 SQLite-related class tests pass (SqliteConnector, OSWFile(+Inference), OpenSwath{Export,OSWWriter, PercolatorScoring}, TransitionPQPFile, BrukerTimsImagingFile, MzMLSqlite{Handler,SwathHandler}, OMSFile, SqMassFile, SpectrumAccessSqMass, CachedMzML). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * Reduce void* usage in the SQLite-private headers Follow-up to the previous commit: replace the void* handle parameters that type-hiding introduced with properly typed references, so the installed headers name neither a SQLite type nor a bare void* (down from 9 void* to 1). - MzMLSqliteHandler / TransitionPQPFile: the private helpers now take a SqliteConnector& (a SQLite-type-free type) instead of void*; the native sqlite3* is resolved inside the .cpp via SqliteConnector_impl.h. Callers pass the connection object directly (readExperiment no longer needs a raw db local). - SqliteConnector: drop the public void* nativeHandle() accessor. The one remaining void* is the private db_ member; it is reachable only from the non-installed SqliteConnector_impl.h through a new friend, Internal::SqliteConnectorFriend. (A unique_ptr pimpl would remove even this but would make SqliteConnector move-only; it is kept copyable because OSWFile embeds it by value and declares a defaulted copy ctor.) - SqliteConnector_test: verify a fresh connection is usable functionally (the native handle is now fully private). Verified: libOpenMS builds clean; 9 SQLite-related class tests pass (SqliteConnector, OSWFile(+Inference), OpenSwath{Export,OSWWriter}, TransitionPQPFile, MzMLSqlite{Handler,SwathHandler}, SqMassFile). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
What & why
Makes Xerces-C++ a PRIVATE link dependency of
libOpenMS. PreviouslyXercesC::XercesCwas linked PUBLIC because Xerces types leaked out of installed headers — the SAX handler baseInternal::XMLHandlerderived fromxercesc::DefaultHandler, subclasses overrodestartElement(..., const xercesc::Attributes&), input-source adapters derived fromxercesc::InputSource/BinInputStream, and a few signatures namedxercesc::SAXParseException/DOMNode. As a result every consumer of the OpenMS target (pyOpenMS, the GUI, 29 TOPP tools, class tests, third parties) inherited Xerces on its include and link path.After this PR, Xerces appears in no installed OpenMS header; downstream consumers neither include nor link it, while
libOpenMS.sostill uses Xerces internally. Closes the Xerces part of #8547.How
Xerces is encapsulated behind a Xerces-free public API + an internal bridge:
XMLHandlerno longer derives fromxercesc::DefaultHandler. New native callbacksonStartElement(const char16_t* qname, const XMLAttributes&),onEndElement(const char16_t*),onCharacters(const char16_t*, Size)replace the Xerces SAX callbacks. A new internal, non-installedSAX2HandlerAdapterbridges the Xerces SAX2 interface to these (installed as the content+error handler inXMLFile.cppandImzMLFile.cpp).EndParsingSoftlystill unwinds throughparse()unchanged (adapter overrides are intentionally notnoexcept).XMLAttributes— a new Xerces-free, opaque (void*-backed) view overxercesc::Attributesexposingvalue(name)/index(name)/valueByIndex(i).StringManagerextracted into its own Xerces-free header with achar16_tAPI (transcode bodies +doRelease_specializations moved toStringManager.cpp).CONST_XMLCHis now a plainu""literal.*File/ validator subclasses migrated to the native callbacks (unuseduri/localnamedropped — the SAX parser runs namespace-unaware; the handlers only ever usedqname).XMLValidatorpimpl'd (internalErrorHandlerbridge in the.cpp);MzMLSpectrumDecoder's privatehandleBinaryDataArray_takesvoid*instead ofxercesc::DOMNode*.MzIdentMLDOMHandler.hand the four Xerces input-source adapter headers moved toOpenMS_private_headers(compiled, never installed).XercesC::XercesC(and the macOS CoreFoundation/CoreServices frameworks) moved toOPENMS_DEP_PRIVATE_LIBRARIES. The five class tests that exercise the internal Xerces input-source adapters link Xerces explicitly.QcMLFile.error/warning(SAXParseException)bindings.Commits are split by phase (A: additive native surface → B: migrate subclasses → C: cut the base + secondary leaks → D: flip CMake), each building green, so the diff is reviewable phase-by-phase.
Verification
MzMLFile,MzXMLFile,MzDataFile,FeatureXMLFile,ConsensusXMLFile,IdXMLFile,MzIdentMLFile,TraMLFile,PepXMLFile,XTandemXMLFile,UnimodXMLFile,ParamXMLFile,ImzMLFile,XQuestResultXMLFile,SemanticValidator,MzMLValidator,XMLValidator,MzMLSpectrumDecoder,XMLHandler, and the four input-stream tests (26/26).FileInfo(which transitively includesMzMLFile.hetc.) succeeds with no Xerces include dir on its command line, whileldd libOpenMS.sostill showslibxerces-c. TOPP tools and pyOpenMS build against the cleaned headers.Note
XMLChis assumed to bechar16_t(guaranteed on Xerces-C++ ≥3.2, the supported config; asizeofstatic_assert guards the boundary casts). On a hypotheticalXMLCh = unsigned shortbuild this would be a compile error, not a silent runtime bug.🤖 Generated with Claude Code
Summary by CodeRabbit
errorandwarningmethods from theQcMLFilewrapper.