#include <string.h>
#include <iostream>
#include <fstream>
#include "sgftoken.hpp"
Include dependency graph for sgftoken.cpp:

Functions | |
| void | read_token () |
| Reads the current token from the file. | |
| unsigned | read_string (char term, char *str, unsigned max_len) |
| Reads characters from 'sg_input_f' until 'term' is encountered. | |
| bool | read_by_chunks (char term, t_str_chunk_reader &reader) |
| bool | open_input (char *file_name) |
| Opens the input file and sets the first entry of input_token_buf to '\0' and last_delim to '\0'. | |
| void | close_input () |
| Closes the input stream. | |
| int | check_token (char *tok) |
| Compares a token given in the argument with the token in input_token_buf. | |
| int | check_long (long *num) |
| Converts the token in input_token_buf to an integer. | |
| int | check_double (double *num) |
| Converts the token in input_token_buf to a real number. | |
Variables | |
| char | input_token_buf [MAX_TOKEN+1] |
| The global buffer for a current token. This buffer is initialized by 'read_token' and used by 'check_token' or some external user. | |
| unsigned long | input_line_number = 1 |
| int check_double | ( | double * | num | ) |
Converts the token in input_token_buf to a real number.
It returns nonzero if succeded to convert the whole contents of input_token_buf, and 0 otherwise.
| int check_long | ( | long * | num | ) |
Converts the token in input_token_buf to an integer.
It returns nonzero if succeded to convert the whole contents of input_token_buf, and 0 otherwise.
| int check_token | ( | char * | tok | ) |
Compares a token given in the argument with the token in input_token_buf.
It returns nonzero if the tokens are equal and zero otherwise.
| void close_input | ( | ) |
Closes the input stream.
It returns the return value of 'fclose'.
| bool open_input | ( | char * | file_name | ) |
Opens the input file and sets the first entry of input_token_buf to '\0' and last_delim to '\0'.
Read the first token using the function read_token, after that the same values of input_token_buf and last_delim mean EOF (in contrast to the situation before the first run of read_token). This function returns 0 if the operation succeded and nonzero if it failed.
| bool read_by_chunks | ( | char | term, | |
| t_str_chunk_reader & | reader | |||
| ) |
The characters are written to 'reader.buffer'. As soon as the buffer is filled up it is flushed using 'reader.get_chunk'. If this function returns nonzero, the further characters up to 'term' or the end of the file are skipped. Unless EOF encounered the terminating character 'term' is written to input_token_buf, else (if EOF encountered) the first entry of input_token_buf is set to zero. last_delim is always set to zero. The function returns zero if 'reader.get_chunk' has returned zero at all the calls and nonzero otherwise.
| unsigned read_string | ( | char | term, | |
| char * | str, | |||
| unsigned | max_len | |||
| ) |
Reads characters from 'sg_input_f' until 'term' is encountered.
The first max. 'max_len' characters are written to 'str', other characters are skipped. Unless EOF encounered the terminating character 'term' is written to input_token_buf, else (if EOF encountered) the first entry of input_token_buf is set to zero. last_delim is always set to zero. The function returns the number of characters written to 'str'.
| void read_token | ( | ) |
Reads the current token from the file.
The token is placed in input_token_buf, the delimiter encountered at its end is written to last_delim. The previous values of these buffers are lost. The function follows the rules below:
Thus input_token_buf is empty after this function if and only if the EOF is encountered.
This global variable stores the current line number, i. e. the number of new-line characters read and transfered to input_token_buf plus one. It is assumed that NL is always a white space character, so it newer appears in input_token_buf. Thus all the characters in input_token_buf belong to one line. The character writter currently to last_delim is not taken into account. The code of the new-line caracter is given by the macro NEW_LINE_CHAR.
The global buffer for a current token. This buffer is initialized by 'read_token' and used by 'check_token' or some external user.
1.5.2