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

default_type_parser.h

00001 /***************************************************************************
00002  *   Copyright (C) 2004-2006 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 GRAMMAR_TO_PARSERDEFAULT_TYPE_PARSER_H
00021 #define GRAMMAR_TO_PARSERDEFAULT_TYPE_PARSER_H
00022 
00023 #include "object_parser.h"
00024 
00025 namespace grammar_to_parser {
00026 
00027 const char* DEFAULT_TYPE_PARSER = "DefaultTypeParser";
00032 template< typename E, typename A >
00033 class basic_default_type_parser : public basic_object_parser<E,A>
00034 {
00035 public:
00036     basic_default_type_parser( const char* name = DEFAULT_TYPE_PARSER );
00037         basic_default_type_parser( const basic_default_type_parser& rhs );
00038         basic_default_type_parser( const A& obj, const char* name = DEFAULT_TYPE_PARSER );
00039 
00040     virtual ~basic_default_type_parser();
00041 
00045     virtual std::basic_ostream<E>& format( std::basic_ostream<E>& os );
00046 };
00047 
00048 template< typename A >
00049 class default_type_parser : 
00050         public basic_default_type_parser<char,A>
00051 {
00052 public:
00053     default_type_parser() : basic_default_type_parser<char,A>() {};
00054         default_type_parser(const default_type_parser& rhs) : 
00055                 basic_default_type_parser<char,A>( rhs ) {};
00056         default_type_parser(const A& obj) : 
00057                 basic_default_type_parser<char,A>( obj ) {};
00058 };
00059 
00060 template< typename A >
00061 class wdefault_type_parser : 
00062         public basic_default_type_parser<wchar_t,A>
00063 {
00064 public:
00065     wdefault_type_parser() : basic_default_type_parser<wchar_t,A>() {};
00066         wdefault_type_parser(const wdefault_type_parser& rhs) : 
00067                 basic_default_type_parser<wchar_t,A>( rhs ) {};
00068         wdefault_type_parser(const A& obj) : 
00069                 basic_default_type_parser<wchar_t,A>( obj ) {};
00070 };
00071 
00072 template< typename E, typename A >
00073 basic_default_type_parser<E,A>::basic_default_type_parser(const char* name)
00074  : basic_object_parser<E,A>(name,terminal_type)
00075 {
00076 }
00077 
00078 
00079 template< typename E, typename A >
00080 basic_default_type_parser<E,A>::~basic_default_type_parser()
00081 {
00082 }
00083 
00084 template< typename E, typename A >
00085 basic_default_type_parser<E,A>::basic_default_type_parser( 
00086                                                 const basic_default_type_parser& rhs )
00087  : basic_object_parser<E,A>(rhs)
00088 {
00089 }
00090 
00091 template< typename E, typename A >
00092 basic_default_type_parser<E,A>::basic_default_type_parser( 
00093                                                                                 const A& obj, const char* name )
00094  : basic_object_parser<E,A>(name, obj, terminal_type)
00095 {
00096 }
00097 
00098 template< typename E, typename A >
00099 std::basic_ostream<E>& basic_default_type_parser<E,A>::format( 
00100                                                                                 std::basic_ostream<E>& os )
00101 {
00102         prepare_for_formatting();
00103 
00104         std::streampos strPos = os.tellp();
00105         os << get_valid();
00106         if( ( m_is_formatted = os.good() ) ) 
00107         {
00108                 m_formatted_size = os.tellp() - strPos;
00109         }
00110         else
00111         {
00112                 os.seekp(strPos);
00113         }
00114         return os;
00115 }
00116 
00117 
00118 };
00119 
00120 #endif

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