musrfit 1.10.0
PStartupHandler.cpp File Reference
#include <sys/types.h>
#include <sys/stat.h>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <TObjArray.h>
#include <TObjString.h>
#include <TColor.h>
#include <TList.h>
#include <TXMLAttr.h>
#include "PStartupHandler.h"
Include dependency graph for PStartupHandler.cpp:

Go to the source code of this file.

Functions

 ClassImpQ (PStartupHandler) int parseXmlFile(TSAXParser *saxParser
 Replacement for TSAXParser::ParseFile() that uses buffer-based parsing.
 
xmlFile open (startup_path_name, std::ios::in|std::ios::ate)
 
 if (xmlFile.is_open())
 
 if (!xmlBuffer)
 

Variables

const char * startup_path_name
 
std::fstream xmlFile
 
unsigned int xmlSize = 0
 
char * xmlBuffer = nullptr
 
 else
 
return status
 

Function Documentation

◆ ClassImpQ()

ClassImpQ ( PStartupHandler )

Replacement for TSAXParser::ParseFile() that uses buffer-based parsing.

This function provides a workaround for environments where the standard TSAXParser::ParseFile() method fails but ParseBuffer() works correctly. It reads the entire XML file into memory and then parses it as a buffer.

Algorithm:

  1. Open XML file in binary mode, positioned at end to determine size
  2. Allocate buffer for entire file content
  3. Read file into buffer
  4. Close file
  5. Call saxParser->ParseBuffer() with buffer contents
  6. Free buffer memory

Memory Management: The function allocates a buffer equal to the file size, which is freed after parsing completes. For very large XML files, this may consume significant memory temporarily.

Parameters
saxParserPointer to an initialized TSAXParser object. The parser should have its signal slots connected to a handler object (e.g., PStartupHandler) before calling this function.
startup_path_nameFull filesystem path to the XML file to be parsed.
Returns
Parse status code:
  • 0: Success (file parsed without errors)
  • 1: File could not be opened or read
  • Other: XML parse error code from TSAXParser::ParseBuffer()
See also
PStartupHandler for the XML content handler implementation

◆ if() [1/2]

if ( ! xmlBuffer)

Definition at line 98 of file PStartupHandler.cpp.

References if(), status, and xmlBuffer.

◆ if() [2/2]

◆ open()

xmlFile open ( startup_path_name ,
std::ios::in|std::ios::ate  )

References startup_path_name, and xmlFile.

Variable Documentation

◆ else

else
Initial value:
{
status = saxParser->ParseBuffer(xmlBuffer, xmlSize)
char * xmlBuffer
return status
unsigned int xmlSize

Definition at line 100 of file PStartupHandler.cpp.

◆ startup_path_name

const char* startup_path_name

◆ status

◆ xmlBuffer

xmlBuffer = nullptr

Definition at line 88 of file PStartupHandler.cpp.

Referenced by if().

◆ xmlFile

std::fstream xmlFile

Definition at line 86 of file PStartupHandler.cpp.

Referenced by if(), and open().

◆ xmlSize

unsigned int xmlSize = 0

Definition at line 87 of file PStartupHandler.cpp.