00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef EXTENDED_REGULAR_EXPRESSIONERE_H
00021 #define EXTENDED_REGULAR_EXPRESSIONERE_H
00022
00023 #include <map>
00024 #include <list>
00025
00026 #include "grammar_to_parser.h"
00027
00028 #include "match.h"
00029 #include "matches.h"
00030 #include "bracket_expression.h"
00031 #include "ere_base.h"
00032 #include "ere_dupl_symbol.h"
00033 #include "ere_dups.h"
00034 #include "special_chars.h"
00035 #include "one_char_or_coll_elem_ere.h"
00036 #include "ere_expression.h"
00037 #include "ere_branch.h"
00038 #include "extended_reg_exp.h"
00039
00040 namespace extended_regular_expression
00041 {
00042
00043 template< typename E >
00044 class ere
00045 {
00046 typedef typename grammar_to_parser::basic_parser<E>::parser_list parser_list;
00047
00048 grammar_to_parser::basic_choice< E, extended_reg_exp<E> > m_ext_reg_exp;
00049 unsigned long m_rec_size;
00050 unsigned long m_rec_pos;
00051 bool m_is_rec;
00052
00053 public:
00054 ere() : m_rec_size(0), m_rec_pos(0), m_is_rec(false) {};
00055 ~ere() {};
00056
00057 unsigned long recognize( const E* buf,
00058 const unsigned long buf_length,
00059 bool try_positions = true )
00060 {
00061 m_ext_reg_exp->recognize( buf, buf_length, 0, try_positions );
00062 m_is_rec = m_ext_reg_exp->is_recognized();
00063 m_rec_pos = m_ext_reg_exp->recognized_position();
00064 m_rec_size = m_ext_reg_exp->recognized_size();
00065 return m_rec_size;
00066 }
00067 void assign_matches( matches& m )
00068 {
00069 unsigned long branch_pos = 0;
00070 matches::match_key key = "1";
00071 if( m_ext_reg_exp.is_parsed() ) m_ext_reg_exp->assign_matches( key, branch_pos, m );
00072 };
00073
00074 void push_parsers( parser_list& l )
00075 {
00076 l.push_back( &m_ext_reg_exp );
00077 }
00078
00079 bool is_recognized()
00080 {
00081 return m_is_rec;
00082 }
00083
00084 const unsigned long recognized_size() const
00085 {
00086 return m_rec_size;
00087 }
00088
00089 const unsigned long recognized_position() const
00090 {
00091 return m_rec_pos;
00092 }
00093 };
00094
00095 };
00096
00097 #endif