Cutelee  6.1.0
lists.h
1 /*
2  This file is part of the Cutelee template system.
3 
4  Copyright (c) 2009,2010,2011 Stephen Kelly <steveire@gmail.com>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either version
9  2.1 of the Licence, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with this library. If not, see <http://www.gnu.org/licenses/>.
18 
19 */
20 
21 #ifndef LISTFILTERS_H
22 #define LISTFILTERS_H
23 
24 // krazy:excludeall=includes
25 
26 #include "filter.h"
27 
28 using namespace Cutelee;
29 
30 class JoinFilter : public Filter
31 {
32 public:
33  QVariant doFilter(const QVariant &input, const QVariant &argument = {},
34  bool autoescape = {}) const override;
35 
36  bool isSafe() const override { return true; }
37 };
38 
39 class LengthFilter : public Filter
40 {
41 public:
42  QVariant doFilter(const QVariant &input, const QVariant &argument = {},
43  bool autoescape = {}) const override;
44 
45  bool isSafe() const override { return true; }
46 };
47 
48 class LengthIsFilter : public Filter
49 {
50 public:
51  QVariant doFilter(const QVariant &input, const QVariant &argument = {},
52  bool autoescape = {}) const override;
53 
54  bool isSafe() const override { return true; }
55 };
56 
57 class FirstFilter : public Filter
58 {
59 public:
60  QVariant doFilter(const QVariant &input, const QVariant &argument = {},
61  bool autoescape = {}) const override;
62 };
63 
64 class LastFilter : public Filter
65 {
66 public:
67  QVariant doFilter(const QVariant &input, const QVariant &argument = {},
68  bool autoescape = {}) const override;
69 };
70 
71 class RandomFilter : public Filter
72 {
73 public:
74  QVariant doFilter(const QVariant &input, const QVariant &argument = {},
75  bool autoescape = {}) const override;
76 
77  bool isSafe() const override { return true; }
78 };
79 
80 class SliceFilter : public Filter
81 {
82 public:
83  QVariant doFilter(const QVariant &input, const QVariant &argument = {},
84  bool autoescape = {}) const override;
85 
86  bool isSafe() const override { return true; }
87 };
88 
89 class MakeListFilter : public Filter
90 {
91 public:
92  QVariant doFilter(const QVariant &input, const QVariant &argument = {},
93  bool autoescape = {}) const override;
94 
95  bool isSafe() const override { return true; }
96 };
97 
99 {
100 public:
101  QVariant doFilter(const QVariant &input, const QVariant &argument = {},
102  bool autoescape = {}) const override;
103 
104  bool isSafe() const override { return true; }
105 
106 protected:
107  SafeString processList(const QVariantList &list, int tabs,
108  bool autoescape) const;
109 };
110 
111 class DictSortFilter : public Filter
112 {
113 public:
114  QVariant doFilter(const QVariant &input, const QVariant &argument = {},
115  bool autoescape = {}) const override;
116 
117  bool isSafe() const override { return false; }
118 };
119 
120 #endif
Base class for all filters.
Definition: filter.h:59
A QString wrapper class for containing whether a string is safe or needs to be escaped.
Definition: safestring.h:92
bool isSafe() const override
Definition: lists.h:117
bool isSafe() const override
Definition: lists.h:36
bool isSafe() const override
Definition: lists.h:45
bool isSafe() const override
Definition: lists.h:54
bool isSafe() const override
Definition: lists.h:95
bool isSafe() const override
Definition: lists.h:77
bool isSafe() const override
Definition: lists.h:86
bool isSafe() const override
Definition: lists.h:104
The Cutelee namespace holds all public Cutelee API.
Definition: Mainpage.dox:8