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

xml_string_attribute_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 #include "string_parser.h"
00021 #include "xml_attribute_parser.h"
00022  
00023 namespace xml_parser {
00024 
00028 template< typename E >
00029 class basic_xml_string_attribute_parser : public basic_xml_attribute_parser<E>
00030 {
00031 public:
00032 typedef typename grammar_to_parser::basic_parser<E>::parser_list parser_list;
00033 typedef typename basic_xml_attribute_parser<E>::use_type use_type;
00034 typedef typename grammar_to_parser::basic_string_parser<E>::string_type string_type;
00035 typedef grammar_to_parser::basic_string_parser<E> str_parser;
00036 typedef std::basic_string<E> std_string;
00037         
00038         basic_xml_string_attribute_parser( std::basic_string<E> attribute_name,
00039                                                 use_type a_use_type = REQUIRED,
00040                                                 std_string default_value = std_string(),
00041                                                 string_type a_string_type = str_parser::STRING ) :
00042                 basic_xml_attribute_parser<E>( attribute_name, a_use_type ),
00043                 m_attribute_value( '\"', a_string_type ),
00044                 m_default_value( default_value )
00045         {};
00046 
00047         virtual void push_parsers( parser_list &l )
00048         {
00049                 basic_xml_attribute_parser<E>::push_parsers(l);
00050                 l.push_back(&m_comma_left);
00051                 l.push_back(&m_attribute_value);
00052                 l.push_back(&m_comma_right);
00053         }
00054         
00055         use_type get_use_type()
00056         {
00057                 return m_use_type;
00058         }
00059 
00060         operator std_string()
00061         {
00062                 return m_attribute_value.get_valid();
00063         }
00064 protected:
00065         grammar_to_parser::basic_terminal<E,'\"'>               m_comma_left;
00066         grammar_to_parser::basic_string_parser<E>               m_attribute_value;
00067         grammar_to_parser::basic_terminal<E,'\"'>               m_comma_right;
00068         
00069         std_string                                                                              m_default_value;
00070 };
00071 
00072 typedef basic_xml_string_attribute_parser<char> xml_string_attribute_parser;
00073 typedef basic_xml_string_attribute_parser<wchar_t> wxml_string_attribute_parser;
00074 
00075 };

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