BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
xmlBase::XmlErrorHandler Class Reference

#include <XmlErrorHandler.h>

Inheritance diagram for xmlBase::XmlErrorHandler:

Public Member Functions

 XmlErrorHandler (bool throwErrors=false)
 ~XmlErrorHandler ()
void warning (const SAXParseException &exception)
 Keep count of warnings seen.
void error (const SAXParseException &exception)
 Output row, column of parse error and increment counter.
void fatalError (const SAXParseException &exception)
 Output row, column of fatal parse error and increment counter.
void resetErrors ()
 Clear counters.
int getWarningCount () const
int getErrorCount () const
int getFatalCount () const
 XmlErrorHandler (bool throwErrors=false)
 ~XmlErrorHandler ()
void warning (const SAXParseException &exception)
 Keep count of warnings seen.
void error (const SAXParseException &exception)
 Output row, column of parse error and increment counter.
void fatalError (const SAXParseException &exception)
 Output row, column of fatal parse error and increment counter.
void resetErrors ()
 Clear counters.
int getWarningCount () const
int getErrorCount () const
int getFatalCount () const
 XmlErrorHandler (bool throwErrors=false)
 ~XmlErrorHandler ()
void warning (const SAXParseException &exception)
 Keep count of warnings seen.
void error (const SAXParseException &exception)
 Output row, column of parse error and increment counter.
void fatalError (const SAXParseException &exception)
 Output row, column of fatal parse error and increment counter.
void resetErrors ()
 Clear counters.
int getWarningCount () const
int getErrorCount () const
int getFatalCount () const

Detailed Description

This class handles errors during parsing of an xml file. By default output will go to cerr, but if throwErrors is set to true an exception of type xml::ParseException will be thrown instead

Definition at line 39 of file Calibration/xmlBase/include/xmlBase/XmlErrorHandler.h.

Constructor & Destructor Documentation

◆ XmlErrorHandler() [1/3]

xmlBase::XmlErrorHandler::XmlErrorHandler ( bool throwErrors = false)
inline

Definition at line 42 of file Calibration/xmlBase/include/xmlBase/XmlErrorHandler.h.

42 : m_throwErrors( throwErrors ) {
44 }
void resetErrors()
Clear counters.

◆ ~XmlErrorHandler() [1/3]

xmlBase::XmlErrorHandler::~XmlErrorHandler ( )
inline

◆ XmlErrorHandler() [2/3]

xmlBase::XmlErrorHandler::XmlErrorHandler ( bool throwErrors = false)
inline

Definition at line 42 of file InstallArea/x86_64-el9-gcc13-dbg/include/xmlBase/XmlErrorHandler.h.

42 : m_throwErrors( throwErrors ) {
44 }

◆ ~XmlErrorHandler() [2/3]

xmlBase::XmlErrorHandler::~XmlErrorHandler ( )
inline

◆ XmlErrorHandler() [3/3]

xmlBase::XmlErrorHandler::XmlErrorHandler ( bool throwErrors = false)
inline

Definition at line 42 of file InstallArea/x86_64-el9-gcc13-opt/include/xmlBase/XmlErrorHandler.h.

42 : m_throwErrors( throwErrors ) {
44 }

◆ ~XmlErrorHandler() [3/3]

xmlBase::XmlErrorHandler::~XmlErrorHandler ( )
inline

Member Function Documentation

◆ error() [1/3]

void XmlErrorHandler::error ( const SAXParseException & exception)

Output row, column of parse error and increment counter.

Definition at line 15 of file XmlErrorHandler.cxx.

15 {
16 char* charSyst = XMLString::transcode( toCatch.getSystemId() );
17 std::string systemId( charSyst );
18 // std::string systemId(Dom::transToChar(toCatch.getSystemId()));
19 XMLString::release( &charSyst );
20 char* charMsg = XMLString::transcode( toCatch.getMessage() );
21 std::string msg( charMsg );
22 XMLString::release( &charMsg );
23
24 std::string line;
25 facilities::Util::itoa( (int)toCatch.getLineNumber(), line );
26 std::string col;
27 facilities::Util::itoa( (int)toCatch.getColumnNumber(), col );
28
29 m_nError++;
30
31 std::string errMsg( "Error at file \"" );
32 errMsg += systemId + "\", line " + line + ",column " + col;
33 errMsg += "\n Message: " + msg;
34 if ( m_throwErrors ) { throw ParseException( errMsg ); }
35 else { std::cerr << errMsg << "\n\n"; }
36 }
static const char * itoa(int val, std::string &outStr)

◆ error() [2/3]

void xmlBase::XmlErrorHandler::error ( const SAXParseException & exception)

Output row, column of parse error and increment counter.

◆ error() [3/3]

void xmlBase::XmlErrorHandler::error ( const SAXParseException & exception)

Output row, column of parse error and increment counter.

◆ fatalError() [1/3]

void XmlErrorHandler::fatalError ( const SAXParseException & exception)

Output row, column of fatal parse error and increment counter.

Definition at line 38 of file XmlErrorHandler.cxx.

38 {
39
40 // getMessage returns type XMLCh*
41
42 char* charMsg = XMLString::transcode( toCatch.getMessage() );
43 std::string msg( charMsg );
44 XMLString::release( &charMsg );
45
46 m_nFatal++;
47
48 if ( !( toCatch.getSystemId() ) )
49 {
50 std::string errMsg( "Fatal XML parse error: no such file \n Message: " );
51 errMsg += msg;
52 if ( m_throwErrors ) { throw ParseException( errMsg ); }
53 else { std::cerr << errMsg << "\n\n"; }
54 }
55 else
56 {
57 char* charSyst = XMLString::transcode( toCatch.getSystemId() );
58 std::string systemId( charSyst );
59 XMLString::release( &charSyst );
60
61 std::string line;
62 facilities::Util::itoa( (int)toCatch.getLineNumber(), line );
63 std::string col;
64 facilities::Util::itoa( (int)toCatch.getColumnNumber(), col );
65 std::string errMsg( "Fatal error at file \"" );
66 errMsg += systemId + "\", line " + line + ",column " + col;
67 errMsg += "\n Message: " + msg;
68
69 if ( m_throwErrors ) { throw ParseException( errMsg ); }
70 else { std::cerr << errMsg << "\n\n"; }
71 }
72 }

◆ fatalError() [2/3]

void xmlBase::XmlErrorHandler::fatalError ( const SAXParseException & exception)

Output row, column of fatal parse error and increment counter.

◆ fatalError() [3/3]

void xmlBase::XmlErrorHandler::fatalError ( const SAXParseException & exception)

Output row, column of fatal parse error and increment counter.

◆ getErrorCount() [1/3]

int xmlBase::XmlErrorHandler::getErrorCount ( ) const
inline

Definition at line 59 of file Calibration/xmlBase/include/xmlBase/XmlErrorHandler.h.

59{ return m_nError; }

◆ getErrorCount() [2/3]

int xmlBase::XmlErrorHandler::getErrorCount ( ) const
inline

Definition at line 59 of file InstallArea/x86_64-el9-gcc13-dbg/include/xmlBase/XmlErrorHandler.h.

59{ return m_nError; }

◆ getErrorCount() [3/3]

int xmlBase::XmlErrorHandler::getErrorCount ( ) const
inline

Definition at line 59 of file InstallArea/x86_64-el9-gcc13-opt/include/xmlBase/XmlErrorHandler.h.

59{ return m_nError; }

◆ getFatalCount() [1/3]

int xmlBase::XmlErrorHandler::getFatalCount ( ) const
inline

Definition at line 60 of file Calibration/xmlBase/include/xmlBase/XmlErrorHandler.h.

60{ return m_nFatal; }

◆ getFatalCount() [2/3]

int xmlBase::XmlErrorHandler::getFatalCount ( ) const
inline

Definition at line 60 of file InstallArea/x86_64-el9-gcc13-dbg/include/xmlBase/XmlErrorHandler.h.

60{ return m_nFatal; }

◆ getFatalCount() [3/3]

int xmlBase::XmlErrorHandler::getFatalCount ( ) const
inline

Definition at line 60 of file InstallArea/x86_64-el9-gcc13-opt/include/xmlBase/XmlErrorHandler.h.

60{ return m_nFatal; }

◆ getWarningCount() [1/3]

int xmlBase::XmlErrorHandler::getWarningCount ( ) const
inline

Definition at line 58 of file Calibration/xmlBase/include/xmlBase/XmlErrorHandler.h.

58{ return m_nWarning; }

◆ getWarningCount() [2/3]

int xmlBase::XmlErrorHandler::getWarningCount ( ) const
inline

Definition at line 58 of file InstallArea/x86_64-el9-gcc13-dbg/include/xmlBase/XmlErrorHandler.h.

58{ return m_nWarning; }

◆ getWarningCount() [3/3]

int xmlBase::XmlErrorHandler::getWarningCount ( ) const
inline

Definition at line 58 of file InstallArea/x86_64-el9-gcc13-opt/include/xmlBase/XmlErrorHandler.h.

58{ return m_nWarning; }

◆ resetErrors() [1/3]

void XmlErrorHandler::resetErrors ( )

Clear counters.

Definition at line 73 of file XmlErrorHandler.cxx.

73{ m_nWarning = m_nError = m_nFatal = 0; }

Referenced by XmlErrorHandler().

◆ resetErrors() [2/3]

void xmlBase::XmlErrorHandler::resetErrors ( )

Clear counters.

◆ resetErrors() [3/3]

void xmlBase::XmlErrorHandler::resetErrors ( )

Clear counters.

◆ warning() [1/3]

void XmlErrorHandler::warning ( const SAXParseException & exception)

Keep count of warnings seen.

Definition at line 13 of file XmlErrorHandler.cxx.

13{ m_nWarning++; }

◆ warning() [2/3]

void xmlBase::XmlErrorHandler::warning ( const SAXParseException & exception)

Keep count of warnings seen.

◆ warning() [3/3]

void xmlBase::XmlErrorHandler::warning ( const SAXParseException & exception)

Keep count of warnings seen.


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