00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #include <qgarlib/qtimpl/QtQgarContentHandlerAdaptor.H>
00045
00046
00047 #include <qgarlib/qtimpl/QtAttributesAdaptor.H>
00048 #include <qgarlib/qtimpl/QtLocatorAdaptor.H>
00049 #include <qgarlib/sax/ContentHandler.H>
00050 #include <qgarlib/sax/SAXException.H>
00051
00052
00053
00054 using namespace std;
00055
00056 namespace qgxml {
00057
00058
00059
00060
00061
00062
00063 QtQgarContentHandlerAdaptor::QtQgarContentHandlerAdaptor(ContentHandler
00064 * handler)
00065 {
00066 _impl = handler;
00067 _locatorImpl = 0;
00068 }
00069
00070
00071
00072
00073
00074
00075
00076 QtQgarContentHandlerAdaptor::~QtQgarContentHandlerAdaptor()
00077 {
00078 delete _locatorImpl;
00079 }
00080
00081
00082
00083
00084
00085
00086
00087 bool
00088 QtQgarContentHandlerAdaptor::characters(const QString & ch)
00089 {
00090 bool retval = true;
00091
00092 try {
00093
00094 _impl->characters(_sc(ch).c_str(), 0, ch.length());
00095 }
00096 catch(SAXException& e) {
00097 retval = false;
00098 _errorMsg = e.getMessage();
00099 }
00100
00101 return retval;
00102 }
00103
00104
00105
00106 bool
00107 QtQgarContentHandlerAdaptor::endDocument()
00108 {
00109 bool retval = true;
00110
00111 try {
00112
00113 _impl->endDocument();
00114 }
00115 catch(SAXException& e) {
00116
00117 retval = false;
00118 _errorMsg = e.getMessage();
00119 }
00120
00121 return retval;
00122 }
00123
00124
00125
00126 bool
00127 QtQgarContentHandlerAdaptor::endElement ( const QString & namespaceURI,
00128 const QString & localName,
00129 const QString & qName )
00130 {
00131 bool retval = true;
00132
00133 try {
00134
00135 _impl->endElement(_sc(namespaceURI), _sc(localName), _sc(qName));
00136 }
00137 catch(SAXException& e) {
00138 retval = false;
00139 _errorMsg = e.getMessage();
00140 }
00141
00142 return retval;
00143 }
00144
00145
00146
00147 bool
00148 QtQgarContentHandlerAdaptor::endPrefixMapping (const QString & prefix)
00149 {
00150 bool retval = true;
00151
00152 try {
00153
00154 _impl->endPrefixMapping(_sc(prefix));
00155 }
00156 catch(SAXException& e) {
00157 retval = false;
00158 _errorMsg = e.getMessage();
00159 }
00160
00161 return retval;
00162 }
00163
00164
00165
00166 QString
00167 QtQgarContentHandlerAdaptor::errorString()
00168 {
00169 return _errorMsg;
00170 }
00171
00172
00173
00174 bool
00175 QtQgarContentHandlerAdaptor::ignorableWhitespace ( const QString & ch )
00176 {
00177 bool retval = true;
00178
00179 try {
00180
00181 _impl->ignorableWhitespace(_sc(ch).c_str(), 0, ch.length());
00182 }
00183 catch(SAXException& e) {
00184 retval = false;
00185 _errorMsg = e.getMessage();
00186 }
00187
00188 return retval;
00189 }
00190
00191
00192
00193 void
00194 QtQgarContentHandlerAdaptor::setDocumentLocator (QXmlLocator * locator)
00195 {
00196
00197
00198
00199 delete _locatorImpl;
00200 _locatorImpl = new QtLocatorAdaptor(locator);
00201
00202
00203
00204
00205 _impl->setDocumentLocator(_locatorImpl);
00206 }
00207
00208
00209
00210 bool
00211 QtQgarContentHandlerAdaptor::startDocument()
00212 {
00213 bool retval = true;
00214
00215 try {
00216
00217 _impl->startDocument();
00218 }
00219 catch(SAXException& e) {
00220 retval = false;
00221 _errorMsg = e.getMessage();
00222 }
00223
00224 return retval;
00225 }
00226
00227
00228
00229 bool
00230 QtQgarContentHandlerAdaptor::processingInstruction ( const QString & target,
00231 const QString & data )
00232 {
00233 bool retval = true;
00234
00235 try {
00236
00237 _impl->processingInstruction(_sc(target), _sc(data));
00238 }
00239 catch(SAXException& e) {
00240 retval = false;
00241 _errorMsg = e.getMessage();
00242 }
00243
00244 return retval;
00245 }
00246
00247
00248
00249 bool
00250 QtQgarContentHandlerAdaptor::skippedEntity (const QString & name)
00251 {
00252 bool retval = true;
00253
00254 try {
00255
00256 _impl->skippedEntity(_sc(name));
00257 }
00258 catch(SAXException& e) {
00259 retval = false;
00260 _errorMsg = e.getMessage();
00261 }
00262
00263 return retval;
00264 }
00265
00266
00267 bool
00268 QtQgarContentHandlerAdaptor::startElement (const QString & namespaceURI,
00269 const QString & localName,
00270 const QString & qName,
00271 const QXmlAttributes& atts)
00272 {
00273 bool retval = true;
00274
00275 try {
00276 _impl->startElement(_sc(namespaceURI),
00277 _sc(localName),
00278 _sc(qName),
00279 QtAttributesAdaptor(const_cast<QXmlAttributes *>(&atts)));
00280 }
00281 catch(SAXException& e) {
00282 retval = false;
00283 _errorMsg = e.getMessage();
00284 }
00285
00286 return retval;
00287 }
00288
00289
00290
00291 bool
00292 QtQgarContentHandlerAdaptor::startPrefixMapping ( const QString & prefix,
00293 const QString & uri )
00294 {
00295 bool retval = true;
00296
00297 try {
00298
00299 _impl->startPrefixMapping(_sc(prefix), _sc(uri));
00300 }
00301 catch(SAXException& e) {
00302 retval = false;
00303 _errorMsg = e.getMessage();
00304 }
00305
00306 return retval;
00307 }
00308
00309
00310
00311 }