QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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  , mDaEllipsoid( other.mDaEllipsoid )
50  , mDaCrs( other.mDaCrs )
51  , mDaTransformContext( other.mDaTransformContext )
52  , mCalc( other.mCalc )
53  , mDistanceUnit( other.mDistanceUnit )
54  , mAreaUnit( other.mAreaUnit )
55  {}
56 
57  ~QgsExpressionPrivate()
58  {
59  delete mRootNode;
60  }
61 
62  QAtomicInt ref;
63 
64  QgsExpressionNode *mRootNode = nullptr;
65 
66  QString mParserErrorString;
67  QString mEvalErrorString;
68 
69  QList<QgsExpression::ParserError> mParserErrors;
70 
71  QString mExp;
72 
73  QString mDaEllipsoid;
75  QgsCoordinateTransformContext mDaTransformContext;
76 
77  std::shared_ptr<QgsDistanceArea> mCalc;
80 
82  bool mIsPrepared = false;
83 
84  QgsExpressionPrivate &operator= ( const QgsExpressionPrivate & ) = delete;
85 };
86 
87 
88 struct HelpArg
89 {
90  HelpArg( const QString &arg, const QString &desc, bool descOnly = false, bool syntaxOnly = false,
91  bool optional = false, const QString &defaultVal = QString() )
92  : mArg( arg )
93  , mDescription( desc )
94  , mDescOnly( descOnly )
95  , mSyntaxOnly( syntaxOnly )
96  , mOptional( optional )
97  , mDefaultVal( defaultVal )
98  {}
99 
100  QString mArg;
101  QString mDescription;
102  bool mDescOnly;
103  bool mSyntaxOnly;
104  bool mOptional;
105  QString mDefaultVal;
106 };
107 
108 struct HelpExample
109 {
110  HelpExample( const QString &expression, const QString &returns, const QString &note = QString() )
111  : mExpression( expression )
112  , mReturns( returns )
113  , mNote( note )
114  {}
115 
116  QString mExpression;
117  QString mReturns;
118  QString mNote;
119 };
120 
121 
122 struct HelpVariant
123 {
124  HelpVariant( const QString &name, const QString &description,
125  const QList<HelpArg> &arguments = QList<HelpArg>(),
126  bool variableLenArguments = false,
127  const QList<HelpExample> &examples = QList<HelpExample>(),
128  const QString &notes = QString(),
129  const QStringList &tags = QStringList() )
130  : mName( name )
131  , mDescription( description )
132  , mArguments( arguments )
133  , mVariableLenArguments( variableLenArguments )
134  , mExamples( examples )
135  , mNotes( notes )
136  , mTags( tags )
137  {}
138 
139  QString mName;
140  QString mDescription;
141  QList<HelpArg> mArguments;
142  bool mVariableLenArguments;
143  QList<HelpExample> mExamples;
144  QString mNotes;
145  QStringList mTags;
146 };
147 
148 
149 struct Help
150 {
152  Help() = default;
153 
154  Help( const QString &name, const QString &type, const QString &description, const QList<HelpVariant> &variants )
155  : mName( name )
156  , mType( type )
157  , mDescription( description )
158  , mVariants( variants )
159  {}
160 
161  QString mName;
162  QString mType;
163  QString mDescription;
164  QList<HelpVariant> mVariants;
165 };
166 
167 typedef QHash<QString, Help> HelpTextHash;
168 
169 HelpTextHash &functionHelpTexts();
170 
172 
173 #endif // QGSEXPRESSIONPRIVATE_H
QgsCoordinateTransformContext
Definition: qgscoordinatetransformcontext.h:57
QgsUnitTypes::DistanceUnknownUnit
@ DistanceUnknownUnit
Unknown distance unit.
Definition: qgsunittypes.h:78
qgsexpression.h
qgsunittypes.h
QgsUnitTypes::DistanceUnit
DistanceUnit
Units of distance.
Definition: qgsunittypes.h:67
qgsexpressionnode.h
QgsUnitTypes::AreaUnit
AreaUnit
Units of area.
Definition: qgsunittypes.h:93
QgsCoordinateReferenceSystem
Definition: qgscoordinatereferencesystem.h:206
QgsExpressionNode
Definition: qgsexpressionnode.h:34
functionHelpTexts
HelpTextHash & functionHelpTexts()
Definition: qgsexpression.cpp:35
qgsdistancearea.h
QgsUnitTypes::AreaUnknownUnit
@ AreaUnknownUnit
Unknown areal unit.
Definition: qgsunittypes.h:106