QGIS API Documentation
4.3.0-Master (1c7cf7431bd)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
qgspythonrunner.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgspythonrunner.h
3
---------------------
4
begin : May 2011
5
copyright : (C) 2011 by Martin Dobias
6
email : wonder dot sk at gmail dot com
7
***************************************************************************
8
* *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
13
* *
14
***************************************************************************/
15
#ifndef QGSPYTHONRUNNER_H
16
#define QGSPYTHONRUNNER_H
17
18
#include "qgis_core.h"
19
#include "
qgis_sip.h
"
20
21
#include <QString>
22
32
class
CORE_EXPORT
QgsPythonRunner
33
{
34
public
:
39
static
bool
isValid
();
40
42
static
bool
run
(
const
QString &command,
const
QString &messageOnError = QString() );
43
48
static
bool
runFile
(
const
QString &filename,
const
QString &messageOnError = QString() );
49
51
static
bool
eval
(
const
QString &command, QString &result
SIP_OUT
);
52
54
static
bool
setArgv
(
const
QStringList &arguments,
const
QString &messageOnError = QString() );
55
61
static
void
setInstance
(
QgsPythonRunner
*runner
SIP_TRANSFER
);
62
63
protected
:
65
QgsPythonRunner
() =
default
;
66
virtual
~QgsPythonRunner
() =
default
;
67
69
virtual
bool
runCommand
( QString command, QString messageOnError = QString() ) = 0;
70
72
virtual
bool
runFileCommand
(
const
QString &filename,
const
QString &messageOnError = QString() ) = 0;
73
75
virtual
bool
evalCommand
( QString command, QString &result ) = 0;
76
78
virtual
bool
setArgvCommand
(
const
QStringList &arguments,
const
QString &messageOnError = QString() ) = 0;
79
80
static
QgsPythonRunner
*
sInstance
;
81
};
82
83
#endif
// QGSPYTHONRUNNER_H
QgsPythonRunner::setArgv
static bool setArgv(const QStringList &arguments, const QString &messageOnError=QString())
Set sys.argv.
Definition
qgspythonrunner.cpp:74
QgsPythonRunner::run
static bool run(const QString &command, const QString &messageOnError=QString())
Execute a Python statement.
Definition
qgspythonrunner.cpp:33
QgsPythonRunner::evalCommand
virtual bool evalCommand(QString command, QString &result)=0
Evaluates the given expression, producing a result.
QgsPythonRunner::runFileCommand
virtual bool runFileCommand(const QString &filename, const QString &messageOnError=QString())=0
Runs the code from the given file.
QgsPythonRunner::setInstance
static void setInstance(QgsPythonRunner *runner)
Assign an instance of Python runner so that run() can be used.
Definition
qgspythonrunner.cpp:87
QgsPythonRunner::eval
static bool eval(const QString &command, QString &result)
Eval a Python statement.
Definition
qgspythonrunner.cpp:61
QgsPythonRunner::runCommand
virtual bool runCommand(QString command, QString messageOnError=QString())=0
Runs the given statement.
QgsPythonRunner::~QgsPythonRunner
virtual ~QgsPythonRunner()=default
QgsPythonRunner::setArgvCommand
virtual bool setArgvCommand(const QStringList &arguments, const QString &messageOnError=QString())=0
Sets sys.argv to the given arguments.
QgsPythonRunner::sInstance
static QgsPythonRunner * sInstance
Definition
qgspythonrunner.h:80
QgsPythonRunner::runFile
static bool runFile(const QString &filename, const QString &messageOnError=QString())
Execute a Python filename, showing an error message if one occurred.
Definition
qgspythonrunner.cpp:47
QgsPythonRunner::isValid
static bool isValid()
Returns true if the runner has an instance (and thus is able to run commands).
Definition
qgspythonrunner.cpp:28
QgsPythonRunner::QgsPythonRunner
QgsPythonRunner()=default
Protected constructor: can be instantiated only from children.
qgis_sip.h
SIP_TRANSFER
#define SIP_TRANSFER
Definition
qgis_sip.h:35
SIP_OUT
#define SIP_OUT
Definition
qgis_sip.h:57
Generated on
for QGIS API Documentation by
1.17.0