QGIS API Documentation  3.12.1-BucureČ™ti (121cc00ff0)
qgsexpression_p.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsexpression_p.h
3 
4  ---------------------
5  begin : 9.12.2015
6  copyright : (C) 2015 by Matthias Kuhn
7  email : [email protected]
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #ifndef QGSEXPRESSIONPRIVATE_H
18 #define QGSEXPRESSIONPRIVATE_H
19 
20 #include <QString>
21 #include <memory>
22 
23 #include "qgsexpression.h"
24 #include "qgsdistancearea.h"
25 #include "qgsunittypes.h"
26 #include "qgsexpressionnode.h"
27 
29 
35 class QgsExpressionPrivate
36 {
37  public:
38  QgsExpressionPrivate()
39  : ref( 1 )
40  {}
41 
42  QgsExpressionPrivate( const QgsExpressionPrivate &other )
43  : ref( 1 )
44  , mRootNode( other.mRootNode ? other.mRootNode->clone() : nullptr )
45  , mParserErrorString( other.mParserErrorString )
46  , mEvalErrorString( other.mEvalErrorString )
47  , mParserErrors( other.mParserErrors )
48  , mExp( other.mExp )
49  , mCalc( other.mCalc )
50  , mDistanceUnit( other.mDistanceUnit )
51  , mAreaUnit( other.mAreaUnit )
52  {}
53 
54  ~QgsExpressionPrivate()
55  {
56  delete mRootNode;
57  }
58 
59  QAtomicInt ref;
60 
61  QgsExpressionNode *mRootNode = nullptr;
62 
63  QString mParserErrorString;
64  QString mEvalErrorString;
65 
66  QList<QgsExpression::ParserError> mParserErrors;
67 
68  QString mExp;
69 
70  std::shared_ptr<QgsDistanceArea> mCalc;
73 
75  bool mIsPrepared = false;
76 };
77 
78 
79 struct HelpArg
80 {
81  HelpArg( const QString &arg, const QString &desc, bool descOnly = false, bool syntaxOnly = false,
82  bool optional = false, const QString &defaultVal = QString() )
83  : mArg( arg )
84  , mDescription( desc )
85  , mDescOnly( descOnly )
86  , mSyntaxOnly( syntaxOnly )
87  , mOptional( optional )
88  , mDefaultVal( defaultVal )
89  {}
90 
91  QString mArg;
92  QString mDescription;
93  bool mDescOnly;
94  bool mSyntaxOnly;
95  bool mOptional;
96  QString mDefaultVal;
97 };
98 
99 struct HelpExample
100 {
101  HelpExample( const QString &expression, const QString &returns, const QString &note = QString() )
102  : mExpression( expression )
103  , mReturns( returns )
104  , mNote( note )
105  {}
106 
107  QString mExpression;
108  QString mReturns;
109  QString mNote;
110 };
111 
112 
113 struct HelpVariant
114 {
115  HelpVariant( const QString &name, const QString &description,
116  const QList<HelpArg> &arguments = QList<HelpArg>(),
117  bool variableLenArguments = false,
118  const QList<HelpExample> &examples = QList<HelpExample>(),
119  const QString &notes = QString(),
120  const QStringList &tags = QStringList() )
121  : mName( name )
122  , mDescription( description )
123  , mArguments( arguments )
124  , mVariableLenArguments( variableLenArguments )
125  , mExamples( examples )
126  , mNotes( notes )
127  , mTags( tags )
128  {}
129 
130  QString mName;
131  QString mDescription;
132  QList<HelpArg> mArguments;
133  bool mVariableLenArguments;
134  QList<HelpExample> mExamples;
135  QString mNotes;
136  QStringList mTags;
137 };
138 
139 
140 struct Help
141 {
143  Help() = default;
144 
145  Help( const QString &name, const QString &type, const QString &description, const QList<HelpVariant> &variants )
146  : mName( name )
147  , mType( type )
148  , mDescription( description )
149  , mVariants( variants )
150  {}
151 
152  QString mName;
153  QString mType;
154  QString mDescription;
155  QList<HelpVariant> mVariants;
156 };
157 
158 typedef QHash<QString, Help> HelpTextHash;
159 
160 HelpTextHash &functionHelpTexts();
161 
163 
164 #endif // QGSEXPRESSIONPRIVATE_H
Unknown areal unit.
Definition: qgsunittypes.h:105
Abstract base class for all nodes that can appear in an expression.
DistanceUnit
Units of distance.
Definition: qgsunittypes.h:66
Unknown distance unit.
Definition: qgsunittypes.h:77
HelpTextHash & functionHelpTexts()
AreaUnit
Units of area.
Definition: qgsunittypes.h:92