00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef BRACKET_EXPRESSIONCLASS_NAME_H
00021 #define BRACKET_EXPRESSIONCLASS_NAME_H
00022
00023 namespace bracket_expression {
00024
00025 template<typename E>
00026 class class_name
00027 {
00028 typedef typename grammar_to_parser::basic_parser<E>::parser_list parser_list;
00029 typedef std::ctype_base ctypebase;
00030
00031 grammar_to_parser::basic_pattern_parser<E> m_alnum;
00032 grammar_to_parser::basic_pattern_parser<E> m_cntrl;
00033 grammar_to_parser::basic_pattern_parser<E> m_lower;
00034 grammar_to_parser::basic_pattern_parser<E> m_space;
00035 grammar_to_parser::basic_pattern_parser<E> m_alpha;
00036 grammar_to_parser::basic_pattern_parser<E> m_digit;
00037 grammar_to_parser::basic_pattern_parser<E> m_print;
00038 grammar_to_parser::basic_pattern_parser<E> m_upper;
00039 grammar_to_parser::basic_pattern_parser<E> m_blank;
00040 grammar_to_parser::basic_pattern_parser<E> m_graph;
00041 grammar_to_parser::basic_pattern_parser<E> m_punct;
00042 grammar_to_parser::basic_pattern_parser<E> m_xdigit;
00043
00044 int m_size;
00045 public:
00046 class_name() :
00047 m_alnum( "alnum" ),
00048 m_cntrl( "cntrl" ),
00049 m_lower( "lower" ),
00050 m_space( "space" ),
00051 m_alpha( "alpha" ),
00052 m_digit( "digit" ),
00053 m_print( "print" ),
00054 m_upper( "upper" ),
00055 m_blank( "blank" ),
00056 m_graph( "graph" ),
00057 m_punct( "punct" ),
00058 m_xdigit( "xdigit" ),
00059 m_size(0) {};
00060
00061 int matched_size() { return m_size; }
00062
00063 void push_parsers( parser_list &l )
00064 {
00065 l.push_back(&m_alnum);
00066 l.push_back(&m_cntrl);
00067 l.push_back(&m_lower);
00068 l.push_back(&m_space);
00069 l.push_back(&m_alpha);
00070 l.push_back(&m_digit);
00071 l.push_back(&m_print);
00072 l.push_back(&m_upper);
00073 l.push_back(&m_blank);
00074 l.push_back(&m_graph);
00075 l.push_back(&m_punct);
00076 l.push_back(&m_xdigit);
00077 }
00078
00079 unsigned long compare( const E* buf, const unsigned long buf_length )
00080 {
00081 std::ctype_base t;
00082 int ret = 0;
00083 ctypebase::mask m;
00084
00085
00086 if( m_alnum.is_parsed() ) m=ctypebase::alnum;
00087 if( m_cntrl.is_parsed() ) m=ctypebase::cntrl;
00088 if( m_lower.is_parsed() ) m=ctypebase::lower;
00089 if( m_space.is_parsed() ) m=ctypebase::space;
00090 if( m_alpha.is_parsed() ) m=ctypebase::alpha;
00091 if( m_digit.is_parsed() ) m=ctypebase::digit;
00092 if( m_print.is_parsed() ) m=ctypebase::print;
00093 if( m_upper.is_parsed() ) m=ctypebase::upper;
00094
00095 if( m_graph.is_parsed() ) m=ctypebase::graph;
00096 if( m_punct.is_parsed() ) m=ctypebase::punct;
00097 if( m_xdigit.is_parsed() ) m=ctypebase::xdigit;
00098
00099 while( m_size < buf_length )
00100 {
00101 if( !std::use_facet< std::ctype<E> >(std::locale()).is( buf,
00102 buf+m_size+1, &m ) )
00103 {
00104 break;
00105 }
00106 m_size++;
00107 }
00108
00109 if( m_size > 0 )
00110 return 0;
00111 else
00112 return 1;
00113 }
00114
00115
00116 ~class_name()
00117 {
00118 }
00119
00120 };
00121
00122 };
00123
00124 #endif