00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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