Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::XML2EventParser Class Reference

Generates a list of InteractionEvents by parsing an XML file. More...

#include <mitkXML2EventParser.h>

Inheritance diagram for mitk::XML2EventParser:
Collaboration diagram for mitk::XML2EventParser:

Public Types

typedef std::vector< mitk::InteractionEvent::Pointer > EventContainerType
 Container type for the parsed interaction events. More...
 

Public Member Functions

 XML2EventParser (const std::string &filename, const us::Module *module=nullptr)
 Construct an InteractionEventList object from an XML resource file. More...
 
 XML2EventParser (std::istream &inputStream)
 Construct an InteractionEventList object from an input stream. More...
 
EventContainerType GetInteractions ()
 Get the list of parsed interaction events. More...
 
 ~XML2EventParser () override
 Destructor. More...
 

Protected Member Functions

void StartElement (const char *elementName, const char **atts) override
 Handle the start of an XML element during parsing. More...
 
void EndElement (const char *elementName) override
 Handle the end of an XML element during parsing. More...
 
std::string ReadXMLStringAttribute (const std::string &name, const char **atts)
 Read a string attribute value from the XML attribute array. More...
 
bool ReadXMLBooleanAttribute (const std::string &name, const char **atts)
 Read a boolean attribute value from the XML attribute array. More...
 

Detailed Description

Generates a list of InteractionEvents by parsing an XML file.

Reads an XML event configuration file and constructs a list of InteractionEvent objects that can be used for interaction testing.

See also
EventRecorder

Definition at line 41 of file mitkXML2EventParser.h.

Member Typedef Documentation

◆ EventContainerType

typedef std::vector<mitk::InteractionEvent::Pointer> mitk::XML2EventParser::EventContainerType

Container type for the parsed interaction events.

Definition at line 68 of file mitkXML2EventParser.h.

Constructor & Destructor Documentation

◆ XML2EventParser() [1/2]

mitk::XML2EventParser::XML2EventParser ( const std::string &  filename,
const us::Module *  module = nullptr 
)

Construct an InteractionEventList object from an XML resource file.

Uses the specified resource file containing an XML event configuration to construct the event list. If the resource is invalid, no events are created.

Parameters
[in]filenameThe resource name relative to the Interactions resource folder.
[in]moduleThe module from which to load the resource. If nullptr, the current module context is used.

◆ XML2EventParser() [2/2]

mitk::XML2EventParser::XML2EventParser ( std::istream &  inputStream)

Construct an InteractionEventList object from an input stream.

Uses the specified input stream containing XML event configuration data to construct the event list. If the stream contains invalid XML, no events are created and an error is logged.

Parameters
[in]inputStreamInput stream referring to XML configuration data.

◆ ~XML2EventParser()

mitk::XML2EventParser::~XML2EventParser ( )
inlineoverride

Destructor.

Definition at line 78 of file mitkXML2EventParser.h.

Member Function Documentation

◆ EndElement()

void mitk::XML2EventParser::EndElement ( const char *  elementName)
overrideprotected

Handle the end of an XML element during parsing.

When an event variant element ends, the collected properties are used to create an InteractionEvent and add it to the list.

Parameters
[in]elementNameName of the XML element.

◆ GetInteractions()

EventContainerType mitk::XML2EventParser::GetInteractions ( )
inline

Get the list of parsed interaction events.

Returns
A copy of the container with all parsed InteractionEvent objects.

Definition at line 75 of file mitkXML2EventParser.h.

◆ ReadXMLBooleanAttribute()

bool mitk::XML2EventParser::ReadXMLBooleanAttribute ( const std::string &  name,
const char **  atts 
)
protected

Read a boolean attribute value from the XML attribute array.

The attribute is compared case-insensitively against "TRUE".

Parameters
[in]nameThe attribute name to look for.
[in]attsNull-terminated array of attribute name/value pairs.
Returns
True if the attribute value is "TRUE" (case-insensitive), false otherwise.

◆ ReadXMLStringAttribute()

std::string mitk::XML2EventParser::ReadXMLStringAttribute ( const std::string &  name,
const char **  atts 
)
protected

Read a string attribute value from the XML attribute array.

Parameters
[in]nameThe attribute name to look for.
[in]attsNull-terminated array of attribute name/value pairs.
Returns
The attribute value, or an empty string if not found.

◆ StartElement()

void mitk::XML2EventParser::StartElement ( const char *  elementName,
const char **  atts 
)
overrideprotected

Handle the start of an XML element during parsing.

Parameters
[in]elementNameName of the XML element.
[in]attsNull-terminated array of attribute name/value pairs.

The documentation for this class was generated from the following file: