LTP GCOV extension - code coverage report
Current view: directory - usr/include/tagcoll-2.0.11/tagcoll/input - base.h
Test: lcov.info
Date: 2008-08-14 Instrumented lines: 14
Code covered: 7.1 % Executed lines: 1

       1                 : #ifndef TAGCOLL_INPUT_BASE_H
       2                 : #define TAGCOLL_INPUT_BASE_H
       3                 : 
       4                 : /** \file
       5                 :  * Base class for parsers
       6                 :  */
       7                 : 
       8                 : /*
       9                 :  * Copyright (C) 2003,2004,2005,2006  Enrico Zini <enrico@debian.org>
      10                 :  *
      11                 :  * This library is free software; you can redistribute it and/or
      12                 :  * modify it under the terms of the GNU Lesser General Public
      13                 :  * License as published by the Free Software Foundation; either
      14                 :  * version 2.1 of the License, or (at your option) any later version.
      15                 :  *
      16                 :  * This library 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 GNU
      19                 :  * Lesser General Public License for more details.
      20                 :  *
      21                 :  * You should have received a copy of the GNU Lesser General Public
      22                 :  * License along with this library; if not, write to the Free Software
      23                 :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
      24                 :  */
      25                 : 
      26                 : #include <string>
      27                 : #include <wibble/exception.h>
      28                 : 
      29                 : namespace tagcoll {
      30                 : 
      31                 : namespace input {
      32                 : class Input;
      33                 : }
      34                 : 
      35                 : namespace exception {
      36                 : 
      37                 : /**
      38                 :  * Base exception for parser errors
      39                 :  */
      40                 : class Input : public wibble::exception::Consistency
      41               0 : {
      42                 : protected:
      43                 :         std::string _file;
      44                 :         int _line;
      45                 : 
      46                 :         std::string makeContext(const std::string& file, int line);
      47                 :         
      48                 : public:
      49                 :         Input(const tagcoll::input::Input& input, const std::string& message) throw ();
      50                 :         Input(const std::string& file, int line, const std::string& message) throw ()
      51                 :                 : wibble::exception::Consistency(makeContext(file, line), message),
      52                 :                  _file(file), _line(line) {}
      53               0 :         Input(int line, const std::string& message) throw ()
      54               0 :                 : wibble::exception::Consistency(makeContext(std::string(), line), message),
      55               0 :                  _line(line) {}
      56                 :         Input(const std::string& message) throw ()
      57                 :                 : wibble::exception::Consistency(makeContext(std::string(), -1), message),
      58                 :                  _line(-1) {}
      59               0 :         virtual ~Input() throw () {}
      60                 : 
      61                 :         int line() const throw () { return _line; }
      62               0 :         int line(int line) throw () { return _line = line; }
      63                 : 
      64                 :         const std::string& file() const throw () { return _file; }
      65                 :         std::string file() throw () { return _file; }
      66                 :         std::string file(const std::string file) throw () { return _file = file; }
      67                 : 
      68               0 :         virtual const char* type() const throw () { return "Input"; }
      69                 : };
      70                 : 
      71                 : /**
      72                 :  * Exception thrown in case of problems accessing the input of the parser
      73                 :  */
      74                 : class Parser : public Input
      75               0 : {
      76                 : public:
      77               0 :         Parser(const tagcoll::input::Input& input, const std::string& message) throw ()
      78               0 :                 : Input(input, message) {}
      79               0 :         virtual ~Parser() throw () {}
      80                 : 
      81               0 :         virtual const char* type() const throw ()
      82                 :         {
      83               0 :                 return "Parser";
      84                 :         }
      85                 : };
      86                 : 
      87                 : }
      88                 : 
      89                 : namespace input {
      90                 : 
      91                 : /**
      92                 :  * Generic interface for parser input readers.
      93                 :  *
      94                 :  * It encapsulates and hides the reading machinery.  It can be implemented as a
      95                 :  * file read, a stream read, a decompressing file read, a network read or
      96                 :  * whatever else is needed.
      97                 :  */
      98                 : class Input
      99                 : {
     100                 : public:
     101                 :         static const int Eof = -1;
     102                 : 
     103                 :         Input() {}
     104            1305 :         virtual ~Input() {}
     105                 : 
     106                 :         virtual const std::string& fileName() const = 0;
     107                 :         virtual int lineNumber() const = 0;
     108                 :         virtual int nextChar()  = 0;
     109                 :         virtual void pushChar(int c)  = 0;
     110                 : };
     111                 : 
     112                 : }
     113                 : 
     114                 : }
     115                 : 
     116                 : // vim:set ts=4 sw=4:
     117                 : #endif

Generated by: LTP GCOV extension version 1.6