Grantlee  0.5.1
templates/lib/outputstream.h
00001 /*
00002   This file is part of the Grantlee template system.
00003 
00004   Copyright (c) 2010 Stephen Kelly <steveire@gmail.com>
00005 
00006   This library is free software; you can redistribute it and/or
00007   modify it under the terms of the GNU Lesser General Public
00008   License as published by the Free Software Foundation; either version
00009   2.1 of the Licence, or (at your option) any later version.
00010 
00011   This library is distributed in the hope that it will be useful,
00012   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014   Lesser General Public License for more details.
00015 
00016   You should have received a copy of the GNU Lesser General Public
00017   License along with this library.  If not, see <http://www.gnu.org/licenses/>.
00018 
00019 */
00020 
00021 #ifndef GRANTLEE_OUTPUTSTREAM_H
00022 #define GRANTLEE_OUTPUTSTREAM_H
00023 
00024 #include "grantlee_core_export.h"
00025 
00026 #include <QtCore/QSharedPointer>
00027 #include <QtCore/QTextStream>
00028 
00029 namespace Grantlee
00030 {
00031 
00032 class SafeString;
00033 
00035 
00076 class GRANTLEE_CORE_EXPORT OutputStream
00077 {
00078 public:
00082   OutputStream();
00083 
00087   explicit OutputStream( QTextStream *stream );
00088 
00092   virtual ~OutputStream();
00093 
00097   virtual QString escape( const QString &input ) const;
00098 
00102   QString escape( const SafeString &input ) const;
00103 
00107   virtual QSharedPointer<OutputStream> clone( QTextStream *stream ) const;
00108 
00112   QString conditionalEscape( const Grantlee::SafeString &input ) const;
00113 
00117   OutputStream& operator<<( const QString &input );
00118 
00122   OutputStream& operator<<( const SafeString &input );
00123 
00127   OutputStream& operator<<( QTextStream *stream );
00128 
00129 private:
00130   QTextStream *m_stream;
00131   Q_DISABLE_COPY( OutputStream )
00132 };
00133 
00134 }
00135 
00136 #endif