SIFEL/GEFEL/intools.cpp File Reference

#include "intools.h"
#include "iotools.h"
#include "xfile.h"
#include <string.h>
#include <ctype.h>

Go to the source code of this file.

Functions

FILE * cleancommblock (FILE *in)
void delcomment (char *s)
long getdouble (FILE *in, double &num)
void geteoln (FILE *in)
long getgkwid (XFILE *in, long id, long &numl)
long getgkwid (FILE *in, long id)
long getint (FILE *in, int &num)
long getlong (FILE *in, long &num)
void getnextln (FILE *in)
void getnexttxt (FILE *in)
long getnprop (FILE *in)
long getnprop (XFILE *in, long &numl)
long getpkw (FILE *in)
long getstring (FILE *in, char *str, long maxlen)
long getstring2 (FILE *in, char *str, long maxlen)
long inputln (FILE *in, char *anystr, long maxlen)
long iscomment (char *s, char *&ptr)
long isgkw (char *s, char *&ptr)
long ispkw (char *s, char *&ptr)

Variables

static const char * Genkw [2] = {"begin", "end"}
 general keywords string array
static long Ngkw = 2
 number of general keywords
static long Npkw = 21
 number of property keywords
static const char * Propkw [21]
 property keywords string array

Function Documentation

FILE* cleancommblock ( FILE *  in  ) 

Function deletes comment blocks from file one block denoted by general keywords 'begin' and 'end'. This block is rewritten without comments to the temporary file.

Parameters:
in - pointer to opened file with block which will be cleaned out of comments
Return values:
pointer to opened temporary file where is the result of cleaning process.

created 12.2001, Tomas Koudelka, koudelka@cml.fsv.cvut.cz modified 23.1.2002, Tomas Koudelka, koudelka@cml.fsv.cvut.cz

Definition at line 128 of file intools.cpp.

References Genkw, getgkwid(), and getnextln().

Referenced by main().

void delcomment ( char *  s  ) 

Function deletes part of string s behind comment character # and puts chracter instead it. If only blank chracters precede #, then is placed to the first (0-th) position of string

Parameters:
s - pointer to searched string.

created 12.2001, Tomas Koudelka, koudelka@cml.fsv.cvut.cz modified 23.1.2002, Tomas Koudelka, koudelka@cml.fsv.cvut.cz

Definition at line 98 of file intools.cpp.

long getdouble ( FILE *  in,
double &  num 
)

Function reads real number type double from file given by parameter in. Comment blocks are accepted and skipped. On success, the file position indicator is set after last character searched number.

Parameters:
in - pointer to opened file where the number is searched
num - output parameter for result
Return values:
1 - if fails reading of input file
0 - on succes

created 12.2001, Tomas Koudelka, koudelka@cml.fsv.cvut.cz modified 23.1.2002, Tomas Koudelka, koudelka@cml.fsv.cvut.cz

Definition at line 612 of file intools.cpp.

References geteoln(), and iscomment().

Referenced by loadn::read_prop(), tablefunct::read_prop(), itablefunct::read_prop(), and gfunct::read_prop().

void geteoln ( FILE *  in  ) 

Function searches file given by parameter in for
character and sets file position indicator on it.

Parameters:
in - pointer to opened file where
is searched

created 12.2001, Tomas Koudelka, koudelka@cml.fsv.cvut.cz modified 23.1.2002, Tomas Koudelka, koudelka@cml.fsv.cvut.cz

Definition at line 177 of file intools.cpp.

Referenced by getdouble(), getgkwid(), getint(), getlong(), getnprop(), getpkw(), getstring(), and getstring2().

long getgkwid ( XFILE in,
long  id,
long &  numl 
)

Function searches file given by parameter in for id-th general keyword. Comment blocks are accepted and skipped. On success, the file position indicator is set after last character searched keyword.

Parameters:
in - pointer to opened file where general keyword is searched
id - index of desired general keyword
numl - number of processed lines
Return values:
1 - if fails reading of input file
0 - on succes

created 12.2001, Tomas Koudelka, koudelka@cml.fsv.cvut.cz modified 23.1.2002, Tomas Koudelka, koudelka@cml.fsv.cvut.cz

Definition at line 296 of file intools.cpp.

References clearcomments(), XFILE::col, XFILE::file, XFILE::give_maxlnsize(), inputln(), isgkw(), XFILE::lnfpos, memset(), and Propkw.

long getgkwid ( FILE *  in,
long  id 
)

Function searches file given by parameter in for id-th general keyword. Comment blocks are accepted and skipped. On success, the file position indicator is set after last character searched keyword.

Parameters:
in - pointer to opened file where general keyword is searched
id - index of desired general keyword
Return values:
1 - if fails reading of input file
0 - on succes

created 12.2001, Tomas Koudelka, koudelka@cml.fsv.cvut.cz modified 23.1.2002, Tomas Koudelka, koudelka@cml.fsv.cvut.cz

Definition at line 238 of file intools.cpp.

References Genkw, geteoln(), iscomment(), isgkw(), and memset().

Referenced by cleancommblock().

long getint ( FILE *  in,
int &  num 
)

Function reads integer number type int from file given by parameter in. Comment blocks are accepted and skipped. On success, the file position indicator is set after last character searched number.

Parameters:
in - pointer to opened file where the number is searched
num - output parameter for result
Return values:
1 - if fails reading of input file
0 - on succes

created 12.2001, Tomas Koudelka, koudelka@cml.fsv.cvut.cz modified 23.1.2002, Tomas Koudelka, koudelka@cml.fsv.cvut.cz

Definition at line 561 of file intools.cpp.

References geteoln(), and iscomment().

Referenced by tablefunct::read_prop(), and gfunct::read_prop().

long getlong ( FILE *  in,
long &  num 
)

Function reads integer number type long from file given by parameter in. Comment blocks are accepted and skipped. On success, the file position indicator is set after last character searched number.

Parameters:
in - pointer to opened file where the number is searched
num - output parameter for result
Return values:
1 - if fails reading of input file
0 - on succes

created 12.2001, Tomas Koudelka, koudelka@cml.fsv.cvut.cz modified 23.1.2002, Tomas Koudelka, koudelka@cml.fsv.cvut.cz

Definition at line 506 of file intools.cpp.

References geteoln(), and iscomment().

Referenced by main(), loadn::read_prop(), tablefunct::read_prop(), itablefunct::read_prop(), and gfunct::read_prop().

void getnextln ( FILE *  in  ) 

Function searches file given by parameter in for
character and sets file position indicator after it.

Parameters:
in - pointer to opened file where
is searched

created 12.2001, Tomas Koudelka, koudelka@cml.fsv.cvut.cz modified 23.1.2002, Tomas Koudelka, koudelka@cml.fsv.cvut.cz

Definition at line 194 of file intools.cpp.

Referenced by cleancommblock(), getstring(), and getstring2().

void getnexttxt ( FILE *  in  ) 

Function searches file given by parameter in from current position for WHITESPACE characters and sets file position indicator to the first nonwhitespace character i.e. it searches next text.

Parameters:
in - pointer to opened file where
is searched

created 9.2003, Tomas Koudelka, koudelka@cml.fsv.cvut.cz modified 9.2003, Tomas Koudelka, koudelka@cml.fsv.cvut.cz

Definition at line 209 of file intools.cpp.

long getnprop ( FILE *  in  ) 

Function searches file given by parameter in for property keywords and counts its number. File is proccessing until any general keyword found. Comment blocks are accepted and skipped. After searching the file position indicator is set to the original position before searching.

Parameters:
in - pointer to opened file where property keywords are searched
id - index of desired property keyword
Return values:
1 - if fails reading of input file
0 - on succes

created 12.2001, Tomas Koudelka, koudelka@cml.fsv.cvut.cz modified 23.1.2002, Tomas Koudelka, koudelka@cml.fsv.cvut.cz

Definition at line 446 of file intools.cpp.

References geteoln(), iscomment(), isgkw(), and ispkw().

long getnprop ( XFILE in,
long &  numl 
)

Function searches file given by parameter in for property keywords and counts its number. File is proccessing until any general keyword found. Comment blocks are accepted and skipped. After searching the file position indicator is set to the original position before searching.

Parameters:
in - pointer to opened file where property keywords are searched
numl - number of lines found during the searching
Return values:
1 - if fails reading of input file
0 - on succes

created 2.2007, Tomas Koudelka, koudelka@cml.fsv.cvut.cz

Definition at line 400 of file intools.cpp.

References clearcomments(), XFILE::file, XFILE::give_maxlnsize(), inputln(), isgkw(), ispkw(), and memset().

long getpkw ( FILE *  in  ) 

Function searches file given by parameter in for id-th property keyword. Comment blocks are accepted and skipped. On success, the file position indicator is set after last character searched keyword.

Parameters:
in - pointer to opened file where property keyword is searched
id - index of desired property keyword
Return values:
1 - if fails reading of input file
0 - on succes

created 12.2001, Tomas Koudelka, koudelka@cml.fsv.cvut.cz modified 23.1.2002, Tomas Koudelka, koudelka@cml.fsv.cvut.cz

Definition at line 343 of file intools.cpp.

References geteoln(), iscomment(), ispkw(), and Propkw.

long getstring ( FILE *  in,
char *  str,
long  maxlen 
)

Function reads string from file given by parameter in. Initial whitespaces are skipped. String str has maximu length maxlen chracters including terminating . Comment blocks are accepted and skipped. On success, the file position indicator is set after last character searched string.

Parameters:
in - pointer to opened file where the string is searched
num - output parameter for result
Return values:
0 always

created 12.2001, Tomas Koudelka, koudelka@cml.fsv.cvut.cz modified 23.1.2002, Tomas Koudelka, koudelka@cml.fsv.cvut.cz

Definition at line 666 of file intools.cpp.

References geteoln(), and getnextln().

Referenced by main(), and gfunct::read_prop().

long getstring2 ( FILE *  in,
char *  str,
long  maxlen 
)

Function reads string from file given by parameter in. String str has maximu length maxlen chracters including terminating . Comment blocks are accepted and skipped. On success, the file position indicator is set after last character searched string.

Parameters:
in - pointer to opened file where the string is searched
num - output parameter for result
Return values:
0 always

created 12.2001, Tomas Koudelka, koudelka@cml.fsv.cvut.cz modified 23.1.2002, Tomas Koudelka, koudelka@cml.fsv.cvut.cz

Definition at line 734 of file intools.cpp.

References geteoln(), and getnextln().

long inputln ( FILE *  in,
char *  anystr,
long  maxlen 
)

Function reads maxlen characters to string anystr from th file in. Function reads file till the line treminating character
and stores chracters to string given by parameter anystr until maxlen chractres are read.

Parameters:
in - pointer to opened file
anystr - output parameter, pointer to allocated string where read chracters are stored
maxlen - maximu number of read chracters
Return values:
number of successfully read bytes

Definition at line 786 of file intools.cpp.

Referenced by getgkwid(), and getnprop().

long iscomment ( char *  s,
char *&  ptr 
)

Function searches string s for comment character # and returns result

Parameters:
s - pointer to searched string.
ptr - output parameter which contains pointer to string s where was found character # or NULL when no # chracter found
Return values:
1 - There was found # character in the string.
0 - No # chracterwas was found.

created 12.2001, Tomas Koudelka, koudelka@cml.fsv.cvut.cz modified 23.1.2002, Tomas Koudelka, koudelka@cml.fsv.cvut.cz

Definition at line 81 of file intools.cpp.

References strstr().

Referenced by getdouble(), getgkwid(), getint(), getlong(), getnprop(), and getpkw().

long isgkw ( char *  s,
char *&  ptr 
)

Function comparess string s with Genkw array and returns result

Parameters:
s - pointer to compared string.
ptr - output parameter which contains pointer to array Genkw where is same keyword as in the s string or NULL when no general keyword matches.
Return values:
-1 - no general keyword matches string s.
i - i-th general keyword matches string s. Indexing starts from 0

created 12.2001, Tomas Koudelka, koudelka@cml.fsv.cvut.cz modified 23.1.2002, Tomas Koudelka, koudelka@cml.fsv.cvut.cz

Definition at line 33 of file intools.cpp.

References Genkw, Ngkw, and strstr().

Referenced by getgkwid(), and getnprop().

long ispkw ( char *  s,
char *&  ptr 
)

Function comparess string s with Propkw array and returns result

Parameters:
s - pointer to compared string.
ptr - output parameter which contains pointer to array Propkw where is same keyword as in the s string or NULL when no property keyword matches.
Return values:
-1 - no property keyword matches string s.
i - i-th property keyword matches string s. Indexing starts from 0

created 12.2001, Tomas Koudelka, koudelka@cml.fsv.cvut.cz modified 23.1.2002, Tomas Koudelka, koudelka@cml.fsv.cvut.cz

Definition at line 58 of file intools.cpp.

References Npkw, Propkw, and strstr().

Referenced by getnprop(), and getpkw().


Variable Documentation

const char* Genkw[2] = {"begin", "end"} [static]

general keywords string array

Definition at line 11 of file intools.cpp.

Referenced by cleancommblock(), getgkwid(), and isgkw().

long Ngkw = 2 [static]

number of general keywords

This file contains functions for processing file with keywords and comments blocks

Definition at line 10 of file intools.cpp.

Referenced by isgkw().

long Npkw = 21 [static]

number of property keywords

Definition at line 12 of file intools.cpp.

Referenced by ispkw().

const char* Propkw[21] [static]
Initial value:
 {"ndofn",    "bocon", "nload",  "crsec",   "lcsys",  "eltype",
                           "mater",    "eload", "dloadn", "dloadel", "inicon", "comcn",
                           "loadedge", "sscomp", "ntemp", "tfunct", "loadsurf", "elsurfload", 
                           "ntimefunc", "etimefunc", "bocsurf"}

property keywords string array

Definition at line 13 of file intools.cpp.

Referenced by getgkwid(), getpkw(), and ispkw().


Generated by  doxygen 1.6.2