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

The QScriptScriptData class holds data associated with a script. More...

#include <qscriptscriptdata_p.h>

Public Functions

int baseLineNumber () const
 
QString contents () const
 
QString fileName () const
 
bool isValid () const
 
QStringList lines (int startLineNumber, int count) const
 
bool operator!= (const QScriptScriptData &other) const
 
QScriptScriptDataoperator= (const QScriptScriptData &other)
 
bool operator== (const QScriptScriptData &other) const
 
 QScriptScriptData ()
 
 QScriptScriptData (const QString &contents, const QString &fileName, int baseLineNumber, const QDateTime &timeStamp=QDateTime())
 
 QScriptScriptData (const QScriptScriptData &other)
 
QDateTime timeStamp () const
 
 ~QScriptScriptData ()
 

Properties

QScopedSharedPointer< QScriptScriptDataPrivated_ptr
 

Friends

Q_AUTOTEST_EXPORT QDataStreamoperator<< (QDataStream &, const QScriptScriptData &)
 
Q_AUTOTEST_EXPORT QDataStreamoperator>> (QDataStream &, QScriptScriptData &)
 

Detailed Description

The QScriptScriptData class holds data associated with a script.

Since
4.5
Warning
This function is not part of the public interface.

Definition at line 68 of file qscriptscriptdata_p.h.

Constructors and Destructors

◆ QScriptScriptData() [1/3]

QScriptScriptData::QScriptScriptData ( )

Definition at line 84 of file qscriptscriptdata.cpp.

85  : d_ptr(0)
86 {
87 }
QScopedSharedPointer< QScriptScriptDataPrivate > d_ptr

◆ QScriptScriptData() [2/3]

QScriptScriptData::QScriptScriptData ( const QString contents,
const QString fileName,
int  baseLineNumber,
const QDateTime timeStamp = QDateTime() 
)

Definition at line 89 of file qscriptscriptdata.cpp.

92 {
93  d_ptr->contents = contents;
94  d_ptr->fileName = fileName;
95  d_ptr->baseLineNumber = baseLineNumber;
96  if (timeStamp.isValid())
97  d_ptr->timeStamp = timeStamp;
98  else
99  d_ptr->timeStamp = QDateTime::currentDateTime();
100  d_ptr->ref.ref();
101 }
bool isValid() const
Returns true if both the date and the time are valid; otherwise returns false.
Definition: qdatetime.cpp:2346
QScopedSharedPointer< QScriptScriptDataPrivate > d_ptr
static QDateTime currentDateTime()
Returns the current datetime, as reported by the system clock, in the local time zone.
Definition: qdatetime.cpp:3138
QString contents() const
QString fileName() const

◆ QScriptScriptData() [3/3]

QScriptScriptData::QScriptScriptData ( const QScriptScriptData other)

Definition at line 103 of file qscriptscriptdata.cpp.

104  : d_ptr(other.d_ptr.data())
105 {
106  if (d_ptr)
107  d_ptr->ref.ref();
108 }
T * data() const
Returns the value of the pointer referenced by this object.
QScopedSharedPointer< QScriptScriptDataPrivate > d_ptr

◆ ~QScriptScriptData()

QScriptScriptData::~QScriptScriptData ( )

Definition at line 110 of file qscriptscriptdata.cpp.

111 {
112 }

Functions

◆ baseLineNumber()

int QScriptScriptData::baseLineNumber ( ) const

Definition at line 145 of file qscriptscriptdata.cpp.

Referenced by QScriptDebuggerScriptsModel::data(), QScriptScriptData(), scriptDataToScriptValue(), and QScriptDebuggerCodeWidget::setCurrentScript().

146 {
147  Q_D(const QScriptScriptData);
148  if (!d)
149  return -1;
150  return d->baseLineNumber;
151 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptScriptData class holds data associated with a script.

◆ contents()

QString QScriptScriptData::contents ( ) const

Definition at line 120 of file qscriptscriptdata.cpp.

Referenced by QScriptDebuggerScriptsModel::data(), QScriptScriptData(), scriptDataToScriptValue(), and QScriptDebuggerCodeWidget::setCurrentScript().

121 {
122  Q_D(const QScriptScriptData);
123  if (!d)
124  return QString();
125  return d->contents;
126 }
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 QScriptScriptData class holds data associated with a script.

◆ fileName()

QString QScriptScriptData::fileName ( ) const

◆ isValid()

bool QScriptScriptData::isValid ( ) const

Definition at line 161 of file qscriptscriptdata.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute(), and QScriptDebuggerCodeWidget::setCurrentScript().

162 {
163  Q_D(const QScriptScriptData);
164  return (d != 0);
165 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptScriptData class holds data associated with a script.

◆ lines()

QStringList QScriptScriptData::lines ( int  startLineNumber,
int  count 
) const

Definition at line 128 of file qscriptscriptdata.cpp.

Referenced by QScriptDebuggerShowLineJob::handleResponse().

129 {
130  Q_D(const QScriptScriptData);
131  if (!d)
132  return QStringList();
133  QStringList allLines = d->contents.split(QLatin1Char('\n'));
134  return allLines.mid(qMax(0, startLineNumber - d->baseLineNumber), count);
135 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QList< T > mid(int pos, int length=-1) const
Returns a list whose elements are copied from this list, starting at position pos.
Definition: qlist.h:637
The QScriptScriptData class holds data associated with a script.
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ operator!=()

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

Definition at line 180 of file qscriptscriptdata.cpp.

181 {
182  return !(*this == other);
183 }

◆ operator=()

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

Definition at line 114 of file qscriptscriptdata.cpp.

115 {
116  d_ptr.assign(other.d_ptr.data());
117  return *this;
118 }
T * data() const
Returns the value of the pointer referenced by this object.
QScopedSharedPointer< QScriptScriptDataPrivate > d_ptr

◆ operator==()

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

Definition at line 167 of file qscriptscriptdata.cpp.

168 {
169  Q_D(const QScriptScriptData);
170  const QScriptScriptDataPrivate *od = other.d_func();
171  if (d == od)
172  return true;
173  if (!d || !od)
174  return false;
175  return ((d->contents == od->contents)
176  && (d->fileName == od->fileName)
177  && (d->baseLineNumber == od->baseLineNumber));
178 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptScriptData class holds data associated with a script.

◆ timeStamp()

QDateTime QScriptScriptData::timeStamp ( ) const

Definition at line 153 of file qscriptscriptdata.cpp.

154 {
155  Q_D(const QScriptScriptData);
156  if (!d)
157  return QDateTime();
158  return d->timeStamp;
159 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptScriptData class holds data associated with a script.
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216

Friends and Related Functions

◆ operator<<

Q_AUTOTEST_EXPORT QDataStream& operator<< ( QDataStream ,
const QScriptScriptData  
)
friend

Definition at line 185 of file qscriptscriptdata.cpp.

186 {
187  const QScriptScriptDataPrivate *d = data.d_ptr.data();
188  if (d) {
189  out << d->contents;
190  out << d->fileName;
191  out << qint32(d->baseLineNumber);
192  } else {
193  out << QString();
194  out << QString();
195  out << qint32(0);
196  }
197  return out;
198 }
double d
Definition: qnumeric_p.h:62
int qint32
Definition: qglobal.h:937
T * data() const
Returns the value of the pointer referenced by this object.
The QString class provides a Unicode character string.
Definition: qstring.h:83
QScopedSharedPointer< QScriptScriptDataPrivate > d_ptr

◆ operator>>

Q_AUTOTEST_EXPORT QDataStream& operator>> ( QDataStream ,
QScriptScriptData  
)
friend

Definition at line 200 of file qscriptscriptdata.cpp.

201 {
202  if (!data.d_ptr) {
204  data.d_ptr->ref.ref();
205  }
207  in >> d->contents;
208  in >> d->fileName;
209  qint32 ln;
210  in >> ln;
211  d->baseLineNumber = ln;
212  return in;
213 }
double d
Definition: qnumeric_p.h:62
int qint32
Definition: qglobal.h:937
T * data() const
Returns the value of the pointer referenced by this object.
void reset(T *other=0)
Deletes the existing object it is pointing to if any, and sets its pointer to other.
QScopedSharedPointer< QScriptScriptDataPrivate > d_ptr

Properties

◆ d_ptr

QScopedSharedPointer<QScriptScriptDataPrivate> QScriptScriptData::d_ptr
private

Definition at line 94 of file qscriptscriptdata_p.h.

Referenced by operator<<(), operator=(), operator>>(), and QScriptScriptData().


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