Scol standard library package  0.3.1
Common and usefull functions for all Scol applications
Functions
The iteration standard API.

Functions

 std_itAdd (oIt, szToAdd)
 Add the substring to a StdIteration object from the current cursor position. The cursor position keeps unchanged. More...
 
 std_itGepIncluded (oIt)
 Get if the current defined seperator is included (or not in the return. More...
 
 std_itGet (oIt)
 Return the initial object. More...
 
 std_itGetLastLength (oIt)
 Get the last given length for read. More...
 
 std_itGetLength (oIt)
 Get the length of a StdIteration object. More...
 
 std_itGetPos (oIt)
 Get the current cursor position of a StdIteration object. More...
 
 std_itGetPosBegin (oIt)
 Get the minimum cursor position. More...
 
 std_itGetPosEnd (oIt)
 Get the maximum cursor position. More...
 
 std_itGetSep (oIt)
 Get the current defined seperator. More...
 
 std_itNewFile (chn, pFile)
 Create a new StdIteration object from a File object. More...
 
 std_itNewS (szValue)
 Create a new StdIteration object from a string. More...
 
 std_itNewTab (tab)
 Create a new StdIteration object from a tab (array) object. More...
 
 std_itRead (oIt, iLength)
 Read the subcontent of a StdIteration object from the current cursor position and the given lenght (like the fread C-function). Next, the position will be updated (current position + lenght) More...
 
 std_itReadNext (oIt)
 Read the subcontent of a StdIteration object from the current cursor position to one unit (byte, char or other) (like the fread C-function). Next, the position will be updated (current position + 1) More...
 
 std_itReadSep (oIt)
 Read the subcontent of a StdIteration object from the current cursor position until the next separator found. More...
 
 std_itSepIncluded (oIt, iFlag)
 Set if the separator is included in the return or not. More...
 
 std_itSetCb (oIt, cbfun)
 Set the function called for each iteration. More...
 
 std_itSetCbEnd (oIt, cbfun)
 Set the function called when the ioterator comes to the end. More...
 
 std_itSetPosBegin (oIt, iPosBegin)
 Set the minimum cursor position. By default it is 0. More...
 
 std_itSetPosEnd (oIt, iPosEnd)
 Set themaximum cursor position. By default it is the lenght of the object. More...
 
 std_itSetSep (oIt, iSep)
 Define a separator for a StdIteration object. More...
 
 std_itSetSepFromS (oIt, szSep)
 Define a separator for a StdIteration object. More...
 
 std_itUpdatePos (oIt, iPos, iFlag)
 Read the subcontent of a StdIteration tab (array) object from the current cursor position and the given lenght (like the fread C-function). Next, the position will be updated (current position + lenght) More...
 

Detailed Description

Package to load : lib/std/iteration.pkg

Dependancies :

Function Documentation

std_itNewS ( szValue  )

Create a new StdIteration object from a string.

Prototype : fun [S] StdIteration

The current cursor position is put at 0.

Parameters
S: an inital string to iterate
Returns
StdIteration : the new StdIteration object
See also
std_itUpdatePos to change the position
std_itNewFile ( chn  ,
pFile   
)

Create a new StdIteration object from a File object.

Prototype : fun [Chn P] StdIteration

The current cursor position is put at 0.

Parameters
Chn: a channel, like the current channel (_channel)
P: a read file reference to iterate
Returns
StdIteration : the new StdIteration object
See also
std_itUpdatePos to change the position
std_itNewTab ( tab  )

Create a new StdIteration object from a tab (array) object.

Prototype : fun [tab u0] StdIteration

The current cursor position is put at 0.

Parameters
tabu0 : a table (array) to iterate
Returns
StdIteration : the new StdIteration object
See also
std_itUpdatePos to change the position
Warning
Removed !
std_itRead ( oIt  ,
iLength   
)

Read the subcontent of a StdIteration object from the current cursor position and the given lenght (like the fread C-function). Next, the position will be updated (current position + lenght)

Prototype : fun [StdIteration I] S

Parameters
StdIteration: a StdIteration object to iterate
I: a lenght (can be a negative or positive integer)
Returns
S : the subcontent or nil if an error occurs
See also
std_itSetCb
std_itReadTab
std_itReadNext ( oIt  )

Read the subcontent of a StdIteration object from the current cursor position to one unit (byte, char or other) (like the fread C-function). Next, the position will be updated (current position + 1)

Prototype : fun [StdIteration] S

Parameters
StdIteration: a StdIteration object to iterate
Returns
S : the subcontent or nil if an error occurs
See also
std_itRead
std_itUpdatePos ( oIt  ,
iPos  ,
iFlag   
)

Read the subcontent of a StdIteration tab (array) object from the current cursor position and the given lenght (like the fread C-function). Next, the position will be updated (current position + lenght)

Prototype : fun [StdIteration I] tab u0

Parameters
StdIteration: a StdIteration object to iterate
I: a lenght (can be a negative or positive integer)
Returns
tab u0 : a new tab (its size is the given length) or nil if an error occurs
See also
std_itRead Removed !

Update the cursor position.

Prototype : fun [StdIteration I I] StdIteration

Parameters
StdIteration: a StdIteration object to iterate
I: a new position (if negative, the new position will be 0, if too long, the new position will be truncated.
I: a flag :
  • STD_IT_FROMBEGIN : position given from beginning of the object
  • STD_IT_FROMCURRENT : position given from the current cursor position of the object
  • STD_IT_FROMEND : position given from end of the object
Returns
StdIteration : the same StdIteration object or nil if an error occurs
std_itSetPosBegin ( oIt  ,
iPosBegin   
)

Set the minimum cursor position. By default it is 0.

Prototype : fun [StdIteration I] StdIteration

Parameters
StdIteration: a StdIteration object to iterate
I: a new minimum position (can be negative, the new position will be from the maximum).
Returns
StdIteration : the same StdIteration object or nil if an error occurs
See also
std_itSetPosEnd
std_itSetPosEnd ( oIt  ,
iPosEnd   
)

Set themaximum cursor position. By default it is the lenght of the object.

Prototype : fun [StdIteration I I] StdIteration

Parameters
StdIteration: a StdIteration object to iterate
I: a new maximum position (can be negative, the new position will be from the old maximum).
Returns
StdIteration : the same StdIteration object or nil if an error occurs
See also
std_itSetPosBegin
std_itGetPosBegin ( oIt  )

Get the minimum cursor position.

Prototype : fun [StdIteration] I

Parameters
StdIteration: a StdIteration object to iterate
Returns
I : the minimum position
std_itGetPosEnd ( oIt  )

Get the maximum cursor position.

Prototype : fun [StdIteration] I

Parameters
StdIteration: a StdIteration object to iterate
Returns
I : the maximum position
std_itGetLength ( oIt  )

Get the length of a StdIteration object.

Prototype : fun [StdIteration] I

Parameters
StdIteration: a StdIteration object to iterate
Returns
I : this length or nil if error / not supported
std_itGetPos ( oIt  )

Get the current cursor position of a StdIteration object.

Prototype : fun [StdIteration] I

Parameters
StdIteration: a StdIteration object to iterate
Returns
I : the current position or nil if error
std_itGetLastLength ( oIt  )

Get the last given length for read.

Prototype : fun [StdIteration] I

Parameters
StdIteration: a StdIteration object to iterate
Returns
I : this last length or nil if error
std_itGet ( oIt  )

Return the initial object.

Prototype : fun [StdIteration] S

Parameters
StdIteration: a StdIteration object to iterate
Returns
S : the object : a string, a path name, ... or nil if error
std_itSetCbEnd ( oIt  ,
cbfun   
)

Set the function called when the ioterator comes to the end.

Prototype : fun [StdIteration fun [StdIteration] I] StdIteration

Parameters
StdIteration: a StdIteration object to iterate
fun[StdIteration] I : the callback (the argument is the StdIteration object itself)
Returns
StdIteration : the same StdIteration object or nil if an error occurs
std_itSetCb ( oIt  ,
cbfun   
)

Set the function called for each iteration.

Prototype : fun [StdIteration fun [StdIteration S] I] StdIteration

Parameters
StdIteration: a StdIteration object to iterate
fun[StdIteration S] I : the callback. The arguments are :
Returns
StdIteration : the same StdIteration object or nil if an error occurs
See also
std_itRead
std_itAdd ( oIt  ,
szToAdd   
)

Add the substring to a StdIteration object from the current cursor position. The cursor position keeps unchanged.

Prototype : fun [StdIteration S] StdIteration

Parameters
StdIteration: a StdIteration object to iterate
S: a string to add (to include)
Returns
StdIteration : the same StdIteration object or nil if an error occurs
std_itSetSep ( oIt  ,
iSep   
)

Define a separator for a StdIteration object.

A separator is an ascii value.

Prototype : fun [StdIteration I] StdIteration

Parameters
StdIteration: a StdIteration object to iterate
I: an ascii value
Returns
StdIteration : the same StdIteration object or nil if an error occurs
See also
std_itSetSepFromS
std_itSetSepFromS ( oIt  ,
szSep   
)

Define a separator for a StdIteration object.

A separator is an ascii value.

Prototype : fun [StdIteration S] StdIteration

Parameters
StdIteration: a StdIteration object to iterate
S: a string. The first char will take off only, others are ignored. This function is a convenience to avoid to give the ascii value directly.
Returns
StdIteration : the same StdIteration object or nil if an error occurs
See also
std_itSetSep
std_itGetSep ( oIt  )

Get the current defined seperator.

Prototype : fun [StdIteration] I

Parameters
StdIteration: a StdIteration object to iterate
Returns
I : the ascii value of the current separator (nil if undefined)
std_itSepIncluded ( oIt  ,
iFlag   
)

Set if the separator is included in the return or not.

Prototype : fun [StdIteration I] StdIteration

Parameters
StdIteration: a StdIteration object to iterate
I: 1 to include, 0 to not include (default)
Returns
StdIteration : the same StdIteration object or nil if an error occurs
See also
std_itReadSep
std_itGepIncluded ( oIt  )

Get if the current defined seperator is included (or not in the return.

Prototype : fun [StdIteration] I

Parameters
StdIteration: a StdIteration object to iterate
Returns
I : 1 if included else 0
See also
std_itReadSep
std_itReadSep ( oIt  )

Read the subcontent of a StdIteration object from the current cursor position until the next separator found.

If the separator is not found, th ewhole subcontent from the current sursor position until the end position is returned. Next, the cursor position will be updated.

Prototype : fun [StdIteration] S

Parameters
StdIteration: a StdIteration object to iterate
Returns
S : the subcontent or nil if an error occurs
See also
std_itSepIncluded
std_itSetSep
std_itRead
std_itSetPosEnd to define the end position (otherwise, it is the end of the object)