GTS Library Reference Manual |
---|
#include <gts.h> #define GTS_COMMENTS GtsFile; enum GtsTokenType; GtsFileVariable; GtsFile* gts_file_new (FILE *fp);void gts_file_next_token (GtsFile *f);void gts_file_first_token_after (GtsFile *f, GtsTokenType type);void gts_file_assign_start (GtsFile *f, GtsFileVariable *vars); GtsFileVariable* gts_file_assign_next (GtsFile *f, GtsFileVariable *vars);void gts_file_assign_variables (GtsFile *f, GtsFileVariable *vars);gint gts_file_getc (GtsFile *f);gint gts_file_getc_scope (GtsFile *f);guint gts_file_read (GtsFile *f,gpointer ptr,guint size,guint nmemb);void gts_file_variable_error (GtsFile *f, GtsFileVariable *vars, constgchar *name, constgchar *format, ...);void gts_file_verror (GtsFile *f, constgchar *format,va_list args);void gts_file_error (GtsFile *f, constgchar *format, ...);void gts_file_destroy (GtsFile *f);
The gts_get_token()
gts_get_newline()
#define GTS_COMMENTS "#!"
Set of characters used as comments identifiers in GTS geometric files.
typedef struct { FILE * fp; gchar * s, * s1; guint line, pos; GString * token; GtsTokenType type; gchar * error; guint curline, curpos; guint scope, scope_max; gint next_token; gchar * delimiters; gchar * comments; gchar * tokens; } GtsFile;
typedef enum { GTS_NONE = 1 << 8, GTS_INT = 1 << 9, GTS_UINT = 1 << 10, GTS_FLOAT = 1 << 11, GTS_DOUBLE = 1 << 12, GTS_STRING = 1 << 13, GTS_FILE = 1 << 14, GTS_ERROR = 1 << 15 } GtsTokenType;
typedef struct { GtsTokenType type; gchar name[30]; gboolean unique; gpointer data; gboolean set; guint line, pos; } GtsFileVariable;
void gts_file_next_token (GtsFile *f);
Reads next token from f
and updates its token
and delim
fields.
f : | a GtsFile. |
void gts_file_first_token_after (GtsFile *f, GtsTokenType type);
Finds and sets the first token of a type different from type
occuring after a token of type type
.
f : | a GtsFile. |
type : | a GtsTokenType. |
void gts_file_assign_start (GtsFile *f, GtsFileVariable *vars);
Opens a block delimited by braces to read a list of optional
arguments specified by vars
.
If an error is encountered the error
field of f
is set.
f : | a GtsFile. |
vars : | a GTS_NONE terminated array of GtsFileVariable. |
GtsFileVariable* gts_file_assign_next (GtsFile *f, GtsFileVariable *vars);
Assigns the next optional argument of vars
read from f
.
f : | a GtsFile. |
vars : | a GTS_NONE terminated array of GtsFileVariable. |
Returns : | the variable of |
void gts_file_assign_variables (GtsFile *f, GtsFileVariable *vars);
Assigns all the variables belonging to vars
found in f
.
If an error is encountered the error
field of f
is set.
f : | a GtsFile. |
vars : | an array of GtsFileVariable. |
gint gts_file_getc (GtsFile *f);
f : | a GtsFile. |
Returns : | the next character in |
gint gts_file_getc_scope (GtsFile *f);
f : | a GtsFile. |
Returns : | the next character in |
guint gts_file_read (GtsFile *f,gpointer ptr,guint size,guint nmemb);
Reads nmemb
elements of data, each size
bytes long, from f
,
storing them at the location given by ptr
.
f : | a GtsFile. |
ptr : | a pointer. |
size : | size of an element. |
nmemb : | number of elements. |
Returns : | the number of elements read. |
void gts_file_variable_error (GtsFile *f, GtsFileVariable *vars, constgchar *name, constgchar *format, ...);
Sets the error
field of f
using gts_file_verror()
.
String name
must match one of the variable names in vars
.
If variable name
has been assigned (using gts_file_assign_variables()
)
sets the line
and pos
fields of f
to the line and position where
it has been assigned.
f : | a GtsFile. |
vars : | an array of GtsFileVariable. |
name : | the name of a variable in |
format : | the standard |
... : | the parameters to insert into the format string. |
void gts_file_verror (GtsFile *f, constgchar *format,va_list args);
Sets the error
field of f
using g_strdup_vprintf()
This function can be called only once and disables any other
operation on f
(gts_file_close()
f : | a |
format : | the standard |
args : | the list of parameters to insert into the format string. |
void gts_file_error (GtsFile *f, constgchar *format, ...);
Sets the error
field of f
using gts_file_verror()
.
This function can be called only once and disables any other
operation on f
(gts_file_close()
f : | a |
format : | the standard |
... : | the parameters to insert into the format string. |
<<< Simple statistics | Geometrical Object Hierarchy >>> |