mupp 1.1.0
Loading...
Searching...
No Matches
PmuppAdminXMLParser Class Reference

XML parser for mupp configuration files. More...

#include <PmuppAdmin.h>

Collaboration diagram for PmuppAdminXMLParser:

Public Member Functions

 PmuppAdminXMLParser (const QString &fln, PmuppAdmin *)
 Constructor that parses the XML configuration file.
 
virtual ~PmuppAdminXMLParser ()
 Destructor.
 
virtual bool isValid ()
 Checks if the XML parsing was successful.
 

Private Types

enum  EAdminKeyWords {
  eEmpty , eRecentFile , eIgnoreThemeAutoDetection , eDarkThemeIconsMenu ,
  eDarkThemeIconsToolbar , eMarker , eColor
}
 Enumeration of recognized XML element types. More...
 

Private Member Functions

bool parse (QIODevice *device)
 Main parsing method that processes the XML document.
 
bool startDocument ()
 Handler for XML document start.
 
bool startElement ()
 Handler for XML element opening tags.
 
bool endElement ()
 Handler for XML element closing tags.
 
bool characters ()
 Handler for XML element text content.
 
bool endDocument ()
 Handler for XML document end.
 

Private Attributes

QXmlStreamReader fXml
 Qt XML stream reader object for parsing.
 
bool fValid
 flag indicating successful XML parsing
 
EAdminKeyWords fKeyWord
 current element type being processed
 
PmuppAdminfAdmin
 pointer to the admin object being populated
 

Detailed Description

XML parser for mupp configuration files.

PmuppAdminXMLParser is responsible for reading and parsing the mupp startup XML file (mupp_startup.xml). This configuration file contains:

  • Recent file history
  • Theme preferences (light/dark mode icons)
  • Plot marker styles and sizes
  • Plot color definitions

The parser uses Qt's QXmlStreamReader for efficient XML processing and populates a PmuppAdmin object with the configuration data.

XML structure handled:

  • <recent_files>: List of recently opened files
  • <ignore_theme_auto_detection>: Theme detection override
  • <dark_theme_icon_menu>: Menu icon theme preference
  • <dark_theme_icon_toolbar>: Toolbar icon theme preference
  • <marker>: Plot marker definitions
  • <color>: RGB color definitions

Definition at line 223 of file PmuppAdmin.h.

Member Enumeration Documentation

◆ EAdminKeyWords

Enumeration of recognized XML element types.

These keywords determine how to process the content of each XML element.

Enumerator
eEmpty 

no specific element being processed

eRecentFile 

recent file path element

eIgnoreThemeAutoDetection 

theme auto-detection override

eDarkThemeIconsMenu 

menu icon theme setting

eDarkThemeIconsToolbar 

toolbar icon theme setting

eMarker 

marker definition element

eColor 

Definition at line 250 of file PmuppAdmin.h.

Constructor & Destructor Documentation

◆ PmuppAdminXMLParser()

PmuppAdminXMLParser::PmuppAdminXMLParser ( const QString & fln,
PmuppAdmin * admin )

Constructor that parses the XML configuration file.

Constructor for XML parser.

Parameters
flnpath to the mupp_startup.xml file
adminpointer to PmuppAdmin object to populate with parsed data

Initializes the XML parser and attempts to open and parse the specified configuration file. The parsed data is stored in the provided PmuppAdmin object.

Parameters
flnpath to the mupp_startup.xml configuration file
adminpointer to the PmuppAdmin instance to populate with parsed data

Definition at line 123 of file PmuppAdmin.cpp.

◆ ~PmuppAdminXMLParser()

virtual PmuppAdminXMLParser::~PmuppAdminXMLParser ( )
inlinevirtual

Destructor.

Definition at line 236 of file PmuppAdmin.h.

Member Function Documentation

◆ characters()

bool PmuppAdminXMLParser::characters ( )
private

Handler for XML element text content.

Handler called to process XML element content.

Returns
true if content is valid, false on error

This method processes the text content between XML opening and closing tags. The content interpretation depends on the current fKeyWord state (set by startElement).

Content processing by element type:

  • eRecentFile: Adds file path to recent files list
  • eIgnoreThemeAutoDetection: Sets theme auto-detection flag (yes/no/true/false)
  • eDarkThemeIconsMenu: Sets menu icon theme preference
  • eDarkThemeIconsToolbar: Sets toolbar icon theme preference
  • eMarker: Parses marker definition (code[,size])
  • eColor: Parses RGB color definition (r,g,b[,name])
Returns
true if content is valid, false on parsing errors

Definition at line 272 of file PmuppAdmin.cpp.

◆ endDocument()

bool PmuppAdminXMLParser::endDocument ( )
private

Handler for XML document end.

Handler called at the end of XML document parsing.

Returns
true if successful

This is invoked when the parser reaches the end of the XML document. Currently performs no post-processing but provides a hook for future finalization tasks such as path expansion or validation.

Returns
always returns true

Definition at line 364 of file PmuppAdmin.cpp.

◆ endElement()

bool PmuppAdminXMLParser::endElement ( )
private

Handler for XML element closing tags.

Handler called when an XML closing tag is encountered.

Returns
true if successful

This method is invoked when the parser encounters a closing XML tag. It resets the fKeyWord state to eEmpty, ending the current element's context for content processing.

Returns
always returns true

Definition at line 247 of file PmuppAdmin.cpp.

◆ isValid()

virtual bool PmuppAdminXMLParser::isValid ( )
inlinevirtual

Checks if the XML parsing was successful.

Returns
true if parsing succeeded, false otherwise

Definition at line 242 of file PmuppAdmin.h.

◆ parse()

bool PmuppAdminXMLParser::parse ( QIODevice * device)
private

Main parsing method that processes the XML document.

Parses the mupp startup XML file.

Parameters
deviceQIODevice containing the XML data to parse
Returns
true if parsing succeeds, false on error

This method uses Qt's QXmlStreamReader to parse the configuration file. It processes each XML element sequentially, calling appropriate handler methods (startElement, characters, endElement) based on the element type.

The parser is event-driven and maintains state through the fKeyWord enumeration to determine how to process element content.

Parameters
deviceQIODevice (typically QFile) containing the XML data
Returns
true if parsing succeeds without errors, false otherwise

Definition at line 151 of file PmuppAdmin.cpp.

◆ startDocument()

bool PmuppAdminXMLParser::startDocument ( )
private

Handler for XML document start.

Handler called at the start of XML document parsing.

Returns
true if successful

This is invoked when the XML parser encounters the document start. Currently performs no actions but provides a hook for future initialization.

Returns
always returns true

Definition at line 191 of file PmuppAdmin.cpp.

◆ startElement()

bool PmuppAdminXMLParser::startElement ( )
private

Handler for XML element opening tags.

Handler called when a new XML element is encountered.

Returns
true if successful

This method is invoked when the parser encounters an opening XML tag. It identifies the element type and sets the fKeyWord state accordingly, which determines how the element's content will be processed in the characters() method.

Recognized elements:

  • path_file_name: Recent file entry
  • ignore_theme_auto_detection: Theme detection override
  • dark_theme_icon_menu: Menu icon theme
  • dark_theme_icon_toolbar: Toolbar icon theme
  • marker: Plot marker definition
  • color: RGB color definition
Returns
always returns true

Definition at line 216 of file PmuppAdmin.cpp.

Member Data Documentation

◆ fAdmin

PmuppAdmin* PmuppAdminXMLParser::fAdmin
private

pointer to the admin object being populated

Definition at line 298 of file PmuppAdmin.h.

◆ fKeyWord

EAdminKeyWords PmuppAdminXMLParser::fKeyWord
private

current element type being processed

Definition at line 297 of file PmuppAdmin.h.

◆ fValid

bool PmuppAdminXMLParser::fValid
private

flag indicating successful XML parsing

Definition at line 296 of file PmuppAdmin.h.

◆ fXml

QXmlStreamReader PmuppAdminXMLParser::fXml
private

Qt XML stream reader object for parsing.

Definition at line 295 of file PmuppAdmin.h.


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