JsonTreeModel Implementation  v0.1.0
A Qt tree model for visualizing and manipulating a JSON document.
JsonTreeModelNode Class Referenceabstract

JsonTreeModelNode is the base class for the internal data structure behind JsonTreeModel. More...

#include <jsontreemodel.h>

Inheritance diagram for JsonTreeModelNode:
JsonTreeModelListNode JsonTreeModelScalarNode JsonTreeModelNamedListNode JsonTreeModelWrapperNode

Public Types

enum  Type { Scalar, Object, Array }
 This enum describes the type of data represented by a JsonTreeModelNode. More...
 

Public Member Functions

 JsonTreeModelNode (JsonTreeModelNode *parent)
 Constructs a new node with the given parent. More...
 
virtual ~JsonTreeModelNode ()
 Frees the memory held by this node and its children. More...
 
JsonTreeModelNodeparent () const
 Returns this node's parent. More...
 
void setParent (JsonTreeModelNode *parent)
 Makes this node a child of parent. More...
 
virtual Type type () const =0
 
virtual QJsonValue value () const =0
 Returns the JSON value represented by this node and its children (if any). More...
 

Detailed Description

JsonTreeModelNode is the base class for the internal data structure behind JsonTreeModel.

Member Enumeration Documentation

◆ Type

This enum describes the type of data represented by a JsonTreeModelNode.

See also
type()
Enumerator
Scalar 

Represents scalar JSON values (nulls, Booleans, numbers, and strings).

Object 

Represents JSON objects.

Array 

Represents JSON arrays.

Constructor & Destructor Documentation

◆ JsonTreeModelNode()

JsonTreeModelNode::JsonTreeModelNode ( JsonTreeModelNode parent)
inline

Constructs a new node with the given parent.

Note
Only a JsonTreeModelListNode (or one of its subclasses) can be a parent.

◆ ~JsonTreeModelNode()

JsonTreeModelNode::~JsonTreeModelNode ( )
inlinevirtual

Frees the memory held by this node and its children.

Warning
This node is not automatically removed from its parent's list of children.

Member Function Documentation

◆ parent()

JsonTreeModelNode * JsonTreeModelNode::parent ( ) const
inline

Returns this node's parent.

See also
setParent()

◆ setParent()

void JsonTreeModelNode::setParent ( JsonTreeModelNode parent)
inline

Makes this node a child of parent.

Note
Only a JsonTreeModelListNode (or one of its subclasses) can be a parent.
Warning
This function only updates this node's internal pointer to its parent. The caller must manually update the child's registration.
See also
parent()

◆ type()

virtual Type JsonTreeModelNode::type ( ) const
pure virtual

◆ value()

QJsonValue JsonTreeModelNode::value ( ) const
pure virtual

Returns the JSON value represented by this node and its children (if any).

Implemented in JsonTreeModelWrapperNode, JsonTreeModelNamedListNode, JsonTreeModelListNode, and JsonTreeModelScalarNode.


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