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

XercesQgarContentHandlerAdaptor.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  XercesQgarContentHandlerAdaptor.C
00030  * @brief Implementation of class qgxml::XercesQgarContentHandlerAdaptor.
00031  *
00032  *        See file XercesQgarContentHandlerAdaptor.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 31, 2003  10:24
00036  * @since  Qgar 2.1
00037  */
00038 
00039 
00040 // For RCS/CVS use: Do not delete
00041 /* $Id: XercesQgarContentHandlerAdaptor.C,v 1.3 2004/07/01 22:19:37 masini Exp $ */
00042 
00043 
00044 #include <qgarlib/xercesimpl/XercesQgarContentHandlerAdaptor.H>
00045 
00046 // QGAR
00047 #include <qgarlib/sax/ContentHandler.H>
00048 #include <qgarlib/sax/SAXException.H>
00049 #include <qgarlib/xercesimpl/XercesAttributesAdaptor.H>
00050 #include <qgarlib/xercesimpl/XercesLocatorAdaptor.H>
00051 
00052 // XERCES
00053 #include <xercesc/sax/SAXException.hpp>
00054 
00055 namespace qgxml {
00056 
00057 
00058 // ---------------------------------------------------------------------
00059 // C O N S T R U C T O R S
00060 // ---------------------------------------------------------------------
00061 
00062 XercesQgarContentHandlerAdaptor::XercesQgarContentHandlerAdaptor(
00063                                      qgxml::ContentHandler * handler
00064                                              )
00065 {
00066   _impl = handler;
00067   _locatorImpl = 0;
00068 }
00069 
00070 
00071 
00072 
00073 // ---------------------------------------------------------------------
00074 // D E S T R U C T O R
00075 // ---------------------------------------------------------------------
00076 
00077 XercesQgarContentHandlerAdaptor::~XercesQgarContentHandlerAdaptor() 
00078 {
00079   delete _locatorImpl;
00080 }
00081 
00082 
00083 
00084 // ---------------------------------------------------------------------
00085 // O T H E R
00086 // ---------------------------------------------------------------------
00087 
00088 void 
00089 XercesQgarContentHandlerAdaptor::characters(const XMLCh * const chars, 
00090                                             const unsigned int length)
00091 {
00092   try {
00093 
00094     _impl->characters(_sc(chars).c_str(), 0, length);
00095   }
00096   catch (qgxml::SAXException& se) {
00097     throw xercesc::SAXException(se.getMessage());
00098   }
00099 }
00100 
00101 // ---------------------------------------------------------------------
00102 
00103 void
00104 XercesQgarContentHandlerAdaptor::endDocument()
00105 {
00106   try {
00107 
00108     _impl->endDocument();
00109   }
00110   catch (qgxml::SAXException& se) {
00111     throw xercesc::SAXException(se.getMessage());
00112   }  
00113 }
00114 
00115 // ---------------------------------------------------------------------
00116 
00117 void
00118 XercesQgarContentHandlerAdaptor::endElement(const XMLCh * const uri, 
00119                                             const XMLCh * const localname, 
00120                                             const XMLCh * const qName)
00121 {
00122   try {
00123 
00124     _impl->endElement(_sc(uri), _sc(localname), _sc(qName));
00125   }
00126   catch (qgxml::SAXException& se) {
00127     throw xercesc::SAXException(se.getMessage());
00128   }  
00129 }
00130   
00131 // ---------------------------------------------------------------------
00132 
00133 void
00134 XercesQgarContentHandlerAdaptor::ignorableWhitespace(const XMLCh * const chars, 
00135                                                      const unsigned
00136                                                      int length)
00137 {
00138   try {
00139     
00140     _impl->ignorableWhitespace(_sc(chars).c_str(), 0, length);
00141   }
00142   catch (qgxml::SAXException& se) {
00143     throw xercesc::SAXException(se.getMessage());
00144   }  
00145 }
00146 
00147 // ---------------------------------------------------------------------
00148 
00149 void
00150 XercesQgarContentHandlerAdaptor::processingInstruction(const XMLCh * const target, 
00151                                                        const XMLCh * const data)
00152 {
00153   try {
00154     
00155     _impl->processingInstruction(_sc(target), _sc(data));
00156   }
00157   catch (qgxml::SAXException& se) {
00158     throw xercesc::SAXException(se.getMessage());
00159   }    
00160 }
00161 
00162 // ---------------------------------------------------------------------
00163 
00164 void
00165 XercesQgarContentHandlerAdaptor::setDocumentLocator(
00166                                   const xercesc::Locator * const locator
00167                                   )
00168 {
00169   //-- Update the locator adaptor.
00170   
00171   delete _locatorImpl;
00172   _locatorImpl = new XercesLocatorAdaptor(const_cast<xercesc::Locator *>(locator));
00173   
00174   
00175   //-- Delegate to the adaptee.
00176 
00177   _impl->setDocumentLocator(_locatorImpl);
00178 
00179 }
00180 
00181 // ---------------------------------------------------------------------
00182 
00183 void
00184 XercesQgarContentHandlerAdaptor::startDocument()
00185 {
00186   try {
00187     
00188     _impl->startDocument();
00189   }
00190   catch (qgxml::SAXException& se) {
00191     throw xercesc::SAXException(se.getMessage());
00192   }      
00193 }
00194 
00195 // ---------------------------------------------------------------------
00196 
00197 void
00198 XercesQgarContentHandlerAdaptor::startElement(const XMLCh * const uri,
00199                                               const XMLCh * const localname,
00200                                               const XMLCh * const qname, 
00201                                               const xercesc::Attributes & attrs)
00202 {
00203   try {
00204     
00205     _impl->startElement(_sc(uri),
00206                         _sc(localname),
00207                         _sc(qname),
00208                         XercesAttributesAdaptor(
00209                             const_cast<xercesc::Attributes *>(&attrs))
00210                         );
00211   }
00212   catch (qgxml::SAXException& se) {
00213     throw xercesc::SAXException(se.getMessage());
00214   }      
00215 }
00216   
00217 // ---------------------------------------------------------------------
00218 
00219 void
00220 XercesQgarContentHandlerAdaptor::startPrefixMapping(const XMLCh * const prefix, 
00221                                                     const XMLCh * const uri)
00222 {
00223   try {
00224     
00225     _impl->startPrefixMapping(_sc(prefix), _sc(uri));
00226   }
00227   catch (qgxml::SAXException& se) {
00228     throw xercesc::SAXException(se.getMessage());
00229   }      
00230 }
00231 
00232 // ---------------------------------------------------------------------
00233 
00234 void
00235 XercesQgarContentHandlerAdaptor::endPrefixMapping(const XMLCh * const prefix)
00236 {
00237   try {
00238     
00239     _impl->endPrefixMapping(_sc(prefix));
00240   }
00241   catch (qgxml::SAXException& se) {
00242     throw xercesc::SAXException(se.getMessage());
00243   }      
00244 }
00245 
00246 // ---------------------------------------------------------------------
00247 
00248 void
00249 XercesQgarContentHandlerAdaptor::skippedEntity(const XMLCh * name)
00250 {
00251   try {
00252     
00253     _impl->skippedEntity(_sc(name));
00254   }
00255   catch (qgxml::SAXException& se) {
00256     throw xercesc::SAXException(se.getMessage());
00257   }      
00258 }
00259   
00260 // ----------------------------------------------------------------------
00261 
00262 } // namespace qgxml