musredit 1.0.0
Loading...
Searching...
No Matches
PDefaultPathsXMLParser Class Reference

XML parser for extracting default data paths from configuration. More...

#include <PChangeDefaultPathsDialog.h>

Collaboration diagram for PDefaultPathsXMLParser:

Public Member Functions

 PDefaultPathsXMLParser (const QString &fln, PDefaultPaths *defaultPaths)
 Constructs an XML parser for reading default data paths.
 
virtual ~PDefaultPathsXMLParser ()
 Virtual destructor.
 
virtual bool isValid ()
 Check if the XML file was parsed successfully.
 

Private Types

enum  EAdminKeyWords { eEmpty , eDataPath }
 Keywords for identifying XML elements during parsing. More...
 

Private Member Functions

bool parse (QIODevice *device)
 Parse the XML configuration file for data paths.
 
bool startDocument ()
 Handler called at the start of XML document parsing.
 
bool startElement ()
 Handler called when an XML start element is encountered.
 
bool endElement ()
 Handler called when an XML end element is encountered.
 
bool characters ()
 Handler for XML element character content.
 
bool endDocument ()
 Handler called at the end of XML document parsing.
 

Private Attributes

QXmlStreamReader fXml
 Qt XML stream reader for parsing.
 
bool fValid
 Flag indicating successful parsing.
 
EAdminKeyWords fKeyWord
 Current element type being processed.
 
PDefaultPathsfDefaultPaths
 Pointer to the object storing parsed paths.
 

Detailed Description

XML parser for extracting default data paths from configuration.

This class parses the musrfit_startup.xml configuration file to extract the <data_path> elements that define default search directories for muon data files. The parser uses Qt's QXmlStreamReader for efficient streaming XML parsing.

XML Format:
The parser expects elements in the form:
<data_path>/path/to/data/directory</data_path>
See also
PDefaultPaths The class that stores the parsed paths

Definition at line 83 of file PChangeDefaultPathsDialog.h.

Member Enumeration Documentation

◆ EAdminKeyWords

Keywords for identifying XML elements during parsing.

Enumerator
eEmpty 

No element currently being processed.

eDataPath 

Processing a <data_path> element.

Definition at line 104 of file PChangeDefaultPathsDialog.h.

Constructor & Destructor Documentation

◆ PDefaultPathsXMLParser()

PDefaultPathsXMLParser::PDefaultPathsXMLParser ( const QString & fln,
PDefaultPaths * defaultPaths )

Constructs an XML parser for reading default data paths.

Opens and parses the specified XML configuration file to extract <data_path> elements. The parsed paths are stored in the provided PDefaultPaths object. After construction, call isValid() to check if parsing succeeded.

Parameters
flnFull path to the musrfit_startup.xml configuration file.
defaultPathsPointer to the PDefaultPaths object to populate with parsed paths.

Definition at line 70 of file PChangeDefaultPathsDialog.cpp.

◆ ~PDefaultPathsXMLParser()

virtual PDefaultPathsXMLParser::~PDefaultPathsXMLParser ( )
inlinevirtual

Virtual destructor.

Definition at line 91 of file PChangeDefaultPathsDialog.h.

Member Function Documentation

◆ characters()

bool PDefaultPathsXMLParser::characters ( )
private

Handler for XML element character content.

Processes the text content of the current XML element. If the current element is a <data_path>, the content (directory path) is appended to the PDefaultPaths object.

Returns
Always returns true.

Definition at line 191 of file PChangeDefaultPathsDialog.cpp.

◆ endDocument()

bool PDefaultPathsXMLParser::endDocument ( )
private

Handler called at the end of XML document parsing.

This method is invoked when the parser reaches the end of the XML document. Currently performs no post-processing.

Returns
Always returns true.

Definition at line 217 of file PChangeDefaultPathsDialog.cpp.

◆ endElement()

bool PDefaultPathsXMLParser::endElement ( )
private

Handler called when an XML end element is encountered.

Resets the keyword flag to eEmpty after finishing processing of an element.

Returns
Always returns true.

Definition at line 174 of file PChangeDefaultPathsDialog.cpp.

◆ isValid()

virtual bool PDefaultPathsXMLParser::isValid ( )
inlinevirtual

Check if the XML file was parsed successfully.

Returns
true if parsing succeeded, false otherwise.

Definition at line 97 of file PChangeDefaultPathsDialog.h.

◆ parse()

bool PDefaultPathsXMLParser::parse ( QIODevice * device)
private

Parse the XML configuration file for data paths.

Reads the XML file using Qt's QXmlStreamReader, processing elements sequentially. Recognized <data_path> elements have their content extracted and added to the associated PDefaultPaths object.

Parameters
deviceQIODevice (typically a QFile) opened for reading.
Returns
true if parsing completed without XML errors, false otherwise. On error, displays a message box with error details including line and column numbers.

Definition at line 98 of file PChangeDefaultPathsDialog.cpp.

◆ startDocument()

bool PDefaultPathsXMLParser::startDocument ( )
private

Handler called at the start of XML document parsing.

This method is invoked when the parser encounters the beginning of the XML document. Currently performs no initialization.

Returns
Always returns true.

Definition at line 138 of file PChangeDefaultPathsDialog.cpp.

◆ startElement()

bool PDefaultPathsXMLParser::startElement ( )
private

Handler called when an XML start element is encountered.

Sets the internal keyword flag based on the element name. Currently only recognizes <data_path> elements; all other elements are ignored.

Returns
Always returns true.

Definition at line 154 of file PChangeDefaultPathsDialog.cpp.

Member Data Documentation

◆ fDefaultPaths

PDefaultPaths* PDefaultPathsXMLParser::fDefaultPaths
private

Pointer to the object storing parsed paths.

Definition at line 119 of file PChangeDefaultPathsDialog.h.

◆ fKeyWord

EAdminKeyWords PDefaultPathsXMLParser::fKeyWord
private

Current element type being processed.

Definition at line 118 of file PChangeDefaultPathsDialog.h.

◆ fValid

bool PDefaultPathsXMLParser::fValid
private

Flag indicating successful parsing.

Definition at line 117 of file PChangeDefaultPathsDialog.h.

◆ fXml

QXmlStreamReader PDefaultPathsXMLParser::fXml
private

Qt XML stream reader for parsing.

Definition at line 116 of file PChangeDefaultPathsDialog.h.


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