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

xml_number_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 #ifndef XML_PARSERXML_NUMBER_ATTRIBUTE_PARESE_H
00021 #define XML_PARSERXML_NUMBER_ATTRIBUTE_PARESE_H
00022 
00023 #include <xml_attribute_parser.h>
00024 
00025 namespace xml_parser {
00026 
00031 template< typename E, typename A >
00032 class basic_xml_number_attribute_parser : public basic_xml_attribute_parser<E>
00033 {
00034 typedef typename grammar_to_parser::basic_parser<E>::parser_list parser_list;
00035 typedef typename basic_xml_attribute_parser<E>::use_type use_type;
00036 public:
00037     basic_xml_number_attribute_parser(std::basic_string< E > attribute_name, 
00038                                                                         use_type a_use_type,
00039                                                                         A default_value = 0 ) :
00040                 basic_xml_attribute_parser<E>( attribute_name, a_use_type ),
00041                 m_attribute_value(),
00042                 m_default_value(default_value) {};
00043                 
00044         virtual void push_parsers( parser_list &l )
00045         {
00046                 basic_xml_attribute_parser<E>::push_parsers(l);
00047                 l.push_back(&m_attribute_value);
00048         }
00049         
00050         use_type get_use_type()
00051         {
00052                 return m_use_type;
00053         }
00054 
00055         operator A()
00056         {
00057                 return m_attribute_value.get_valid();
00058         }
00059 protected:
00060         grammar_to_parser::basic_value_parser<E,A>              m_attribute_value;
00061         
00062         A                                                                                               m_default_value;
00063         
00064 };
00065 
00066 template< typename A >
00067 class xml_number_attribute_parser : public basic_xml_number_attribute_parser<char,A>
00068 {
00069 typedef typename basic_xml_attribute_parser<A>::use_type use_type;
00070 public:
00071     xml_number_attribute_parser(std::string attribute_name, 
00072                                                                 use_type a_use_type,
00073                                                                 A default_value = 0 ) :
00074                 basic_xml_number_attribute_parser<char,A>( attribute_name, a_use_type ) {};
00075 };
00076 
00077 template< typename A >
00078 class wxml_number_attribute_parser : public basic_xml_number_attribute_parser<wchar_t,A>
00079 {
00080 typedef typename basic_xml_attribute_parser<wchar_t>::use_type use_type;
00081 public:
00082     wxml_number_attribute_parser(std::wstring attribute_name, 
00083                                                                 use_type a_use_type,
00084                                                                 A default_value = 0 ) :
00085                 basic_xml_number_attribute_parser<wchar_t,A>( attribute_name, a_use_type ) {};
00086 };
00087 
00088 };
00089 
00090 #endif

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