00001 #ifndef XMLHANDLERSHH
00002 #define XMLHANDLERSHH
00003
00004
00005 #include <xercesc/sax/HandlerBase.hpp>
00006 #include <xercesc/framework/XMLFormatter.hpp>
00007 #include <string>
00008 #include <iostream>
00009 #include <stdlib.h>
00010 #include <string>
00011 #include <iostream>
00012 #include <map>
00013
00014 #include "SteerDesc.hh"
00015 #include "Run.hh"
00016
00017
00018 #define RUN "run"
00019 #define INFOR "info"
00020 #define INPUT "input"
00021 #define SLOWCONTROL "slowcontrol"
00022 #define SCPARAM "scParam"
00023 #define OUTPUT "output"
00024 #define DETECTOR "detector"
00025 #define CHAMBER "chamber"
00026 #define BOARD "board"
00027 #define DIF "dif"
00028 #define CHIP "chip"
00029
00030
00031 #define DATE "date"
00032 #define DESCRIPTION "description"
00033 #define PATH "path"
00034 #define NAME "name"
00035 #define ID "id"
00036 #define TYPE "type"
00037 #define XPOS "xPos"
00038 #define YPOS "yPos"
00039 #define ZPOS "zPos"
00040 #define SCID "scId"
00041
00042 XERCES_CPP_NAMESPACE_USE
00043
00044 using namespace std;
00045
00046 class XMLTool;
00047
00048 class XMLHandlers : public HandlerBase, private XMLFormatTarget
00049 {
00050 public:
00051
00052
00053
00054 XMLHandlers
00055 (
00056 const XMLTool& father ,
00057 const char* const encodingName
00058 , const XMLFormatter::UnRepFlags unRepFlags
00059 );
00060 ~XMLHandlers();
00061
00062
00063 private:
00064 string XMLHandlers::XMLCh_to_String( const XMLCh* toTranscode ) ;
00065
00066
00067
00068
00069
00070
00071 void writeChars
00072 (
00073 const XMLByte* const toWrite
00074 );
00075
00076 virtual void writeChars
00077 (
00078 const XMLByte* const toWrite
00079 , const XMLSize_t count
00080 , XMLFormatter* const formatter
00081 );
00082
00083
00084
00085
00086
00087 void endDocument();
00088
00089 void endElement(const XMLCh* const name);
00090
00091 void characters(const XMLCh* const chars, const XMLSize_t length);
00092
00093 void ignorableWhitespace
00094 (
00095 const XMLCh* const chars
00096 , const XMLSize_t length
00097 );
00098
00099 void processingInstruction
00100 (
00101 const XMLCh* const target
00102 , const XMLCh* const data
00103 );
00104
00105 void startDocument();
00106
00107 void startElement(const XMLCh* const name, AttributeList& attributes);
00108
00109
00110
00111
00112
00113
00114 void warning(const SAXParseException& exc);
00115 void error(const SAXParseException& exc);
00116 void fatalError(const SAXParseException& exc);
00117
00118
00119
00120
00121
00122
00123 void notationDecl
00124 (
00125 const XMLCh* const name
00126 , const XMLCh* const publicId
00127 , const XMLCh* const systemId
00128 );
00129
00130 void unparsedEntityDecl
00131 (
00132 const XMLCh* const name
00133 , const XMLCh* const publicId
00134 , const XMLCh* const systemId
00135 , const XMLCh* const notationName
00136 );
00137
00138
00139 private :
00140
00141
00142
00143
00144
00145
00146
00147
00148 XMLFormatter fFormatter;
00149 const XMLTool &father;
00150 };
00151
00152
00153
00154
00155 class XMLTool
00156 {
00157
00158 public:
00159 XMLTool() ;
00160 ~XMLTool(){};
00161 int parse(SteerDesc& _steerDesc, string _xmlFileName);
00162 void receiveEvent(string balise, const map<string,string> &key_value) const;
00163
00164
00165 private:
00166 string xmlFileName;
00167 SteerDesc *steerDesc;
00168
00169 };
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180 class StrX
00181 {
00182 public :
00183
00184
00185
00186 StrX(const XMLCh* const toTranscode)
00187 {
00188
00189 fLocalForm = XMLString::transcode(toTranscode);
00190 }
00191
00192 ~StrX()
00193 {
00194 XMLString::release(&fLocalForm);
00195 }
00196
00197
00198
00199
00200 const char* localForm() const
00201 {
00202 return fLocalForm;
00203 }
00204
00205 private :
00206
00207
00208
00209
00210
00211
00212 char* fLocalForm;
00213 };
00214
00215 inline XERCES_STD_QUALIFIER ostream& operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump)
00216 {
00217 target << toDump.localForm();
00218 return target;
00219 }
00220
00221
00222
00223 #endif