Grantlee  5.1.0
templates/lib/filter.h
00001 /*
00002   This file is part of the Grantlee template system.
00003 
00004   Copyright (c) 2009,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 // krazy:excludeall=dpointer
00022 
00023 #ifndef GRANTLEE_FILTER_H
00024 #define GRANTLEE_FILTER_H
00025 
00026 #include "grantlee_templates_export.h"
00027 #include "outputstream.h"
00028 #include "safestring.h"
00029 
00030 #include <QtCore/QSharedPointer>
00031 #include <QtCore/QStringList>
00032 #include <QtCore/QVariant>
00033 
00034 namespace Grantlee
00035 {
00036 
00038 
00057 class GRANTLEE_TEMPLATES_EXPORT Filter
00058 {
00059 public:
00063   virtual ~Filter();
00064 
00065 #ifndef Q_QDOC
00066 
00070   void setStream(OutputStream *stream);
00071 #endif
00072 
00077   SafeString escape(const QString &input) const;
00078 
00083   SafeString escape(const SafeString &input) const;
00084 
00089   SafeString conditionalEscape(const SafeString &input) const;
00090 
00098   virtual QVariant doFilter(const QVariant &input,
00099                             const QVariant &argument = QVariant(),
00100                             bool autoescape = false) const = 0;
00101 
00105   virtual bool isSafe() const;
00106 
00107 private:
00108 #ifndef Q_QDOC
00109   OutputStream *m_stream;
00110 #endif
00111 };
00112 }
00113 
00114 #endif