Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <xercesc/sax2/Attributes.hpp>
00023 #include <xercesc/sax2/DefaultHandler.hpp>
00024 #include <xercesc/sax/SAXParseException.hpp>
00025 #include <xercesc/sax/SAXException.hpp>
00026 #include <string>
00027 #include <boost/scoped_array.hpp>
00028 #include <boost/algorithm/string.hpp>
00029 #include <xercesc/util/XMLString.hpp>
00030 #include "HippShape.h"
00031 #include "HippPolyline.h"
00032 #include "HippLine.h"
00033 #include "HippEllipse.h"
00034 #include "HippRectangle.h"
00035 #include "HippBackground.h"
00036
00037 #ifndef __SVGHANDLER_H__
00038 #define __SVGHANDLER_H__
00039
00040 XERCES_CPP_NAMESPACE_USE
00041 using namespace std;
00042
00043 namespace hipp {
00044 class SVGHandler : public xercesc::DefaultHandler
00045 {
00046 public:
00047 SVGHandler(void);
00048 ~SVGHandler(void);
00049 virtual void startDocument();
00050
00051 virtual void endDocument();
00052
00067 virtual void startElement(
00068 const XMLCh* const uri,
00069 const XMLCh* const localname,
00070 const XMLCh* const qname,
00071 const xercesc::Attributes& attrs);
00072
00073 virtual void endElement(
00074 const XMLCh* const uri,
00075 const XMLCh* const localname,
00076 const XMLCh* const qname);
00077
00078 virtual void characters(
00079 const XMLCh* const chars,
00080 const XMLSize_t length);
00081
00082
00083
00084
00085 void warning(const SAXParseException& exc);
00086 void error(const SAXParseException& exc);
00087 void fatalError(const SAXParseException& exc);
00088
00089 list<HippShape*> getShapes() const{
00090 return shapes;
00091 }
00092
00093 static string toNativeString(const XMLCh* str)
00094 {
00095 boost::scoped_array<char> ptr(xercesc::XMLString::transcode(str));
00096 return string(ptr.get( ));
00097 }
00098
00099 static string toLowerNativeString(const XMLCh* str){
00100 string s = SVGHandler::toNativeString(str);
00101 boost::to_lower(s);
00102 return s;
00103 }
00104
00105 protected:
00106 template <typename T> T createShape(const xercesc::Attributes& attrs, ShapeType type);
00107 private:
00108 HippShape* current;
00109 list<HippShape*> shapes;
00110 };
00111 }
00112 #endif