File: sqlitewindowdefinition.h

package info (click to toggle)
sqlitestudio 3.4.21%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 54,880 kB
  • sloc: ansic: 406,208; cpp: 123,872; yacc: 2,692; tcl: 497; sh: 462; xml: 426; makefile: 19
file content (131 lines) | stat: -rw-r--r-- 4,459 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#ifndef SQLITEWINDOWDEFINITION_H
#define SQLITEWINDOWDEFINITION_H

//#include "sqliteexpr.h"
//#include "sqliteorderby.h"
#include "sqlitestatement.h"

class SqliteExpr;
class SqliteOrderBy;

/**
 * @addtogroup sqlite_statement
 * @brief The SqliteWindowDefinition class
 */
class API_EXPORT SqliteWindowDefinition : public SqliteStatement
{
    Q_OBJECT

    public:
        class API_EXPORT Window : public SqliteStatement
        {
            public:
                class API_EXPORT Frame : public SqliteStatement
                {
                    public:
                        class API_EXPORT Bound : public SqliteStatement
                        {
                            public:
                                enum class Type
                                {
                                    UNBOUNDED_PRECEDING,
                                    UNBOUNDED_FOLLOWING,
                                    EXPR_PRECEDING,
                                    EXPR_FOLLOWING,
                                    CURRENT_ROW
                                };

                                Bound();
                                Bound(const Bound& other);
                                Bound(SqliteExpr* expr, const QString& value);

                                SqliteStatement* clone();

                                Type type = Type::CURRENT_ROW;
                                SqliteExpr* expr = nullptr;

                            protected:
                                TokenList rebuildTokensFromContents();
                        };

                        enum class RangeOrRows
                        {
                            RANGE,
                            ROWS,
                            GROUPS,
                            null
                        };

                        enum class Exclude
                        {
                            NO_OTHERS,
                            CURRENT_ROW,
                            GROUP,
                            TIES,
                            null
                        };

                        static RangeOrRows toRangeOrRows(const QString& value);
                        static QString fromRangeOrRows(RangeOrRows value);
                        static Exclude toExclude(const QString& value);
                        static QString fromExclude(Exclude value);

                        Frame();
                        Frame(const Frame& other);
                        Frame(RangeOrRows rangeOrRows, Bound* startBound, Bound* endBound, Exclude exclude);

                        SqliteStatement* clone();

                        RangeOrRows rangeOrRows = RangeOrRows::null;
                        Exclude exclude = Exclude::null;
                        Bound* startBound = nullptr;
                        Bound* endBound = nullptr;

                    protected:
                        TokenList rebuildTokensFromContents();
                };

                enum class Mode
                {
                    PARTITION_BY,
                    ORDER_BY,
                    null
                };

                Window();
                Window(const Window& other);

                SqliteStatement* clone();
                void initPartitionBy(const QString& name, const QList<SqliteExpr*>& exprList, const QList<SqliteOrderBy*>& orderBy, Frame* frame);
                void initOrderBy(const QString& name, const QList<SqliteOrderBy*>& orderBy, Frame* frame);
                void init(const QString& name, Frame* frame);

                QString name;
                QList<SqliteExpr*> exprList;
                QList<SqliteOrderBy*> orderBy;
                Frame* frame = nullptr;
                Mode mode = Mode::null;

            protected:
                TokenList rebuildTokensFromContents();

            private:
                void initExprList(const QList<SqliteExpr*>& exprList);
                void initOrderBy(const QList<SqliteOrderBy*>& orderBy);
                void initFrame(Frame* frame);
        };

        SqliteWindowDefinition();
        SqliteWindowDefinition(const SqliteWindowDefinition& other);
        SqliteWindowDefinition(const QString& name, Window* window);

        SqliteStatement* clone();

        QString name = QString();
        Window* window = nullptr;

    protected:
        TokenList rebuildTokensFromContents();
};

#endif // SQLITEWINDOWDEFINITION_H