00001
00002
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:
00084
00088 string str_transcode(const XMLCh *const to_transcode);
00089
00091
00095 string truncate(const string &line);
00096
00098
00101 string alltrim(const string& buffer);
00102
00104
00109 int split(const string& buffer, vector<string>& words);
00110
00112 enum eventType {
00113 NONE = 0,
00114 START = 1,
00115 CHARACTERS = 2,
00116 END = 3
00117 };
00118
00120 int _depth;
00121
00123 UserData *_user_data;
00124
00126 eventType _last_event;
00127
00129 string _to_be_printed;
00130
00132 int _left_margin;
00133
00135 string _element_name;
00136
00138 bool _truncated_txt;
00139
00141 string _tag_margin;
00142 };
00143
00144 LIBEPP_NICBR_NS_END
00145 #endif //__BEAUTIFIER_HANDLERS_H__