Libraries |
|
Null_file | Source Code |
|
|
null_file
const type: null_file
-
Base implementation type for the file interface. A null_file discards all data written to it. Reads from a null_file always yield EOF immediately. A null_file is not seekable. The functions length, seek and tell raise FILE_ERROR. The functions getc, getwd and getln are written such that a derived type can use them. Derived types of null_file need to override the functions write, gets, eof and hasNext. A derived type, which represents a seekable file, needs to override the functions length, seek and tell.
Variable Summary | |||||
null_file |
|
Operator Summary | |||||
file |
|
Function Summary | |||||
void |
| ||||
void |
| ||||
void |
| ||||
string |
| ||||
char |
| ||||
string |
| ||||
string |
| ||||
string |
| ||||
boolean |
| ||||
boolean |
| ||||
integer |
| ||||
boolean |
| ||||
void |
| ||||
integer |
| ||||
void |
| ||||
void |
|
Function Detail |
write
const proc: write (in null_file: outFile, in string: stri)
-
Write a string to a null_file. The parameter stri is just ignored. Derived types of null_file need to override this function.
writeln
const proc: writeln (inout null_file: outFile)
-
Write end-of-line to outFile. This function writes the end-of-line marker '\n'. Derived types can use this function. If a derived type does not use '\n' as end-of-line marker it needs to override this function.
writeln
const proc: writeln (inout null_file: outFile, in string: stri)
-
Write a string followed by end-of-line to outFile. This function is based on write and writeln. Derived types can use this function. This function must be overridden, if it is necessary to write stri and '\n' together.
gets
const func string: gets (in null_file: inFile, in integer: maxLength)
-
Read a string with a maximum length from a null_file. Derived types of null_file need to override this function.
- Returns:
- the empty string ("").
- Raises:
- RANGE_ERROR - The parameter maxLength is negative.
getc
const func char: getc (inout null_file: inFile)
getTerminatedString
const func string: getTerminatedString (inout null_file: inFile, in char: terminator)
-
Read a string from inFile until the terminator character is found. If a terminator is found the string before the terminator is returned and the terminator character is assigned to inFile.bufferChar. The file position is advanced after the terminator character. If no terminator is found the rest of inFile is returned and EOF is assigned to the inFile.bufferChar. When the function is left inFile.bufferChar contains either terminator or EOF. This function is based on the gets function. Therefore it is useable for derived types of null_file. For the null_file itself it always returns "" and assigns EOF to inFile.bufferChar.
- Parameters:
- inFile - File from which the string is read.
- terminator - Character which terminates the string.
- Returns:
- the string read without the terminator or the rest of the file if no terminator is found.
getwd
const func string: getwd (inout null_file: inFile)
-
Read a word from a null_file. Before reading the word it skips spaces and tabs. The function accepts words ending with ' ', '\t', '\n' or EOF. The word ending characters are not copied into the string. When the function is left inFile.bufferChar contains ' ', '\t', '\n' or EOF. This function is based on the gets function. Therefore it is useable for derived types of null_file. For the null_file itself it always returns "" and assigns EOF to inFile.bufferChar.
- Returns:
- the word read.
getln
const func string: getln (inout null_file: inFile)
-
Read a line from a null_file. The function accepts lines ending with '\n' or EOF. The line ending characters are not copied into the string. When the function is left inFile.bufferChar contains '\n' or EOF. This function is based on the gets function. Therefore it is useable for derived types of null_file. For the null_file itself it always returns "" and assigns EOF to inFile.bufferChar.
- Returns:
- the line read.
eof
const boolean: eof (in null_file: inFile)
-
Determine the end-of-file indicator. Derived types of null_file need to override this function.
- Returns:
- TRUE, since a null_file is always at end-of-file.
hasNext
const boolean: hasNext (in null_file: inFile)
-
Determine if at least one character can be read successfully. Derived types of null_file need to override this function.
- Returns:
- FALSE, since the next getc will always return EOF.
length
const func integer: length (in null_file: aFile)
-
Obtain the length of a file. A null_file is not seekable, therefore FILE_ERROR is raised. Derived types of null_file need to override this function.
- Returns:
- nothing, because FILE_ERROR is always raised.
- Raises:
- FILE_ERROR - Is always raised, because a null_file is not seekable.
seekable
const boolean: seekable (in null_file: aFile)
-
Determine if the file aFile is seekable. If a file is seekable the functions seek and tell can be used to set and and obtain the current file position.
- Returns:
- FALSE, since a null_file is not seekable.
seek
const proc: seek (in null_file: aFile, in integer: position)
-
Set the current file position. A null_file is not seekable, therefore FILE_ERROR is raised. If a derived type is seekable it needs to override this function.
- Raises:
- FILE_ERROR - Is always raised, because a null_file is not seekable.
tell
const func integer: tell (in null_file: aFile)
-
Obtain the current file position. A null_file is not seekable, therefore FILE_ERROR is raised. If a derived type is seekable it needs to override this function.
- Returns:
- nothing, because FILE_ERROR is always raised.
- Raises:
- FILE_ERROR - Is always raised, because a null_file is not seekable.
flush
const proc: flush (in null_file: aFile)
-
Forces that all buffered data is sent to its destination. Flushing a null_file has no effect.
|
|