Grantlee
0.4.0
|
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_core_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 00052 class GRANTLEE_CORE_EXPORT Filter 00053 { 00054 public: 00055 #ifndef Q_QDOC 00056 typedef QSharedPointer<Filter> Ptr; 00057 #endif 00058 00062 virtual ~Filter() {} 00063 00064 #ifndef Q_QDOC 00065 00068 void setStream( OutputStream *stream ) { 00069 m_stream = stream; 00070 } 00071 #endif 00072 00076 SafeString escape( const QString &input ) const { 00077 return m_stream->escape( input ); 00078 } 00079 00083 SafeString escape( const SafeString &input ) const { 00084 if ( input.isSafe() ) 00085 return SafeString( m_stream->escape( input ), SafeString::IsSafe ); 00086 return m_stream->escape( input ); 00087 } 00088 00092 SafeString conditionalEscape( const SafeString &input ) const { 00093 if ( !input.isSafe() ) 00094 return m_stream->escape( input ); 00095 return input; 00096 } 00097 00104 virtual QVariant doFilter( const QVariant &input, 00105 const QVariant &argument = QVariant(), 00106 bool autoescape = false 00107 ) const = 0; 00108 00112 virtual bool isSafe() const { // krazy:exclude:inline 00113 return false; 00114 } 00115 00116 private: 00117 #ifndef Q_QDOC 00118 OutputStream *m_stream; 00119 #endif 00120 }; 00121 00122 } 00123 00124 #endif 00125