Main Page | Class Hierarchy | Class List | Directories | File List | Class Members

ere_base.h

00001 /***************************************************************************
00002  *   Copyright (C) 2006 by Radko Mihal                                     *
00003  *   rmihal@pobox.sk                                                       *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.              *
00019  ***************************************************************************/
00020 #ifndef EXTENDED_REGULAR_EXPRESSIONERE_BASE_H
00021 #define EXTENDED_REGULAR_EXPRESSIONERE_BASE_H
00022 
00023 namespace extended_regular_expression {
00024 
00025 template< typename E >
00026 class ere_base
00027 {
00028 typedef typename grammar_to_parser::basic_parser<E>::parser_list parser_list;
00029 
00030 protected:
00031         unsigned long   m_rec_size;
00032         unsigned long   m_rec_pos;
00033         bool                    m_is_rec;
00034 public:
00035     ere_base() : m_is_rec(false) , m_rec_pos(0), m_rec_size(0) {};
00036         
00037         bool is_recognized()
00038         {
00039                 return m_is_rec;
00040         }
00041         
00042         void unset()
00043         {
00044                 m_is_rec = false;
00045         }
00046         
00047         void set( const unsigned long pos, const unsigned long size )
00048         {
00049                 m_is_rec = true;
00050                 m_rec_pos = pos;
00051                 m_rec_size = size;
00052         }
00053         
00054         unsigned long recognized_size() 
00055         {
00056                 return m_rec_size;
00057         }
00058 
00059         unsigned long recognized_position() 
00060         {
00061                 return m_rec_pos;
00062         }
00063                 
00064         const match& get_match()
00065         {
00066                 return m_match( m_rec_pos, m_rec_size );
00067         }
00068         
00069         virtual void assign_matches( matches::match_key parent_address, 
00070                                                                 unsigned long& branch_pos, 
00071                                                                 matches& m ) = 0;
00072         
00073         virtual unsigned long recognize( const E* buf, 
00074                                                                 const unsigned long buf_length,
00075                                                                 const unsigned long buf_offset,
00076                                                                 bool try_positions = true ) = 0;
00077         
00078         virtual void push_parsers( parser_list& l ) = 0;
00079         
00080         std::string to_str( const unsigned long i )
00081         {
00082                 std::stringstream ss;
00083                 ss << i;
00084                 return ss.str();
00085         }
00086         
00087 };
00088 
00089 };
00090 
00091 #endif

Generated on Sun Jul 2 18:39:42 2006 for grammar2parser.kdevelop by  doxygen 1.4.1