#include <SAX2Handler.h>
Public Member Functions | |
| SAX2Handler () | |
| SAX2 handler for MIPP XML data. | |
| virtual | ~SAX2Handler () |
| virtual void | StartElement (const std::string &uri, const std::string &localname, const std::string &qname, const AttributeList &attrs) |
| virtual void | Characters (const std::string &chars) |
| virtual void | EndElement (const std::string &uri, const std::string &localname, const std::string &qname) |
Private Attributes | |
| std::string | fUri |
| Tag "universal reference". | |
| std::string | fLocalName |
| Local name of tag. | |
| std::string | fQname |
| Qualified name of tag. | |
| std::vector< Attribute > | fAttributes |
| Set of tag attributes. | |
| std::string | fCharacters |
| Text buffer. | |
| int | fCount |
| Count begin/end tag events. | |
This class is used to hold the state of parsing between the startElement and endElement calls
Definition at line 19 of file SAX2Handler.h.
|
|
SAX2 handler for MIPP XML data.
Definition at line 14 of file SAX2Handler.cxx.
00014 : 00015 fUri (""), 00016 fLocalName (""), 00017 fQname (""), 00018 fCharacters(""), 00019 fCount (0 ) 00020 { } |
|
|
Definition at line 24 of file SAX2Handler.cxx. References fCount, fLocalName, and xmli::Parser::GetCurrentSource().
00025 {
00026 // Check that the begin and end tag counts match
00027 if (fCount>0) {
00028 std::cerr << "xmli::SAX2Handler::" << __LINE__
00029 << " Tag '" << fLocalName << "' not closed "
00030 << " in " << xmli::Parser::GetCurrentSource()
00031 << " (count = " << fCount << ")"
00032 << std::endl;
00033 abort();
00034 }
00035 if (fCount<0) {
00036 std::cerr << "xmli::SAX2Handler::" << __LINE__
00037 << " Tag '" << fLocalName << "' closed but not openned"
00038 << " in " << xmli::Parser::GetCurrentSource()
00039 << " (count = " << fCount << ")"
00040 << std::endl;
00041 abort();
00042 }
00043 }
|
|
|
Definition at line 73 of file SAX2Handler.cxx. References fCharacters. Referenced by xmli::SAX2DefaultHandler::characters().
00074 {
00075 //======================================================================
00076 // Spool the characters inside the element to the local buffer
00077 //======================================================================
00078 // std::cerr << "[Charaters] " << chars << std::endl;
00079 fCharacters += chars;
00080 }
|
|
||||||||||||||||
|
Definition at line 84 of file SAX2Handler.cxx. References xmli::Builder::Build(), fAttributes, fCharacters, fCount, fLocalName, fQname, fUri, xmli::BuilderFac::Get(), xmli::Parser::GetCurrentSource(), and xmli::BuilderFac::Instance(). Referenced by xmli::SAX2DefaultHandler::endElement().
00087 {
00088 //======================================================================
00089 // Handle the end tag
00090 //======================================================================
00091
00092 // These better match what we saw in the StartElement or we're in
00093 // big trouble
00094 if (uri != fUri) abort();
00095 if (localname != fLocalName) abort();
00096 if (qname != fQname) abort();
00097 --fCount;
00098
00099 // Check if there is a builder defined for this tag. If yes, pass
00100 // the accumulated data off to the builder
00101 xmli::Builder* b = xmli::BuilderFac::Instance().Get(localname);
00102 if (b) b->Build(fAttributes, fCharacters);
00103 else {
00104 std::cerr << "xmli::SAX2Handler:" << __LINE__
00105 << " No no handler for tag '"
00106 << localname << "' from file "
00107 << xmli::Parser::GetCurrentSource()
00108 << std::endl;
00109 abort();
00110 }
00111 // std::cerr
00112 // << "[EndElement]"
00113 // << " [ uri=" << uri << "]"
00114 // << " [ localname=" << localname << "]"
00115 // << " [ qname=" << qname << "]"
00116 // << " [ builder=" << b << "]"
00117 // << std::endl;
00118 }
|
|
||||||||||||||||||||
|
Definition at line 47 of file SAX2Handler.cxx. References xmli::AttributeList, fAttributes, fCharacters, fCount, fLocalName, fQname, and fUri. Referenced by xmli::SAX2DefaultHandler::startElement().
00051 {
00052 //======================================================================
00053 // Called at start of tag element
00054 //======================================================================
00055 fUri = uri;
00056 fLocalName = localname;
00057 fQname = qname;
00058 fAttributes = attrs;
00059 fCharacters = "";
00060
00061 ++fCount;
00062
00063 // std::cerr
00064 // << "[StartElement]"
00065 // << " [ uri=" << uri << "]"
00066 // << " [ localname=" << localname << "]"
00067 // << " [ qname=" << qname << "]"
00068 // << std::endl;
00069 }
|
|
|
Set of tag attributes.
Definition at line 36 of file SAX2Handler.h. Referenced by EndElement(), and StartElement(). |
|
|
Text buffer.
Definition at line 37 of file SAX2Handler.h. Referenced by Characters(), EndElement(), and StartElement(). |
|
|
Count begin/end tag events.
Definition at line 38 of file SAX2Handler.h. Referenced by EndElement(), StartElement(), and ~SAX2Handler(). |
|
|
Local name of tag.
Definition at line 34 of file SAX2Handler.h. Referenced by EndElement(), StartElement(), and ~SAX2Handler(). |
|
|
Qualified name of tag.
Definition at line 35 of file SAX2Handler.h. Referenced by EndElement(), and StartElement(). |
|
|
Tag "universal reference".
Definition at line 33 of file SAX2Handler.h. Referenced by EndElement(), and StartElement(). |
1.3.5