ReaderErrorReporter.h
Go to the documentation of this file.
1 #ifndef _utl_ReaderErrorReporter_h_
2 #define _utl_ReaderErrorReporter_h_
3 
4 //#include <xercesc/util/XercesDefs.hpp>
5 //#include <xercesc/util/XMLString.hpp>
6 #include <xercesc/sax/ErrorHandler.hpp>
7 #include <xercesc/sax/SAXParseException.hpp>
8 //#include <iostream>
9 #include <sstream>
10 //#include <string>
11 
12 
13 namespace utl {
14 
23  class ReaderErrorReporter : public xercesc::ErrorHandler {
24  public:
25  void warning(const xercesc::SAXParseException& toCatch) override;
26  void error(const xercesc::SAXParseException& toCatch) override;
27  void fatalError(const xercesc::SAXParseException& toCatch) override;
28  void resetErrors() override;
29 
30  bool getSawErrors() const { return fSawErrors; }
31  const std::ostringstream& getMessages() const { return fMessages; }
32 
33  private:
34  bool fSawErrors = false;
35  std::ostringstream fMessages;
36  };
37 
38 
39  /*inline
40  std::string
41  AsString(const XMLCh* const xmlString)
42  {
43  char* temp = xercesc::XMLString::transcode(xmlString);
44  const std::string str = temp;
45  xercesc::XMLString::release(&temp);
46  return str;
47  }*/
48 
49 
50  /*class XMLChTemporary {
51  public:
52  XMLChTemporary(const std::string& str)
53  : fTemp(xercesc::XMLString::transcode(str.c_str())) { }
54 
55  ~XMLChTemporary() { xercesc::XMLString::release(&fTemp); }
56 
57  XMLCh* operator()() const { return fTemp; }
58 
59  private:
60  XMLChTemporary(const XMLChTemporary&);
61  XMLChTemporary& operator=(const XMLChTemporary&);
62 
63  XMLCh* fTemp = nullptr;
64  };*/
65 
66 }
67 
68 
69 #endif
std::ostringstream fMessages
void warning(const xercesc::SAXParseException &toCatch) override
void error(const xercesc::SAXParseException &toCatch) override
Collect errors during XML parsing.
void fatalError(const xercesc::SAXParseException &toCatch) override
const std::ostringstream & getMessages() const
Reports errors encountered during XML parsing.

, generated on Tue Sep 26 2023.