Data Class Reference
[Data]

#include <data.h>

Collaboration diagram for Data:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Data ()
 Data (const Data &data)
 Data (const DataClass &blah)
Dataoperator= (const Data &from)
 ~Data ()
QString type () const
bool isNull () const
 operator Symbol () const
 operator Token () const
 operator String () const
Dataoperator+= (const Data &)
Dataoperator-= (const Data &)
Dataoperator/= (const Data &)
Dataoperator*= (const Data &)
bool & operator!= (const Data &)
Data getField (QString s)
void setField (QString s, Data v)
bool & operator== (const Data &)

Public Attributes

 BASIC_TYPES
 ARRAY_TYPES

Protected Member Functions

void type_error (QString expected) const
void visit (DataVisitor &v)

Protected Attributes

DataClasscontent

Friends

class DataClass
class DataVisitor

Detailed Description

The class 'Data' represents a generic dataclass. It will take care to count the references of the content it refers to and will deallocate when the reference counter reaches zero. It will also automatically copy local allocated objects towards the heap when necessary.

All data is shared explicitly, thus a dataclass can be passed along as if it were a pointer itself. The content will be explicitly shared. Data should never be assigned in such a way that loops occur.

The dataclass provides functions for easy downcasting, with automatically included runtime type-check.

The data class is not supposed to have subclasses since it merely forms a wrapper around the actual content, which should be subclassed from the class 'DataClass'


Constructor & Destructor Documentation

Data::Data (  ) 

Will create a data object with Null as contents

References content.

Data::Data ( const Data data  ) 

Will copy the data by taking a memory copy of the content. If the content is not yet allocated on the heap it will be copied as well. The copy is only of the internal references. The data objects behave explicitly shared.

References assert(), and content.

Data::Data ( const DataClass blah  ) 

Will take a copy of the given class, which can be anything, ranging from Null, Numbers, Floats, Arrays to Tokens... The copy is only of the internal references. The data objects behave explicitly shared.

References content.

Data::~Data (  ) 

Will decrease the reference count.

References assert(), and content.


Member Function Documentation

Data Data::getField ( QString  s  ) 

Value retrieval by string reference

References assert(), content, and DataClass::getField().

bool Data::isNull (  )  const

true if the type of the content is Null false otherwise

Referenced by Index::read_idx().

Data::operator String (  )  const

Converts the data to a String by passing it back as a String value. If the type is not a symbol a type_error is cast

References assert(), and content.

Data::operator Symbol (  )  const

Converts the data to a Symbol by passing it back as a Symbol value. If the type is not a symbol a type_error is cast

References content, and type_error().

Data::operator Token (  )  const

Converts the data to a Token by passing it back as a Token value. If the type is not a symbol a type_error is cast

References content, and type_error().

bool& Data::operator!= ( const Data  )  [inline]

Empty function at the moment. Will assert itself. This function is necessary to allow the array templates to compile properly

References assert().

Data& Data::operator*= ( const Data  )  [inline]

Empty function at the moment. Will assert itself. This function is necessary to allow the array templates to compile properly

References assert().

Data& Data::operator+= ( const Data  )  [inline]

Empty function at the moment. Will assert itself. This function is necessary to allow the array templates to compile properly

References assert().

Data& Data::operator-= ( const Data  )  [inline]

Empty function at the moment. Will assert itself. This function is necessary to allow the array templates to compile properly

References assert().

Data& Data::operator/= ( const Data  )  [inline]

Empty function at the moment. Will assert itself. This function is necessary to allow the array templates to compile properly

References assert().

Data & Data::operator= ( const Data from  ) 

Will assign to this class by releasing the old content and refitting it with a pointer to the new. Reference counts are updated automatically.

References content.

bool& Data::operator== ( const Data  )  [inline]

Empty function at the moment. Will assert itself. This function is necessary to allow the array templates to compile properly

References assert().

void Data::setField ( QString  s,
Data  v 
)

Setting the values

References assert(), content, and DataClass::setField().

QString Data::type (  )  const [inline]

Returns the type string of the data as a QString

References content, and DataClass::type_name().

Referenced by type_error().

void Data::type_error ( QString  expected  )  const [protected]

called when a type error occurs. Currently this function exits the program

References assert(), data, printf(), and type().

Referenced by operator Symbol(), and operator Token().

void Data::visit ( DataVisitor v  )  [protected]

References content, and DataClass::visit().

Referenced by DataVisitor::visit().


Friends And Related Function Documentation

friend class DataClass [friend]
friend class DataVisitor [friend]

Member Data Documentation

DataClass* Data::content [protected]

The actual content of this Data object. This is the only field and is copied along. The Data class has ownership over this pointer and will deallocate it as soon as the content its reference count reaches zero

Referenced by Data(), getField(), operator String(), operator Symbol(), operator Token(), operator=(), setField(), type(), visit(), and ~Data().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by  doxygen 1.6.2