Qt 4.8
Public Functions | Properties | List of all members
QScriptProgram Class Reference

The QScriptProgram class encapsulates a Qt Script program. More...

#include <qscriptprogram.h>

Public Functions

QString fileName () const
 Returns the filename associated with this program. More...
 
int firstLineNumber () const
 Returns the line number associated with this program. More...
 
bool isNull () const
 Returns true if this QScriptProgram is null; otherwise returns false. More...
 
bool operator!= (const QScriptProgram &other) const
 Returns true if this QScriptProgram is not equal to other; otherwise returns false. More...
 
QScriptProgramoperator= (const QScriptProgram &other)
 Assigns the other value to this QScriptProgram. More...
 
bool operator== (const QScriptProgram &other) const
 Returns true if this QScriptProgram is equal to other; otherwise returns false. More...
 
 QScriptProgram ()
 Constructs a null QScriptProgram. More...
 
 QScriptProgram (const QString &sourceCode, const QString fileName=QString(), int firstLineNumber=1)
 Constructs a new QScriptProgram with the given sourceCode, fileName and firstLineNumber. More...
 
 QScriptProgram (const QScriptProgram &other)
 Constructs a new QScriptProgram that is a copy of other. More...
 
QString sourceCode () const
 Returns the source code of this program. More...
 
 ~QScriptProgram ()
 Destroys this QScriptProgram. More...
 

Properties

QExplicitlySharedDataPointer< QScriptProgramPrivated_ptr
 

Detailed Description

The QScriptProgram class encapsulates a Qt Script program.

Since
4.7

QScriptProgram retains the compiled representation of the script if possible. Thus, QScriptProgram can be used to evaluate the same script multiple times more efficiently.

QScriptProgram program("1 + 2");
QScriptValue result = engine.evaluate(program);

Definition at line 38 of file qscriptprogram.h.

Constructors and Destructors

◆ QScriptProgram() [1/3]

QScriptProgram::QScriptProgram ( )

Constructs a null QScriptProgram.

Definition at line 113 of file qscriptprogram.cpp.

114  : d_ptr(0)
115 {
116 }
QExplicitlySharedDataPointer< QScriptProgramPrivate > d_ptr

◆ QScriptProgram() [2/3]

QScriptProgram::QScriptProgram ( const QString sourceCode,
const QString  fileName = QString(),
int  firstLineNumber = 1 
)

Constructs a new QScriptProgram with the given sourceCode, fileName and firstLineNumber.

Definition at line 122 of file qscriptprogram.cpp.

125  : d_ptr(new QScriptProgramPrivate(sourceCode, fileName, firstLineNumber))
126 {
127 }
QExplicitlySharedDataPointer< QScriptProgramPrivate > d_ptr
int firstLineNumber() const
Returns the line number associated with this program.

◆ QScriptProgram() [3/3]

QScriptProgram::QScriptProgram ( const QScriptProgram other)

Constructs a new QScriptProgram that is a copy of other.

Definition at line 132 of file qscriptprogram.cpp.

133  : d_ptr(other.d_ptr)
134 {
135 }
QExplicitlySharedDataPointer< QScriptProgramPrivate > d_ptr

◆ ~QScriptProgram()

QScriptProgram::~QScriptProgram ( )

Destroys this QScriptProgram.

Definition at line 140 of file qscriptprogram.cpp.

141 {
142 }

Functions

◆ fileName()

QString QScriptProgram::fileName ( ) const

Returns the filename associated with this program.

Definition at line 177 of file qscriptprogram.cpp.

Referenced by operator==().

178 {
179  Q_D(const QScriptProgram);
180  if (!d)
181  return QString();
182  return d->fileName;
183 }
double d
Definition: qnumeric_p.h:62
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptProgram class encapsulates a Qt Script program.

◆ firstLineNumber()

int QScriptProgram::firstLineNumber ( ) const

Returns the line number associated with this program.

Definition at line 188 of file qscriptprogram.cpp.

Referenced by operator==().

189 {
190  Q_D(const QScriptProgram);
191  if (!d)
192  return -1;
193  return d->firstLineNumber;
194 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptProgram class encapsulates a Qt Script program.

◆ isNull()

bool QScriptProgram::isNull ( ) const

Returns true if this QScriptProgram is null; otherwise returns false.

Definition at line 157 of file qscriptprogram.cpp.

158 {
159  Q_D(const QScriptProgram);
160  return (d == 0);
161 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptProgram class encapsulates a Qt Script program.

◆ operator!=()

bool QScriptProgram::operator!= ( const QScriptProgram other) const

Returns true if this QScriptProgram is not equal to other; otherwise returns false.

Definition at line 214 of file qscriptprogram.cpp.

215 {
216  return !operator==(other);
217 }
bool operator==(const QScriptProgram &other) const
Returns true if this QScriptProgram is equal to other; otherwise returns false.

◆ operator=()

QScriptProgram & QScriptProgram::operator= ( const QScriptProgram other)

Assigns the other value to this QScriptProgram.

Definition at line 147 of file qscriptprogram.cpp.

148 {
149  d_ptr = other.d_ptr;
150  return *this;
151 }
QExplicitlySharedDataPointer< QScriptProgramPrivate > d_ptr

◆ operator==()

bool QScriptProgram::operator== ( const QScriptProgram other) const

Returns true if this QScriptProgram is equal to other; otherwise returns false.

Definition at line 200 of file qscriptprogram.cpp.

Referenced by operator!=().

201 {
202  Q_D(const QScriptProgram);
203  if (d == other.d_func())
204  return true;
205  return (sourceCode() == other.sourceCode())
206  && (fileName() == other.fileName())
207  && (firstLineNumber() == other.firstLineNumber());
208 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QString sourceCode() const
Returns the source code of this program.
QString fileName() const
Returns the filename associated with this program.
The QScriptProgram class encapsulates a Qt Script program.
int firstLineNumber() const
Returns the line number associated with this program.

◆ sourceCode()

QString QScriptProgram::sourceCode ( ) const

Returns the source code of this program.

Definition at line 166 of file qscriptprogram.cpp.

Referenced by operator==().

167 {
168  Q_D(const QScriptProgram);
169  if (!d)
170  return QString();
171  return d->sourceCode;
172 }
double d
Definition: qnumeric_p.h:62
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptProgram class encapsulates a Qt Script program.

Properties

◆ d_ptr

QExplicitlySharedDataPointer<QScriptProgramPrivate> QScriptProgram::d_ptr
private

Definition at line 60 of file qscriptprogram.h.

Referenced by operator=().


The documentation for this class was generated from the following files: