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

xml_tag_parser.h

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 #ifndef XML_PARSERBASIC_XML_TAG_PARSER_H
00021 #define XML_PARSERBASIC_XML_TAG_PARSER_H
00022 
00023 namespace xml_parser {
00024 
00028 template< typename E >
00029 class basic_xml_tag_parser  : public grammar_to_parser::basic_simple_non_terminal<E>
00030 {
00031 public:
00032 typedef typename grammar_to_parser::basic_parser<E>::parser_list parser_list;
00033 typedef typename grammar_to_parser::basic_parser<E>::parser_list_iterator parser_list_iterator;
00034         
00035         basic_xml_tag_parser( std::basic_string<E> tag_name ) :
00036                 grammar_to_parser::basic_simple_non_terminal<E>(),
00037                 m_tag_name_begin(tag_name),
00038                 m_tag_name_end(tag_name) {};
00039                 
00040         // The method must be reimplemented when defining subclasses - it returns the
00041         // parser of parameters used in tag declaration
00042         // see xml_parser sample project
00043         virtual grammar_to_parser::basic_parser<E>* get_params_parser() = 0;
00044         
00045         // The method must be reimplemented when defining subclasses - it returns the 
00046         // parser of value enclosed in tag
00047         // see xml_parser sample project 
00048         virtual grammar_to_parser::basic_parser<E>* get_value_parser() = 0;
00049         
00050         void get_symbols( parser_list &l )
00051         {
00052                 l.push_back(&m_1);
00053                 l.push_back(&m_tag_name_begin);
00054                 l.push_back(get_params_parser());
00055                 l.push_back(&m_2);
00056                 l.push_back(get_value_parser());
00057                 l.push_back(&m_3);
00058                 l.push_back(&m_4);
00059                 l.push_back(&m_tag_name_end);
00060                 l.push_back(&m_5);
00061         }       
00062 protected:
00063         grammar_to_parser::basic_terminal<E,'<'>        m_1;
00064         grammar_to_parser::basic_pattern_parser<E>      m_tag_name_begin;
00065         // here will come params parser from inherited class 
00066         // supporting get_params_parser() method 
00067         grammar_to_parser::basic_terminal<E,'>'>        m_2;
00068         // here will come value parser from inherited class 
00069         // supporting get_value_parser() method
00070         grammar_to_parser::basic_terminal<E,'<'>        m_3;
00071         grammar_to_parser::basic_terminal<E,'\\'>       m_4;
00072         grammar_to_parser::basic_pattern_parser<E>      m_tag_name_end;
00073         grammar_to_parser::basic_terminal<E,'>'>        m_5;
00074 };
00075 
00076 
00077 typedef basic_xml_tag_parser<char> xml_tag_parser;
00078 typedef basic_xml_tag_parser<wchar_t> wxml_tag_parser;
00079 
00080 
00081 };
00082 
00083 #endif

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