OpenMS
Loading...
Searching...
No Matches
XMLAttributes Class Reference

Xerces-free, lightweight view over the attribute list of an XML element. More...

#include <OpenMS/FORMAT/HANDLERS/XMLAttributes.h>

Collaboration diagram for XMLAttributes:
[legend]

Public Member Functions

 XMLAttributes (const XMLAttributes &)=default
 
XMLAttributesoperator= (const XMLAttributes &)=default
 
 XMLAttributes (const void *attributes) noexcept
 Wrap a live attribute list (non-owning).
 
const char16_t * value (const char16_t *qname) const
 Value of the attribute named qname (UTF-16 code units), or nullptr if absent.
 
const char16_t * value (const char *qname) const
 Value of the attribute named qname (narrow name, transcoded internally), or nullptr if absent.
 
SignedSize index (const char16_t *qname) const
 Index of the attribute named qname, or a negative value if absent.
 
const char16_t * valueByIndex (Size i) const
 Value of the attribute at position i (UTF-16 code units).
 
const void * handle () const noexcept
 Opaque handle to the underlying attribute list (libOpenMS-internal use).
 

Private Attributes

const void * attributes_
 

Detailed Description

Xerces-free, lightweight view over the attribute list of an XML element.

Wraps a live xercesc::Attributes (owned by the SAX parser and valid only for the duration of the startElement callback). It exposes only the small surface the OpenMS handlers actually use (value-by-name, index-by-name, value-by-index), so that Xerces types never appear in a public header.

The underlying attribute list is held as an opaque pointer, so this header pulls in no Xerces declarations — consumers of libOpenMS need Xerces neither on their include path nor at link time. The accessor implementations (in XMLAttributes.cpp) recover the concrete Xerces type internally.

The wrapper is a non-owning view: it stores a pointer to the parser-owned attribute list and must not outlive the callback it was created for.

Constructor & Destructor Documentation

◆ XMLAttributes() [1/2]

XMLAttributes ( const XMLAttributes )
default

◆ XMLAttributes() [2/2]

XMLAttributes ( const void *  attributes)
inlineexplicitnoexcept

Wrap a live attribute list (non-owning).

Takes an opaque handle so this header need not name any Xerces type. The only caller is the internal SAX2HandlerAdapter, which passes the address of the live xercesc::Attributes (recovered internally in XMLAttributes.cpp).

Member Function Documentation

◆ handle()

const void * handle ( ) const
inlinenoexcept

Opaque handle to the underlying attribute list (libOpenMS-internal use).

◆ index()

SignedSize index ( const char16_t *  qname) const

Index of the attribute named qname, or a negative value if absent.

◆ operator=()

XMLAttributes & operator= ( const XMLAttributes )
default

◆ value() [1/2]

const char16_t * value ( const char *  qname) const

Value of the attribute named qname (narrow name, transcoded internally), or nullptr if absent.

◆ value() [2/2]

◆ valueByIndex()

const char16_t * valueByIndex ( Size  i) const

Value of the attribute at position i (UTF-16 code units).

Member Data Documentation

◆ attributes_

const void* attributes_
private