Qt 4.8
Public Functions | Static Public Functions | Public Variables | Private Functions | List of all members
Node Class Reference
Inheritance diagram for Node:
Attr CharacterData Document Element Text CDATA

Public Functions

bool isNull () const
 
 Node ()
 
 Node (const Node &o)
 
 ~Node ()
 

Static Public Functions

static QScriptValue attributes (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue childNodes (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue create (QScriptEngine *, NodeImpl *)
 
static QScriptValue firstChild (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue lastChild (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue nextSibling (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue nodeName (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue nodeType (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue nodeValue (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue parentNode (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue previousSibling (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue prototype (QScriptEngine *)
 

Public Variables

NodeImpld
 

Private Functions

Nodeoperator= (const Node &)
 

Detailed Description

Definition at line 224 of file qdeclarativexmlhttprequest.cpp.

Constructors and Destructors

◆ Node() [1/2]

Node::Node ( )

Definition at line 718 of file qdeclarativexmlhttprequest.cpp.

719 : d(0)
720 {
721 }

◆ Node() [2/2]

Node::Node ( const Node o)

Definition at line 723 of file qdeclarativexmlhttprequest.cpp.

724 : d(o.d)
725 {
726  if (d) A(d);
727 }
#define A(arg)

◆ ~Node()

Node::~Node ( )

Definition at line 729 of file qdeclarativexmlhttprequest.cpp.

730 {
731  if (d) D(d);
732 }
#define D(arg)

Functions

◆ attributes()

QScriptValue Node::attributes ( QScriptContext context,
QScriptEngine engine 
)
static

Definition at line 454 of file qdeclarativexmlhttprequest.cpp.

455 {
456  Node node = qscriptvalue_cast<Node>(context->thisObject());
457  if (node.isNull()) return engine->undefinedValue();
458 
459  if (node.d->type != NodeImpl::Element)
460  return engine->nullValue();
461  else
462  return NamedNodeMap::create(engine, node.d, &node.d->attributes);
463 }
T qscriptvalue_cast(const QScriptValue &)
bool isNull() const
QList< NodeImpl * > attributes
static QScriptValue create(QScriptEngine *, NodeImpl *, QList< NodeImpl *> *)
QScriptValue undefinedValue()
Returns a QScriptValue of the primitive type Undefined.
QScriptValue thisObject() const
Returns the `this&#39; object associated with this QScriptContext.
QScriptValue nullValue()
Returns a QScriptValue of the primitive type Null.

◆ childNodes()

QScriptValue Node::childNodes ( QScriptContext context,
QScriptEngine engine 
)
static

Definition at line 394 of file qdeclarativexmlhttprequest.cpp.

395 {
396  Node node = qscriptvalue_cast<Node>(context->thisObject());
397  if (node.isNull()) return engine->undefinedValue();
398 
399  return NodeList::create(engine, node.d);
400 }
static QScriptValue create(QScriptEngine *, NodeImpl *)
T qscriptvalue_cast(const QScriptValue &)
bool isNull() const
QScriptValue undefinedValue()
Returns a QScriptValue of the primitive type Undefined.
QScriptValue thisObject() const
Returns the `this&#39; object associated with this QScriptContext.

◆ create()

QScriptValue Node::create ( QScriptEngine engine,
NodeImpl data 
)
static

Definition at line 483 of file qdeclarativexmlhttprequest.cpp.

Referenced by Document::documentElement(), firstChild(), lastChild(), nextSibling(), Attr::ownerElement(), parentNode(), previousSibling(), NamedNodeMapClass::property(), and NodeListClass::property().

484 {
485  QScriptValue instance = engine->newObject();
486 
487  switch (data->type) {
488  case NodeImpl::Attr:
489  instance.setPrototype(Attr::prototype(engine));
490  break;
491  case NodeImpl::Comment:
492  case NodeImpl::Document:
495  case NodeImpl::Entity:
497  case NodeImpl::Notation:
499  return QScriptValue();
500  case NodeImpl::CDATA:
501  instance.setPrototype(CDATA::prototype(engine));
502  break;
503  case NodeImpl::Text:
504  instance.setPrototype(Text::prototype(engine));
505  break;
506  case NodeImpl::Element:
507  instance.setPrototype(Element::prototype(engine));
508  break;
509  }
510 
511  Node node;
512  node.d = data;
513  if (data) A(data);
514 
515  return engine->newVariant(instance, QVariant::fromValue(node));
516 }
static QScriptValue prototype(QScriptEngine *)
static QScriptValue prototype(QScriptEngine *)
#define A(arg)
static const char * data(const QByteArray &arr)
QScriptValue newObject()
Creates a QtScript object of class Object.
static QScriptValue prototype(QScriptEngine *)
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
void setPrototype(const QScriptValue &prototype)
If this QScriptValue is an object, sets the internal prototype (__proto__ property) of this object to...
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
QScriptValue newVariant(const QVariant &value)
Creates a QtScript object holding the given variant value.
static QScriptValue prototype(QScriptEngine *)

◆ firstChild()

QScriptValue Node::firstChild ( QScriptContext context,
QScriptEngine engine 
)
static

Definition at line 402 of file qdeclarativexmlhttprequest.cpp.

403 {
404  Node node = qscriptvalue_cast<Node>(context->thisObject());
405  if (node.isNull()) return engine->undefinedValue();
406 
407  if (node.d->children.isEmpty()) return engine->nullValue();
408  else return Node::create(engine, node.d->children.first());
409 }
T qscriptvalue_cast(const QScriptValue &)
bool isNull() const
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QList< NodeImpl * > children
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
static QScriptValue create(QScriptEngine *, NodeImpl *)
QScriptValue undefinedValue()
Returns a QScriptValue of the primitive type Undefined.
QScriptValue thisObject() const
Returns the `this&#39; object associated with this QScriptContext.
QScriptValue nullValue()
Returns a QScriptValue of the primitive type Null.

◆ isNull()

bool Node::isNull ( ) const

◆ lastChild()

QScriptValue Node::lastChild ( QScriptContext context,
QScriptEngine engine 
)
static

Definition at line 411 of file qdeclarativexmlhttprequest.cpp.

412 {
413  Node node = qscriptvalue_cast<Node>(context->thisObject());
414  if (node.isNull()) return engine->undefinedValue();
415 
416  if (node.d->children.isEmpty()) return engine->nullValue();
417  else return Node::create(engine, node.d->children.last());
418 }
T qscriptvalue_cast(const QScriptValue &)
bool isNull() const
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QList< NodeImpl * > children
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
static QScriptValue create(QScriptEngine *, NodeImpl *)
QScriptValue undefinedValue()
Returns a QScriptValue of the primitive type Undefined.
QScriptValue thisObject() const
Returns the `this&#39; object associated with this QScriptContext.
QScriptValue nullValue()
Returns a QScriptValue of the primitive type Null.

◆ nextSibling()

QScriptValue Node::nextSibling ( QScriptContext context,
QScriptEngine engine 
)
static

Definition at line 437 of file qdeclarativexmlhttprequest.cpp.

438 {
439  Node node = qscriptvalue_cast<Node>(context->thisObject());
440  if (node.isNull()) return engine->undefinedValue();
441 
442  if (!node.d->parent) return engine->nullValue();
443 
444  for (int ii = 0; ii < node.d->parent->children.count(); ++ii) {
445  if (node.d->parent->children.at(ii) == node.d) {
446  if ((ii + 1) == node.d->parent->children.count()) return engine->nullValue();
447  else return Node::create(engine, node.d->parent->children.at(ii + 1));
448  }
449  }
450 
451  return engine->nullValue();
452 }
T qscriptvalue_cast(const QScriptValue &)
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
bool isNull() const
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QList< NodeImpl * > children
static QScriptValue create(QScriptEngine *, NodeImpl *)
QScriptValue undefinedValue()
Returns a QScriptValue of the primitive type Undefined.
QScriptValue thisObject() const
Returns the `this&#39; object associated with this QScriptContext.
QScriptValue nullValue()
Returns a QScriptValue of the primitive type Null.

◆ nodeName()

QScriptValue Node::nodeName ( QScriptContext context,
QScriptEngine engine 
)
static

Definition at line 344 of file qdeclarativexmlhttprequest.cpp.

345 {
346  Node node = qscriptvalue_cast<Node>(context->thisObject());
347  if (node.isNull()) return engine->undefinedValue();
348 
349  switch (node.d->type) {
350  case NodeImpl::Document:
351  return QScriptValue(QLatin1String("#document"));
352  case NodeImpl::CDATA:
353  return QScriptValue(QLatin1String("#cdata-section"));
354  case NodeImpl::Text:
355  return QScriptValue(QLatin1String("#text"));
356  default:
357  return QScriptValue(node.d->name);
358  }
359 }
T qscriptvalue_cast(const QScriptValue &)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool isNull() const
QScriptValue undefinedValue()
Returns a QScriptValue of the primitive type Undefined.
QScriptValue thisObject() const
Returns the `this&#39; object associated with this QScriptContext.
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57

◆ nodeType()

QScriptValue Node::nodeType ( QScriptContext context,
QScriptEngine engine 
)
static

Definition at line 378 of file qdeclarativexmlhttprequest.cpp.

379 {
380  Node node = qscriptvalue_cast<Node>(context->thisObject());
381  if (node.isNull()) return engine->undefinedValue();
382  return QScriptValue(node.d->type);
383 }
T qscriptvalue_cast(const QScriptValue &)
bool isNull() const
QScriptValue undefinedValue()
Returns a QScriptValue of the primitive type Undefined.
QScriptValue thisObject() const
Returns the `this&#39; object associated with this QScriptContext.
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57

◆ nodeValue()

QScriptValue Node::nodeValue ( QScriptContext context,
QScriptEngine engine 
)
static

Definition at line 361 of file qdeclarativexmlhttprequest.cpp.

362 {
363  Node node = qscriptvalue_cast<Node>(context->thisObject());
364  if (node.isNull()) return engine->undefinedValue();
365 
366  if (node.d->type == NodeImpl::Document ||
367  node.d->type == NodeImpl::DocumentFragment ||
368  node.d->type == NodeImpl::DocumentType ||
369  node.d->type == NodeImpl::Element ||
370  node.d->type == NodeImpl::Entity ||
371  node.d->type == NodeImpl::EntityReference ||
372  node.d->type == NodeImpl::Notation)
373  return engine->nullValue();
374 
375  return QScriptValue(node.d->data);
376 }
T qscriptvalue_cast(const QScriptValue &)
bool isNull() const
QScriptValue undefinedValue()
Returns a QScriptValue of the primitive type Undefined.
QScriptValue thisObject() const
Returns the `this&#39; object associated with this QScriptContext.
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
QScriptValue nullValue()
Returns a QScriptValue of the primitive type Null.

◆ operator=()

Node& Node::operator= ( const Node )
private

◆ parentNode()

QScriptValue Node::parentNode ( QScriptContext context,
QScriptEngine engine 
)
static

Definition at line 385 of file qdeclarativexmlhttprequest.cpp.

386 {
387  Node node = qscriptvalue_cast<Node>(context->thisObject());
388  if (node.isNull()) return engine->undefinedValue();
389 
390  if (node.d->parent) return Node::create(engine, node.d->parent);
391  else return engine->nullValue();
392 }
T qscriptvalue_cast(const QScriptValue &)
bool isNull() const
static QScriptValue create(QScriptEngine *, NodeImpl *)
QScriptValue undefinedValue()
Returns a QScriptValue of the primitive type Undefined.
QScriptValue thisObject() const
Returns the `this&#39; object associated with this QScriptContext.
QScriptValue nullValue()
Returns a QScriptValue of the primitive type Null.

◆ previousSibling()

QScriptValue Node::previousSibling ( QScriptContext context,
QScriptEngine engine 
)
static

Definition at line 420 of file qdeclarativexmlhttprequest.cpp.

421 {
422  Node node = qscriptvalue_cast<Node>(context->thisObject());
423  if (node.isNull()) return engine->undefinedValue();
424 
425  if (!node.d->parent) return engine->nullValue();
426 
427  for (int ii = 0; ii < node.d->parent->children.count(); ++ii) {
428  if (node.d->parent->children.at(ii) == node.d) {
429  if (ii == 0) return engine->nullValue();
430  else return Node::create(engine, node.d->parent->children.at(ii - 1));
431  }
432  }
433 
434  return engine->nullValue();
435 }
T qscriptvalue_cast(const QScriptValue &)
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
bool isNull() const
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QList< NodeImpl * > children
static QScriptValue create(QScriptEngine *, NodeImpl *)
QScriptValue undefinedValue()
Returns a QScriptValue of the primitive type Undefined.
QScriptValue thisObject() const
Returns the `this&#39; object associated with this QScriptContext.
QScriptValue nullValue()
Returns a QScriptValue of the primitive type Null.

◆ prototype()

QScriptValue Node::prototype ( QScriptEngine engine)
static

Definition at line 465 of file qdeclarativexmlhttprequest.cpp.

Referenced by Element::prototype(), Attr::prototype(), CharacterData::prototype(), and Document::prototype().

466 {
467  QScriptValue proto = engine->newObject();
468 
479 
480  return proto;
481 }
QScriptValue newFunction(FunctionSignature signature, int length=0)
Creates a QScriptValue that wraps a native (C++) function.
static QScriptValue nextSibling(QScriptContext *context, QScriptEngine *engine)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QScriptValue nodeName(QScriptContext *context, QScriptEngine *engine)
static QScriptValue nodeValue(QScriptContext *context, QScriptEngine *engine)
static QScriptValue attributes(QScriptContext *context, QScriptEngine *engine)
static QScriptValue childNodes(QScriptContext *context, QScriptEngine *engine)
QScriptValue newObject()
Creates a QtScript object of class Object.
static QScriptValue parentNode(QScriptContext *context, QScriptEngine *engine)
static QScriptValue previousSibling(QScriptContext *context, QScriptEngine *engine)
void setProperty(const QString &name, const QScriptValue &value, const PropertyFlags &flags=KeepExistingFlags)
Sets the value of this QScriptValue&#39;s property with the given name to the given value.
static QScriptValue firstChild(QScriptContext *context, QScriptEngine *engine)
static QScriptValue lastChild(QScriptContext *context, QScriptEngine *engine)
static QScriptValue nodeType(QScriptContext *context, QScriptEngine *engine)
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57

Properties

◆ d

NodeImpl* Node::d

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