include/BeautifierHandlers.H

Go to the documentation of this file.
00001 /* ${copyright}$ */
00002 /* $Id: BeautifierHandlers.H 759 2006-06-09 22:10:25Z milena $ */
00007 #ifndef __BEAUTIFIER_HANDLERS_H__
00008 #define __BEAUTIFIER_HANDLERS_H__
00009 
00010 #include <string>
00011 #include <vector>
00012 
00013 #include <xercesc/sax/HandlerBase.hpp>
00014 
00015 #include "libepp_nicbr.H"
00016 
00017 using std::auto_ptr;
00018 using std::string;
00019 using std::vector;
00020 
00021 XERCES_CPP_NAMESPACE_USE
00022 
00023 LIBEPP_NICBR_NS_BEGIN
00024 
00026 struct UserData {
00027   string input_txt;
00028   string output_txt;
00029 };
00030 
00032 class BeautifierHandlers : public XERCES_CPP_NAMESPACE_QUALIFIER HandlerBase
00033 {
00034 public:  
00036 
00039   BeautifierHandlers(UserData *pretty_data);
00040 
00042   ~BeautifierHandlers();
00043 
00045 
00049   void startElement(const XMLCh* const name, AttributeList& attributes);
00050 
00052 
00056   void characters(const XMLCh* const chars, const unsigned int length);
00057 
00059 
00062   void endElement(const XMLCh* const chars);
00063 
00065 
00068   void warning(const SAXParseException& exc);
00069 
00071 
00074   void error(const SAXParseException& exc);
00075 
00077 
00080   void fatalError(const SAXParseException& exc);
00081 
00082 private:
00085   //  another character event so it is necessary to buffer the characters 
00086   //  until the end
00087   void chars_handler();
00088 
00090 
00094   string str_transcode(const XMLCh *const to_transcode);
00095 
00097 
00101   string truncate(const string &line);
00102 
00104 
00107   string alltrim(const string& buffer);
00108 
00110 
00115   int split(const string& buffer, vector<string>& words);
00116 
00118   enum eventType {
00119     NONE = 0,
00120     START = 1,
00121     CHARACTERS = 2,
00122     END = 3
00123   };
00124 
00126   int _depth;
00127 
00129   UserData *_user_data;
00130 
00132   eventType _last_event;
00133 
00135   eventType _last_non_chars_event;
00136 
00138   string _to_be_printed;
00139 
00141   int _left_margin;
00142 
00144   string _element_name;
00145 
00147   bool _truncated_txt;
00148 
00150   string _tag_margin;
00151 
00153   string _buffered_chars;
00154 };
00155 
00156 LIBEPP_NICBR_NS_END
00157 #endif //__BEAUTIFIER_HANDLERS_H__

Generated on Tue Mar 20 13:02:18 2007 for libepp_nicbr by  doxygen 1.4.7