Class Struct

Summary

The Struct class simply provides methods for converting between string and structure representations of information. A good example of it's use in the the addressbook package, where subclasses of this class are used to convert data back and forth between strings (as stored in a DB) and various structures.

Superclasses:
Object

Package:
database
File:
struct.icn
Methods:
addElement, fromIStruct, fromString, gen, remove, toIStruct, toString

Methods inherited from Object:
Type, className, clone, equals, fieldNames, genMethods, getField, get_class, get_class_name, get_id, hasField, hasMethod, hash_code, instanceOf, invoke, is_instance, setField, to_string

Fields:
sType, struct

Source code.

Details
Constructor

Struct(sTypeCons)

Parameter:
sTypeCons
type of structure, e.g. <b>set</b> or <b>list</b>. Default is <b>set</b>.

Given a structure type, map it into a Struct class.

Methods:

addElement(e)

Parameter:
e
element to add
Returns:
nothing useful
Fails:
if structure is not a set or list

Add a single element to the structure.


fromIStruct(s)

Parameter:
s
Unicon structured type
Returns:
this structure after conversion

Convert from a Unicon structure form.


fromString(s, prefix:"", terminator:'\n')

Parameters:
s
string form
prefix
to remove from head of each string structure element
terminator
to remove from tail of each string structure element
Returns:
this structure

Convert from string form.


gen()

Generates:
elements in this structure


remove(e)

Parameter:
e
element to remove

Remove an element from the structure (semi-abstract, only works with set structure - must be overridden for other structures).


toIStruct()

Returns:
(a copy of internal) structure

Produce a Unicon structure form.


toString(prefix:"", terminator:"\n")

Parameters:
prefix
added to head of each string structure element
terminator
added to tail of each string structure element
Returns:
string formed from elements in this structure

Produce a string form (required for storing to DB)


Fields:
sType

struct


This page produced by UniDoc on 2021/04/15 @ 23:59:54.