00001 /*************************************************************************** 00002 * Copyright (C) 2005 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 namespace xml_parser { 00025 template< typename E > 00026 class basic_xml_attributes_parser : public grammar_to_parser::basic_simple_non_terminal<E> 00027 { 00028 public: 00029 typedef typename grammar_to_parser::basic_parser<E>::parser_list parser_list; 00030 typedef typename grammar_to_parser::basic_parser<E>::parser_list_iterator parser_list_iterator; 00031 00032 basic_xml_attributes_parser( std::basic_string<E> attribute_name, 00033 std::basic_string<E> regexp_def ) : 00034 grammar_to_parser::basic_simple_non_terminal<E>(), 00035 m_attribute_name( attribute_name ), 00036 m_assignment( std::basic_string<E>(1,'=') ), 00037 m_attribute_value( regexp_def ) 00038 {}; 00039 00040 virtual void get_symbols( parser_list &l ) 00041 { 00042 l.push_back(&m_attribute_name); 00043 l.push_back(&m_assignment); 00044 l.push_back(&m_attribute_value); 00045 } 00046 00047 operator std::basic_string<E>() 00048 { 00049 return m_attribute_value.get_valid(); 00050 } 00051 protected: 00052 grammar_to_parser::basic_pattern_parser<E> m_attribute_name; 00053 grammar_to_parser::basic_pattern_parser<E> m_assignment; 00054 grammar_to_parser::basic_regexp_parser<E> m_attribute_value; 00055 }; 00056 00057 typedef basic_xml_attributes_parser<char> xml_attribute_parser; 00058 typedef basic_xml_attributes_parser<wchar_t> wxml_attribute_parser; 00059 00060 };