Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

QtQgarContentHandlerAdaptor.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------*
00002  | Library QgarLib, graphics analysis and recognition                  |
00003  | Copyright (C) 2003  Qgar Project, LORIA                             |
00004  |                                                                     |
00005  | This library is free software; you can redistribute it and/or       |
00006  | modify it under the terms of the GNU Lesser General Public          |
00007  | License version 2.1, as published by the Free Software Foundation.  |
00008  |                                                                     |
00009  | This library is distributed in the hope that it will be useful,     |
00010  | but WITHOUT ANY WARRANTY; without even the implied warranty of      |
00011  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                |
00012  | See the GNU Lesser General Public License for more details.         |
00013  |                                                                     |
00014  | The GNU Lesser General Public License is included in the file       |
00015  | LICENSE.LGPL, in the root directory of the Qgar packaging. See      |
00016  | http://www.gnu.org/licenses/lgpl.html for the terms of the license. |
00017  | To receive a paper copy, write to the Free Software Foundation,     |
00018  | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.       |
00019  |                                                                     |
00020  | Contact Project Qgar for any information:                           |
00021  |   LORIA - équipe Qgar                                               |
00022  |   B.P. 239, 54506 Vandoeuvre-lès-Nancy Cedex, France                |
00023  |   email: qgar-contact@loria.fr                                      |
00024  |   http://www.qgar.org/                                              |
00025  *---------------------------------------------------------------------*/
00026 
00027 
00028 /**
00029  * @file  QtQgarContentHandlerAdaptor.C
00030  * @brief Implementation of class qgxml::QtQgarContentHandlerAdaptor
00031  *
00032  *        See file QtQgarContentHandlerAdaptor.H for the interface.
00033  *
00034  * @author <a href="mailto:qgar-contact@loria.fr?subject=Qgar fwd Jan Rendek">Jan Rendek</a>
00035  * @date   March 11, 2003  14:03
00036  * @since  Qgar 2.1
00037  */
00038 
00039 
00040 // For RCS/CVS use: Do not delete
00041 /* $Id: QtQgarContentHandlerAdaptor.C,v 1.4 2004/07/01 22:19:21 masini Exp $ */
00042 
00043 
00044 #include <qgarlib/qtimpl/QtQgarContentHandlerAdaptor.H>
00045 
00046 // QGAR
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 // C O N S T R U C T O R S
00061 // ---------------------------------------------------------------------
00062 
00063 QtQgarContentHandlerAdaptor::QtQgarContentHandlerAdaptor(ContentHandler
00064                                                          * handler)
00065 {
00066   _impl = handler;
00067   _locatorImpl = 0;
00068 }
00069 
00070 
00071 
00072 // ---------------------------------------------------------------------
00073 // D E S T R U C T O R
00074 // ---------------------------------------------------------------------
00075 
00076 QtQgarContentHandlerAdaptor::~QtQgarContentHandlerAdaptor()
00077 {
00078   delete _locatorImpl;
00079 }
00080 
00081 
00082 
00083 // ---------------------------------------------------------------------
00084 // O T H E R
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   //-- Update the locator adaptor.
00198 
00199   delete _locatorImpl;
00200   _locatorImpl = new QtLocatorAdaptor(locator);
00201   
00202 
00203   //-- Delegate to the adaptee.
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 } // namespace qgxml