Views
Data Access Package API Reference Guide
Product Documentation:
Views Documentation Home
List of all members | Public Member Functions | Friends
IliTableBuffer Class Referenceabstract

Table class. More...

#include <ilviews/dataccess/tblbuf.h>

Inheritance diagram for IliTableBuffer:
IliRefCounted

Public Member Functions

IliValueat (IliName colname)
 Returns a value. More...
 
const IliValueat (IliName colname) const
 Returns a value. More...
 
IliValueat (IlInt colno)
 Returns a value. More...
 
const IliValueat (IlInt colno) const
 Returns a value. More...
 
void clear ()
 Sets all values in the table buffer to the 0 value. More...
 
IlInt count () const
 Returns the number of values in the table buffer. More...
 
IliTablegetTable () const
 Returns the table from which the table buffer has been obtained. More...
 
IlBoolean isModified () const
 Returns IlTrue if a value in the table buffer has been modified. More...
 
IlBoolean isNull () const
 Returns IlTrue if all the values in the table buffer are 0. More...
 
IliValueoperator[] (IliName colname)
 Returns a value. More...
 
const IliValueoperator[] (IliName colname) const
 Returns a value. More...
 
IliValueoperator[] (IlInt colno)
 Returns a value. More...
 
const IliValueoperator[] (IlInt colno) const
 Returns a value. More...
 
IlBoolean rowToBuffer (IlInt rowno)
 Retrieves a row from the underlying table. More...
 
- Public Member Functions inherited from IliRefCounted
IlInt getRefCount () const
 Returns the reference count of the object. Initially, this property is set to 0. More...
 
void lock () const
 Increments the reference count of the object.
 
void unLock () const
 Decrements the reference count of the object. More...
 

Friends

class IliTable
 

Additional Inherited Members

- Protected Member Functions inherited from IliRefCounted
virtual ~IliRefCounted ()
 This is the virtual destructor of the IliRefCounted class. More...
 

Detailed Description

Table class.

Library: dataccess

The IliTableBuffer class works in conjunction with the IliTable class. It is required by the users of a table object, to inspect, alter, or insert new rows into the table. An IliTableBuffer object can be obtained using the IliTable::getBuffer() member function. It can then be used to retrieve rows from the table, to update, or insert new rows into the table. When it is no longer required, it should be returned to the table using the IliTable::releaseBuffer() member function.

See also
IliName, IliTable, IliValue.

Accessors\nAccessors provide a scriptable and uniform way to inspect and modify an object by using its base class methods <tt>IlvValueInterface::queryValue()</tt>, <tt>IlvValueInterface::queryValues()</tt>, <tt>IlvValueInterface::changeValue()</tt>, <tt>IlvValueInterface::changeValues()</tt>.\n\nThis class defines the following accessors:

Data accessors

Name Type Equivalent methods
table Object getTable()
columnsCount Int getTable()->getColumnsCount()

Method accessors

Name Return type Equivalent methods
getValue(String colName) Object new IliTableBufferValueItf(this, getTable()->getColumnIndex(colName))
getValueAt(Int col) Object new IliTableBufferValueItf(this, col)
rowToBuffer(Int row) Void rowToBuffer(row)
clear() Void clear()
modifyAll() Void modifyAll()
isModified() Boolean isModified()
isNull() Boolean isNull()

You first obtain a table buffer by calling the table's getBuffer() method. Then the table buffer contains value objects, one for each column of the table to which the table buffer belongs. (See IliTableBufferValue class for more information.)

var buffer = table.getBuffer();

These value objects are properties of the table buffer so that they can be accessed using the dot notation.

var valueObjectID = buffer.ID;
var valueObjectNAME = buffer.NAME;

Each of these value objects holds:

When you assign explicitly a value, the value object becomes "modified". Conversely, when you call either the clear() or rowToBuffer() methods, all value objects in the table buffer become "not modified".

var rowno = 2;
buffer.rowToBuffer(rowno);
writeln(valueObjectNAME.isModified()); // prints "false"
valueObjectNAME.value = "Jones";
writeln(valueObjectNAME.isModified()); // prints "true"

Once you have set up the values in the table buffer according to your needs, you can call one of the IliTable methods that take a table buffer as a parameter (such as insertRow(), appendRow() or updateRow()).

These methods will consider only the values that are marked as modified. All other values will be considered as unspecified. This feature is important when you work with SQL databases. You do not want the IliTable.updateRow() method to send back to the database server all values in the row. Only the values that must be modified are sent to the database server.

So, the following code updates only column NAME and leaves column ID unchanged:

table.updateRow(rowno, buffer);

Note that a table buffer obtained from one table can be used with any other table if both tables have the same number of columns and corresponding columns have the same data types in both tables. This lets you easily copy rows from one table to another. (See the description of the modifyAll() method for an example.)

Member Function Documentation

◆ at() [1/4]

IliValue& IliTableBuffer::at ( IliName  colname)

Returns a value.

Parameters
colnameThe column name.
Returns
A reference to the value that corresponds to the column named colname.

◆ at() [2/4]

const IliValue& IliTableBuffer::at ( IliName  colname) const

Returns a value.

Parameters
colnameThe column name.
Returns
A constant reference to the value that corresponds to the column named colname.

◆ at() [3/4]

IliValue& IliTableBuffer::at ( IlInt  colno)

Returns a value.

Parameters
colnoThe column position.
Returns
A reference to the value positioned at colno.

◆ at() [4/4]

const IliValue& IliTableBuffer::at ( IlInt  colno) const

Returns a value.

Parameters
colnoThe column position.
Returns
A constant reference to the value positioned at colno.

◆ clear()

void IliTableBuffer::clear ( )

Sets all values in the table buffer to the 0 value.

In addition, the modified property of the table buffer is cleared.

◆ count()

IlInt IliTableBuffer::count ( ) const

Returns the number of values in the table buffer.

Each of these values corresponds to a column in the underlying table.

Returns
The count.

◆ getTable()

IliTable* IliTableBuffer::getTable ( ) const

Returns the table from which the table buffer has been obtained.

Returns
The table.

◆ isModified()

IlBoolean IliTableBuffer::isModified ( ) const

Returns IlTrue if a value in the table buffer has been modified.

Returns
IlTrue if a value in the table buffer has been modified since the last time either of the clear() or rowToBuffer() member functions was called.

◆ isNull()

IlBoolean IliTableBuffer::isNull ( ) const

Returns IlTrue if all the values in the table buffer are 0.

Returns
IlTrue if all the values in the table buffer are 0.

◆ operator[]() [1/4]

IliValue& IliTableBuffer::operator[] ( IliName  colname)

Returns a value.

Parameters
colnameThe column name.
Returns
A reference to the value corresponding to the column named colname.

◆ operator[]() [2/4]

const IliValue& IliTableBuffer::operator[] ( IliName  colname) const

Returns a value.

Parameters
colnameThe column name.
Returns
A constant reference to the value corresponding to the column named colname.

◆ operator[]() [3/4]

IliValue& IliTableBuffer::operator[] ( IlInt  colno)

Returns a value.

Parameters
colnoThe column position.
Returns
A reference to the value positioned at colno.

◆ operator[]() [4/4]

const IliValue& IliTableBuffer::operator[] ( IlInt  colno) const

Returns a value.

Parameters
colnoThe column position.
Returns
A constant reference to the value positioned at colno.

◆ rowToBuffer()

IlBoolean IliTableBuffer::rowToBuffer ( IlInt  rowno)

Retrieves a row from the underlying table.

After this member function has been called, each value in the table buffer is the same as its corresponding value in the designated row. In addition, the modified property of the table buffer is cleared.

Parameters
rownoThe row position.
Returns
IlTrue if successful.
IliTable::updateRow
virtual IlBoolean updateRow(IlInt rowno, IliTableBuffer *buff)
Updates a row with the values in the table buffer.
IliTable::getBuffer
IliTableBuffer * getBuffer()
Returns a table buffer for the table.