musrfit 1.10.0
PXmlRgeHandler Class Reference

XML SAX parser handler for TrimSP configuration files. More...

#include <PRgeHandler.h>

Inheritance diagram for PXmlRgeHandler:
Collaboration diagram for PXmlRgeHandler:

Public Member Functions

 PXmlRgeHandler ()
 Default constructor.
 
virtual ~PXmlRgeHandler ()
 Destructor.
 
virtual void OnStartDocument ()
 Called at start of XML document parsing (SLOT)
 
virtual void OnEndDocument ()
 Called at end of XML document parsing, performs validation (SLOT)
 
virtual void OnStartElement (const char *str, const TList *attributes)
 Called when XML start tag is encountered (SLOT)
 
virtual void OnEndElement (const char *str)
 Called when XML end tag is encountered (SLOT)
 
virtual void OnCharacters (const char *str)
 Called for element content between tags (SLOT)
 
virtual void OnComment (const char *str)
 Called for XML comments (SLOT)
 
virtual void OnWarning (const char *str)
 Called when parser emits a warning (SLOT)
 
virtual void OnError (const char *str)
 Called when parser encounters an error (SLOT)
 
virtual void OnFatalError (const char *str)
 Called when parser encounters a fatal error (SLOT)
 
virtual void OnCdataBlock (const char *str, Int_t len)
 Called for CDATA blocks (SLOT)
 
virtual bool IsValid ()
 Returns validity status of parsed configuration.
 
virtual std::string GetTrimSpDataPath ()
 Returns the TrimSP data directory path.
 
virtual std::string GetTrimSpFlnPre ()
 Returns the RGE filename prefix.
 
virtual const PIntVector GetTrimSpDataVectorList () const
 Returns the list of implantation energies.
 

Private Types

enum  EKeyWords { eEmpty , eDataPath , eFlnPre , eEnergy }
 Enum for tracking which XML element is currently being parsed. More...
 

Private Attributes

EKeyWords fKey
 Current parsing context/state.
 
bool isTrimSp {false}
 True when inside <trim_sp> element.
 
bool fIsValid {true}
 Validity flag (false if parsing errors occur)
 
std::string fTrimSpDataPath {""}
 Directory path to RGE files.
 
std::string fTrimSpFlnPre {""}
 RGE filename prefix (e.g., "LCCO_E" for LCCO_E1000.rge)
 
PIntVector fTrimSpDataEnergyList
 List of implantation energies in eV.
 

Detailed Description

XML SAX parser handler for TrimSP configuration files.

PXmlRgeHandler parses XML configuration files to extract TrimSP (Transport of Ions in Matter) data file locations and parameters. The XML file specifies:

  • Data path: Directory containing .rge files
  • Filename prefix: Base name for RGE files (e.g., "LCCO_E")
  • Energy list: Implantation energies (individual values or start/stop/step)

This handler implements ROOT's TSAXParser callbacks for event-driven XML parsing.

XML Format Example:
<trim_sp>
<data_path>/path/to/rge/files</data_path>
<rge_fln_pre>Material_E</rge_fln_pre>
<energy>1000</energy>
<energy>5000</energy>
<energy_vect start="10000" stop="30000" step="1000"/>
</trim_sp>
See also
PRgeHandler for the main RGE data manager
TSAXParser for ROOT's SAX parser implementation

Definition at line 97 of file PRgeHandler.h.

Member Enumeration Documentation

◆ EKeyWords

Enum for tracking which XML element is currently being parsed.

Enumerator
eEmpty 
eDataPath 
eFlnPre 
eEnergy 

Definition at line 178 of file PRgeHandler.h.

Constructor & Destructor Documentation

◆ PXmlRgeHandler()

PXmlRgeHandler::PXmlRgeHandler ( )
inline

Default constructor.

Definition at line 101 of file PRgeHandler.h.

◆ ~PXmlRgeHandler()

virtual PXmlRgeHandler::~PXmlRgeHandler ( )
inlinevirtual

Destructor.

Definition at line 103 of file PRgeHandler.h.

Member Function Documentation

◆ GetTrimSpDataPath()

virtual std::string PXmlRgeHandler::GetTrimSpDataPath ( )
inlinevirtual

Returns the TrimSP data directory path.

Returns
Directory path containing .rge files

Definition at line 162 of file PRgeHandler.h.

References fTrimSpDataPath.

◆ GetTrimSpDataVectorList()

virtual const PIntVector PXmlRgeHandler::GetTrimSpDataVectorList ( ) const
inlinevirtual

Returns the list of implantation energies.

Returns
Vector of energies in eV

Definition at line 174 of file PRgeHandler.h.

References fTrimSpDataEnergyList.

◆ GetTrimSpFlnPre()

virtual std::string PXmlRgeHandler::GetTrimSpFlnPre ( )
inlinevirtual

Returns the RGE filename prefix.

Returns
Filename prefix (e.g., "LCCO_E" for files like LCCO_E1000.rge)

Definition at line 168 of file PRgeHandler.h.

References fTrimSpFlnPre.

◆ IsValid()

virtual bool PXmlRgeHandler::IsValid ( )
inlinevirtual

Returns validity status of parsed configuration.

Returns
True if XML was parsed successfully and all required fields are present

Definition at line 156 of file PRgeHandler.h.

References fIsValid.

◆ OnCdataBlock()

void PXmlRgeHandler::OnCdataBlock ( const char * str,
Int_t len )
virtual

Called for CDATA blocks (SLOT)

SAX callback invoked for CDATA blocks.

Parameters
strCDATA content
lenLength of CDATA

Currently not used - CDATA blocks are ignored.

Parameters
strCDATA content
lenLength of CDATA content

Definition at line 352 of file PRgeHandler.cpp.

◆ OnCharacters()

void PXmlRgeHandler::OnCharacters ( const char * str)
virtual

Called for element content between tags (SLOT)

SAX callback invoked for text content between XML tags.

Parameters
strCharacter data

Processes the content based on the current parsing state (fKey):

  • eDataPath: Stores the data directory path
  • eFlnPre: Stores the RGE filename prefix
  • eEnergy: Parses integer energy value and adds to energy list

Performs validation and error handling for energy values, ensuring they are valid integers within range.

Parameters
strText content from XML element

Definition at line 236 of file PRgeHandler.cpp.

References eDataPath, eEnergy, eFlnPre, fIsValid, fKey, fTrimSpDataEnergyList, fTrimSpDataPath, fTrimSpFlnPre, and OnError().

◆ OnComment()

void PXmlRgeHandler::OnComment ( const char * str)
virtual

Called for XML comments (SLOT)

SAX callback invoked for XML comments.

Parameters
strComment text

Currently not used - comments are ignored.

Parameters
strComment text

Definition at line 287 of file PRgeHandler.cpp.

◆ OnEndDocument()

void PXmlRgeHandler::OnEndDocument ( )
virtual

Called at end of XML document parsing, performs validation (SLOT)

SAX callback invoked at the end of XML document parsing.

Performs final validation to ensure all required fields were parsed:

  • TrimSP data path must be set
  • RGE filename prefix must be set
  • At least one implantation energy must be specified

Sets fIsValid to false and calls OnError() if any validation fails.

Definition at line 72 of file PRgeHandler.cpp.

References fIsValid, fTrimSpDataEnergyList, fTrimSpDataPath, fTrimSpFlnPre, and OnError().

◆ OnEndElement()

void PXmlRgeHandler::OnEndElement ( const char * str)
virtual

Called when XML end tag is encountered (SLOT)

SAX callback invoked when an XML end tag is encountered.

Parameters
strElement name

Resets the parsing state when leaving the <trim_sp> section and clears the current element key for all end tags.

Parameters
strXML element name

Definition at line 211 of file PRgeHandler.cpp.

References eEmpty, fKey, and isTrimSp.

◆ OnError()

void PXmlRgeHandler::OnError ( const char * str)
virtual

Called when parser encounters an error (SLOT)

SAX callback invoked when the parser encounters an error.

Parameters
strError message

Prints error message to stderr. Called both by the parser and by this handler's own validation code.

Parameters
strError message

Definition at line 319 of file PRgeHandler.cpp.

Referenced by OnCharacters(), OnEndDocument(), and OnStartElement().

◆ OnFatalError()

void PXmlRgeHandler::OnFatalError ( const char * str)
virtual

Called when parser encounters a fatal error (SLOT)

SAX callback invoked when the parser encounters a fatal error.

Parameters
strFatal error message

Prints fatal error message to stderr. Fatal errors typically stop parsing.

Parameters
strFatal error message

Definition at line 335 of file PRgeHandler.cpp.

◆ OnStartDocument()

virtual void PXmlRgeHandler::OnStartDocument ( )
virtual

Called at start of XML document parsing (SLOT)

◆ OnStartElement()

void PXmlRgeHandler::OnStartElement ( const char * str,
const TList * attributes )
virtual

Called when XML start tag is encountered (SLOT)

SAX callback invoked when an XML start tag is encountered.

Parameters
strElement name
attributesElement attributes (used for energy_vect)

Processes recognized elements within the <trim_sp> section:

  • <data_path>: Directory containing RGE files
  • <rge_fln_pre>: RGE filename prefix
  • <energy>: Single implantation energy value
  • <energy_vect>: Energy range with start/stop/step attributes

For <energy_vect>, parses the attributes and generates the energy list. Performs extensive validation on attribute values and ranges.

Parameters
strXML element name
attributesElement attributes (only used for energy_vect)

Definition at line 113 of file PRgeHandler.cpp.

References eDataPath, eEnergy, eFlnPre, fIsValid, fKey, fTrimSpDataEnergyList, isTrimSp, and OnError().

◆ OnWarning()

void PXmlRgeHandler::OnWarning ( const char * str)
virtual

Called when parser emits a warning (SLOT)

SAX callback invoked when the parser emits a warning.

Parameters
strWarning message

Prints warning message to stderr.

Parameters
strWarning message from parser

Definition at line 302 of file PRgeHandler.cpp.

Member Data Documentation

◆ fIsValid

bool PXmlRgeHandler::fIsValid {true}
private

Validity flag (false if parsing errors occur)

Definition at line 182 of file PRgeHandler.h.

Referenced by IsValid(), OnCharacters(), OnEndDocument(), and OnStartElement().

◆ fKey

EKeyWords PXmlRgeHandler::fKey
private

Current parsing context/state.

Definition at line 179 of file PRgeHandler.h.

Referenced by ClassImpQ(), OnCharacters(), OnEndElement(), and OnStartElement().

◆ fTrimSpDataEnergyList

PIntVector PXmlRgeHandler::fTrimSpDataEnergyList
private

List of implantation energies in eV.

Definition at line 186 of file PRgeHandler.h.

Referenced by GetTrimSpDataVectorList(), OnCharacters(), OnEndDocument(), and OnStartElement().

◆ fTrimSpDataPath

std::string PXmlRgeHandler::fTrimSpDataPath {""}
private

Directory path to RGE files.

Definition at line 184 of file PRgeHandler.h.

Referenced by GetTrimSpDataPath(), OnCharacters(), and OnEndDocument().

◆ fTrimSpFlnPre

std::string PXmlRgeHandler::fTrimSpFlnPre {""}
private

RGE filename prefix (e.g., "LCCO_E" for LCCO_E1000.rge)

Definition at line 185 of file PRgeHandler.h.

Referenced by GetTrimSpFlnPre(), OnCharacters(), and OnEndDocument().

◆ isTrimSp

bool PXmlRgeHandler::isTrimSp {false}
private

True when inside <trim_sp> element.

Definition at line 181 of file PRgeHandler.h.

Referenced by OnEndElement(), and OnStartElement().


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