LCOV - code coverage report
Current view: top level - shell/inc/internal - xml_parser.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 4 0.0 %
Date: 2012-08-25 Functions: 0 3 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef _XML_PARSER_HXX_
      30                 :            : #define _XML_PARSER_HXX_
      31                 :            : 
      32                 :            : #include <expat.h>
      33                 :            : #include <stdexcept>
      34                 :            : 
      35                 :            : //-----------------------------------------------------
      36                 :          0 : class xml_parser_exception : public std::runtime_error
      37                 :            : {
      38                 :            : public:
      39                 :            : 
      40                 :          0 :     xml_parser_exception(
      41                 :            :         const std::string& error_msg,
      42                 :            :         int error_code,
      43                 :            :         int line_number,
      44                 :            :         int column_number,
      45                 :            :         long byte_index) :
      46                 :            :         std::runtime_error(error_msg),
      47                 :            :         error_code_(error_code),
      48                 :            :         line_number_(line_number),
      49                 :            :         column_number_(column_number),
      50                 :          0 :         byte_index_(byte_index)
      51                 :          0 :     {}
      52                 :            : 
      53                 :            :     int  error_code_;
      54                 :            :     int  line_number_;
      55                 :            :     int  column_number_;
      56                 :            :     long byte_index_;
      57                 :            : };
      58                 :            : 
      59                 :            : 
      60                 :            : //-----------------------------------------------------
      61                 :            : //  Simple wrapper around expat, the xml parser library
      62                 :            : //  created by James Clark
      63                 :            : //-----------------------------------------------------
      64                 :            : class i_xml_parser_event_handler;
      65                 :            : 
      66                 :            : class xml_parser
      67                 :            : {
      68                 :            : public:
      69                 :            :     xml_parser(const XML_Char* EncodingName = 0);
      70                 :            : 
      71                 :            :     ~xml_parser();
      72                 :            : 
      73                 :            :     /** Parse a XML data stream
      74                 :            : 
      75                 :            :         @param      pXmlData
      76                 :            :                     Pointer to a buffer containing the xml data
      77                 :            : 
      78                 :            :         @param      Length
      79                 :            :                     Length of the buffer containing the xml data
      80                 :            : 
      81                 :            :         @param      IsFinal
      82                 :            :                     Indicates whether these are the last xml data
      83                 :            :                     of an xml document to parse. For very large
      84                 :            :                     xml documents it may be usefull to read and
      85                 :            :                     parse the document partially.
      86                 :            : 
      87                 :            :         @precond    XmlData must not be null
      88                 :            : 
      89                 :            :         @throws     SaxException
      90                 :            :                     If the used Sax parser returns an error. The SaxException
      91                 :            :                     contains detailed information about the error.  */
      92                 :            :     void parse(const char* XmlData, size_t Length, bool IsFinal = true);
      93                 :            : 
      94                 :            :     /** Set a document handler
      95                 :            : 
      96                 :            :         @descr      A document handler implements the interface i_xml_parser_event_handler.
      97                 :            :                     The document handler receive notifications of various events
      98                 :            :                     from the sax parser for instance "start_document".
      99                 :            : 
     100                 :            :                     The client is responsible for the life time management of
     101                 :            :                     the given document handler, that means the document handler
     102                 :            :                     instance must exist until a new one was set or until the parser
     103                 :            :                     no longer exist.
     104                 :            : 
     105                 :            :         @param      SaxDocumentHandler
     106                 :            :                     The new document handler, may be null if not interessted in
     107                 :            :                     sax parser events.
     108                 :            : 
     109                 :            :         @postcond   currently used document handler == pSaxDocumentHandler  */
     110                 :            :     void set_document_handler(i_xml_parser_event_handler* event_handler);
     111                 :            : 
     112                 :            :     /** Returns the currently used document handler or null if
     113                 :            :         no document handler was set before. */
     114                 :            :     i_xml_parser_event_handler* get_document_handler() const;
     115                 :            : private:
     116                 :            : 
     117                 :            :     void init();
     118                 :            : 
     119                 :            : private:
     120                 :            :     i_xml_parser_event_handler* document_handler_;
     121                 :            :     XML_Parser xml_parser_;
     122                 :            : 
     123                 :            : // prevent copy and assignment
     124                 :            : private:
     125                 :            :     xml_parser(const xml_parser&);
     126                 :            :     xml_parser& operator=(const xml_parser&);
     127                 :            : };
     128                 :            : 
     129                 :            : #endif
     130                 :            : 
     131                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10