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

XML parser for the musredit configuration file. More...

#include <PAdmin.h>

Collaboration diagram for PAdminXMLParser:

Public Member Functions

 PAdminXMLParser (const QString &fln, PAdmin *)
 Constructs an XML parser for the musredit configuration file.
 
virtual bool isValid ()
 Check if the XML file was parsed successfully.
 

Private Types

enum  EAdminKeyWords {
  eEmpty , eTimeout , eKeepMinuit2Output , eDumpAscii ,
  eDumpRoot , eTitleFromDataFile , eChisqPreRunBlock , eEstimateN0 ,
  eYamlOut , eNoOfTreadsToBeUsed , eMusrviewShowFourier , eMusrviewShowAvg ,
  eMusrviewShowOneToOne , eEnableMusrT0 , eIgnoreThemeAutoDetection , eDarkThemeIconsMenu ,
  eDarkThemeIconsToolbar , eEditW , eEditH , eFontName ,
  eFontSize , eExecPath , eDefaultSavePath , eRecentFile ,
  eBeamline , eInstitute , eFileFormat , eLifetimeCorrection ,
  eTheoFuncPixmapPath , eFunc , eFuncName , eFuncComment ,
  eFuncLabel , eFuncPixmap , eFuncParams , eHelpMain ,
  eHelpTitle , eHelpParameters , eHelpTheory , eHelpFunctions ,
  eHelpRun , eHelpCommand , eHelpFourier , eHelpPlot ,
  eHelpStatistic , eHelpMsr2Data , eHelpMusrFT , eChainFit ,
  eWriteDataHeader , eIgnoreDataHeaderInfo , eWriteColumnData , eRecreateDataFile ,
  eOpenFileAfterFitting , eCreateMsrFileOnly , eFitOnly , eGlobal ,
  eGlobalPlus
}
 Enumeration of XML element keywords recognized by the parser. More...
 

Private Member Functions

bool parse (QIODevice *device)
 Parse the XML configuration file.
 
bool startDocument ()
 Handler called at the beginning 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 character data (element content).
 
bool endDocument ()
 Handler called at the end of XML document parsing.
 
void dump ()
 Dump all configuration values to stdout for debugging.
 
QString expandPath (const QString &)
 Expand environment variables in a path string.
 

Private Attributes

QXmlStreamReader fXml
 Qt XML stream reader for parsing the configuration file.
 
bool fValid
 Flag indicating whether XML parsing completed successfully.
 
EAdminKeyWords fKeyWord
 Current XML element being processed.
 
bool fFunc
 Flag indicating parser is inside a <func> element block.
 
PTheory fTheoryItem
 Temporary storage for theory function data during parsing.
 
PAdminfAdmin
 Pointer to the PAdmin object being populated with configuration data.
 

Detailed Description

XML parser for the musredit configuration file.

This class implements an XML parser using Qt's QXmlStreamReader to parse the musredit_startup.xml configuration file. The parser extracts all settings and populates a PAdmin object with the configuration data.

The XML file structure includes sections for:

  • General settings (timeout, paths, font preferences)
  • Recent files list
  • Help URL mappings
  • MSR file defaults (beamline, institute, file format)
  • msr2data default parameters
  • Theory function definitions
Usage Example:
PAdmin admin;
PAdminXMLParser parser("musredit_startup.xml", &admin);
if (parser.isValid()) {
// Configuration loaded successfully
}
PAdminXMLParser(const QString &fln, PAdmin *)
Constructs an XML parser for the musredit configuration file.
Definition PAdmin.cpp:81
Central administration class for musredit configuration management.
Definition PAdmin.h:209
See also
PAdmin The administration class that stores parsed configuration

Definition at line 127 of file PAdmin.h.

Member Enumeration Documentation

◆ EAdminKeyWords

Enumeration of XML element keywords recognized by the parser.

Each enum value corresponds to an XML element tag in the configuration file. The parser uses these to determine how to process element content.

Enumerator
eEmpty 
eTimeout 
eKeepMinuit2Output 
eDumpAscii 
eDumpRoot 
eTitleFromDataFile 
eChisqPreRunBlock 
eEstimateN0 
eYamlOut 
eNoOfTreadsToBeUsed 
eMusrviewShowFourier 
eMusrviewShowAvg 
eMusrviewShowOneToOne 
eEnableMusrT0 
eIgnoreThemeAutoDetection 
eDarkThemeIconsMenu 
eDarkThemeIconsToolbar 
eEditW 
eEditH 
eFontName 
eFontSize 
eExecPath 
eDefaultSavePath 
eRecentFile 
eBeamline 
eInstitute 
eFileFormat 
eLifetimeCorrection 
eTheoFuncPixmapPath 
eFunc 
eFuncName 
eFuncComment 
eFuncLabel 
eFuncPixmap 
eFuncParams 
eHelpMain 
eHelpTitle 
eHelpParameters 
eHelpTheory 
eHelpFunctions 
eHelpRun 
eHelpCommand 
eHelpFourier 
eHelpPlot 
eHelpStatistic 
eHelpMsr2Data 
eHelpMusrFT 
eChainFit 
eWriteDataHeader 
eIgnoreDataHeaderInfo 
eWriteColumnData 
eRecreateDataFile 
eOpenFileAfterFitting 
eCreateMsrFileOnly 
eFitOnly 
eGlobal 
eGlobalPlus 

Definition at line 145 of file PAdmin.h.

Constructor & Destructor Documentation

◆ PAdminXMLParser()

PAdminXMLParser::PAdminXMLParser ( const QString & fln,
PAdmin * admin )

Constructs an XML parser for the musredit configuration file.

Creates a parser instance and immediately parses the specified XML file. If the file is missing or corrupted, the user is prompted to create a default configuration file. After parsing completes, the validity can be checked using the isValid() method.

Parameters
flnFull path to the musredit_startup.xml configuration file.
adminPointer to the PAdmin object that will be populated with parsed data.
Note
If the configuration file cannot be opened or is empty, a warning dialog is displayed offering to create a default configuration file.

Definition at line 81 of file PAdmin.cpp.

Member Function Documentation

◆ characters()

bool PAdminXMLParser::characters ( )
private

Handler for XML character data (element content).

Processes the text content of the current XML element based on the previously set keyword from startElement(). Routes the content to the appropriate PAdmin setter method or stores it in the temporary theory item structure when parsing function definitions.

Boolean values in the XML use "y" for true and any other value for false.

Returns
true on successful processing, false if a required conversion fails (e.g., invalid integer in params element).

Definition at line 340 of file PAdmin.cpp.

◆ dump()

void PAdminXMLParser::dump ( )
private

Dump all configuration values to stdout for debugging.

Outputs the complete contents of the PAdmin object to standard output in a human-readable format. This includes general settings, recent files, help URLs, font settings, MSR file defaults, msr2data parameters, and all registered theory functions.

Note
This method is intended for debugging purposes only and is typically disabled in production builds.

Definition at line 700 of file PAdmin.cpp.

◆ endDocument()

bool PAdminXMLParser::endDocument ( )
private

Handler called at the end of XML document parsing.

Performs post-processing after all XML elements have been parsed. Expands any environment variables (e.g., $HOME, $ROOTSYS) found in path settings to their full directory paths.

Returns
Always returns true.
See also
expandPath() For the environment variable expansion implementation.

Definition at line 659 of file PAdmin.cpp.

◆ endElement()

bool PAdminXMLParser::endElement ( )
private

Handler called when an XML end element is encountered.

Resets the current keyword to eEmpty after element processing completes. For </func> end tags, finalizes the theory item by adding it to the PAdmin's theory collection and resetting the function parsing flag.

Returns
Always returns true.

Definition at line 312 of file PAdmin.cpp.

◆ expandPath()

QString PAdminXMLParser::expandPath ( const QString & str)
private

Expand environment variables in a path string.

Parses the input path and replaces any environment variable references (prefixed with $) with their actual values from the system environment. For example, $HOME/documents becomes /home/user/documents.

Parameters
strPath string potentially containing environment variable references.
Returns
The expanded path string with all environment variables resolved. Returns an empty string if any referenced variable is not found or empty.
Note
Displays a warning dialog if an environment variable cannot be resolved.

Definition at line 795 of file PAdmin.cpp.

◆ isValid()

virtual bool PAdminXMLParser::isValid ( )
inlinevirtual

Check if the XML file was parsed successfully.

Returns
true if parsing was successful, false otherwise.

Definition at line 136 of file PAdmin.h.

◆ parse()

bool PAdminXMLParser::parse ( QIODevice * device)
private

Parse the XML configuration file.

Reads and processes the musredit_startup.xml file using Qt's QXmlStreamReader. The parser processes elements sequentially, calling appropriate handler methods for start elements, character data, and end elements.

Parameters
deviceQIODevice (typically QFile) opened for reading the XML file.
Returns
true if parsing completed without XML errors, false otherwise. On failure, an error dialog is displayed with line/column information.

Definition at line 112 of file PAdmin.cpp.

◆ startDocument()

bool PAdminXMLParser::startDocument ( )
private

Handler called at the beginning of XML document parsing.

This method is invoked when the XML parser encounters the start of the document. Currently performs no initialization as all state is set up in the constructor.

Returns
Always returns true.

Definition at line 153 of file PAdmin.cpp.

◆ startElement()

bool PAdminXMLParser::startElement ( )
private

Handler called when an XML start element is encountered.

Maps the XML element name to an internal keyword enumeration (EAdminKeyWords) for subsequent character data processing. Also handles initialization of the PTheory structure when a <func> element begins.

Returns
Always returns true.
See also
EAdminKeyWords For the list of recognized XML element tags.

Definition at line 171 of file PAdmin.cpp.

Member Data Documentation

◆ fAdmin

PAdmin* PAdminXMLParser::fAdmin
private

Pointer to the PAdmin object being populated with configuration data.

Definition at line 173 of file PAdmin.h.

◆ fFunc

bool PAdminXMLParser::fFunc
private

Flag indicating parser is inside a <func> element block.

Definition at line 171 of file PAdmin.h.

◆ fKeyWord

EAdminKeyWords PAdminXMLParser::fKeyWord
private

Current XML element being processed.

Definition at line 170 of file PAdmin.h.

◆ fTheoryItem

PTheory PAdminXMLParser::fTheoryItem
private

Temporary storage for theory function data during parsing.

Definition at line 172 of file PAdmin.h.

◆ fValid

bool PAdminXMLParser::fValid
private

Flag indicating whether XML parsing completed successfully.

Definition at line 169 of file PAdmin.h.

◆ fXml

QXmlStreamReader PAdminXMLParser::fXml
private

Qt XML stream reader for parsing the configuration file.

Definition at line 168 of file PAdmin.h.


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