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