CONFIG LIB 1.5
Configuration Files Library (by TGG 2020)
Loading...
Searching...
No Matches
IOFUN Class Reference

Simple I/O functions class. More...

#include <iofun.h>

Inheritance diagram for IOFUN:
AIRFOIL CONNECT_DATA CON_FILE GRID_ARRAYS MS2_Data NGH_FILE PANUKL_AUTO PANUKL_PLR PANUKL_PRJ PAR_FILE PRS_FILE SDSA_FILE SDSA_PARAMS TXT_OUT_FILE

Static Public Member Functions

static void Win2Unix (char *s)
 conversion of directory separators - MS Windows to Unix
 
static void Unix2Win (char *s)
 conversion of directory separators - Unix to MS Windows
 
static int ReadComm (FILE *stream)
 Function to read of a comment till the end of line. It returns 0 or EOF if it is performed.
 
static void ReadDummy (FILE *stream)
 Function to read a comment line.
 
static int ReadPar (FILE *stream, const char *Format, void *Par)
 Function to read one variable. The type of variable depends on Format, compatible with stdio library.
 
static int ReadPar (FILE *stream, const char *Format, void *Par1, void *Par2)
 Function to read two variables. The type of variables depends on Format, compatible with stdio library.
 
static int ReadPar (FILE *stream, const char *Format, void *Par1, void *Par2, void *Par3)
 Function to read three variables. The type of variables depends on Format, compatible with stdio library.
 
static int ReadPar (FILE *stream, const char *Format, void *Par1, void *Par2, void *Par3, void *Par4)
 Function to read four variables. The type of variables depends on Format, compatible with stdio library.
 
static int ReadVect3 (FILE *stream, double *Par, double dScal=1.)
 Function to read double vector "Par" of "3" dimension from FILE "stream". The read values are scaled by multiplier "dScal".
 
static int ReadVect3 (FILE *stream, float *Par, float fScal=1.)
 Function to read float vector "Par" of "3" dimension from FILE "stream". The read values are scaled by multiplier "fScal".
 
static int ReadVect3 (FILE *stream, long *Par, long lScal=1)
 Function to read long vector "Par" of "3" dimension from FILE "stream". The read values are scaled by multiplier "lScal".
 
static int ReadVect3 (FILE *stream, int *Par, int iScal=1)
 Function to read int vector "Par" of "3" dimension from FILE "stream". The read values are scaled by multiplier "iScal".
 
static int ReadVect (FILE *stream, double *Par, int n, double dScal=1.)
 Function to read double vector "Par" of "n" dimension from FILE "stream". The read values are scaled by multiplier "dScal".
 
static int ReadVect (FILE *stream, float *Par, int n, float fScal=1.)
 Function to read float vector "Par" of "n" dimension from FILE "stream". The read values are scaled by multiplier "fScal".
 
static int ReadVect (FILE *stream, long *Par, int n, long lScal=1)
 Function to read long vector "Par" of "n" dimension from FILE "stream". The read values are scaled by multiplier "lScal".
 
static int ReadVect (FILE *stream, int *Par, int n, int iScal=1)
 Function to read int vector "Par" of "n" dimension from FILE "stream". The read values are scaled by multiplier "iScal".
 
static int ReadStr (FILE *stream, char *Par)
 Function to read the new line from FILE "stream" and to store it in table of char "Par". The starting and ending blanc charaters are clipped.
 
static void ReadStrL (FILE *stream, char *Par, int *len)
 Function to read the string (Par) from FILE "stream". It reads from current pointer of FILE to the end of line or EOF. Number of read characters is returned in "len".
 
static void ClipString (char *string)
 Clipping of the "string" up to the first blanc character or comment "#" character.
 
static void ClipFileName (char *string)
 Clipping of the ending blanc characters of "string".
 
static bool CompareStrings (char *str1, char *str2)
 Compares two strings (str1 and str2). Returns true if they match, false otherwise.
 
static int file_exist (const char *name)
 Returns true (1) if file "name" does exist, 0 otherwise.
 
static const char * filename_name (const char *name)
 Returns pointer to filename without path.
 
static const char * filename_ext (const char *buf)
 Returns pointer to filename extension.
 
static char * filename_setext (char *buf, int buflen, const char *ext)
 set/change filename extension
 
static int filename_dir (char *name)
 returns the length of the path in (path)name
 
static const char * filename_date (const char *name)
 Returns pointer to the string that contains the date of last file modification/creation.
 
static FILE * fopen (const char *filename, const char *mode)
 Cross-platform function to fopen function that supports UTF-8 encoded name.
 
static int stat (const char *f, struct stat *b)
 Cross-platform function to stat() a file using a UTF-8 encoded name or value.
 
static size_t strlcpy (char *d, const char *s, size_t bufsize)
 The implementation of nonstandard strlcpy function.
 
static int nLines (FILE *stream)
 Returns number of lines of text file from current pointer to EOF.
 
static int nColumns (FILE *stream, char Par[][32])
 Returns number of columns of text file (number of strings in the first line). Names of columns are stored in Par array.
 
static int isstrblank (char *cc, int iLen)
 Checks if string (cc) is blank (1/0)
 
static void ReadVect3 (FILE *stream, VECTOR_3D *Vec, double dScal=1.)
 Function to read VECTOR_3D Vec components from FILE "stream". The read values are scaled by multiplier "dScal".
 
static int readln (FILE *ff, char *value_x)
 Pascal style "readln" function to read string.
 
static int readln (FILE *ff, int *value_x)
 Pascal style "readln" function to read int.
 
static int readln (FILE *ff, long *value_x)
 Pascal style "readln" function to read long.
 
static int readln (FILE *ff, float *value_x)
 Pascal style "readln" function to read float.
 
static int readln (FILE *ff, double *value_x)
 Pascal style "readln" function to read double.
 
static int readln (FILE *ff, long double *value_x)
 Pascal style "readln" function to read long double.
 
static int readln (FILE *ff)
 Pascal style "readln" function to read comment.
 
static int readln (FILE *ff, VECTOR_3D *vec)
 Pascal style "readln" function to read VECTOR_3D components.
 
static int read (FILE *ff, char *value_x)
 Pascal style "read" function to read string.
 
static int read (FILE *ff, int *value_x)
 Pascal style "read" function to read int.
 
static int read (FILE *ff, long *value_x)
 Pascal style "read" function to read long.
 
static int read (FILE *ff, float *value_x)
 Pascal style "read" function to read float.
 
static int read (FILE *ff, double *value_x)
 Pascal style "read" function to read double.
 
static int read (FILE *ff, long double *value_x)
 Pascal style "read" function to read long double.
 
static int read (FILE *ff, VECTOR_3D *vec)
 Pascal style "read" function to read VECTOR_3D components.
 

Detailed Description

Simple I/O functions class.

Definition at line 41 of file iofun.h.

Member Function Documentation

◆ ClipFileName()

void IOFUN::ClipFileName ( char * string)
static

Clipping of the ending blanc characters of "string".

Definition at line 250 of file iofun.cpp.

251{
252 int len = strlen( string );
253 int i=0;
254 while( !( string[i] == '#' || string[i] == '\0' ) ) i++;
255 i--;
256 while( isspace( string[i] ) )i--;
257 i++;
258 string[i] = '\0';
259 for( int ii=i; ii<len; ii++ )string[ii] = '\0';
260
261#ifdef WIN32
262 Unix2Win( string );
263#else
264 Win2Unix( string );
265#endif
266}
static void Win2Unix(char *s)
conversion of directory separators - MS Windows to Unix
Definition iofun.cpp:25
static void Unix2Win(char *s)
conversion of directory separators - Unix to MS Windows
Definition iofun.cpp:33

Referenced by SDSA_PARAMS::Read(), PANUKL_PLR::Read(), PANUKL_PRJ::Read(), PANUKL_AUTO::Read(), CON_FILE::ReadCON(), NGH_FILE::ReadNGH(), PAR_FILE::ReadPAR(), and PRS_FILE::ReadPRS().

◆ ClipString()

void IOFUN::ClipString ( char * string)
static

Clipping of the "string" up to the first blanc character or comment "#" character.

Definition at line 243 of file iofun.cpp.

244{
245 int i=0;
246 while( !( isspace( string[i] ) || string[i] == '#' || string[i] == '\0' ) ) i++;
247 string[i] = '\0';
248}

◆ CompareStrings()

bool IOFUN::CompareStrings ( char * str1,
char * str2 )
static

Compares two strings (str1 and str2). Returns true if they match, false otherwise.

Definition at line 270 of file iofun.cpp.

271{
272 char tmp1[256], tmp2[256];
273 int i;
274 for( i=0; i<(int)strlen(str1); i++ ) tmp1[i] = tolower( str1[i] ); tmp1[i] = '\0';
275 for( i=0; i<(int)strlen(str2); i++ ) tmp2[i] = tolower( str2[i] ); tmp2[i] = '\0';
276 if( strcmp( tmp1, tmp2 ) == 0 )
277 return true;
278 else
279 return false;
280}

Referenced by MS2_Data::Read(), CONNECT_DATA::Read(), MS2_Data::ReadChordDivision(), MS2_Data::ReadFusAirfoil(), MS2_Data::ReadFusFromParams(), MS2_Data::ReadProfile(), MS2_Data::ReadWing(), and MS2_Data::ReadWingModule().

◆ file_exist()

int IOFUN::file_exist ( const char * name)
static

Returns true (1) if file "name" does exist, 0 otherwise.

Definition at line 327 of file iofun.cpp.

328{
329 int iReturn = 0;
330 FILE *fc = fopen( name, "r" );
331 if( fc )
332 {
333 fclose( fc );
334 iReturn = 1;
335 }
336
337 return iReturn;
338}
static FILE * fopen(const char *filename, const char *mode)
Cross-platform function to fopen function that supports UTF-8 encoded name.
Definition iofun.cpp:358

◆ filename_date()

const char * IOFUN::filename_date ( const char * name)
static

Returns pointer to the string that contains the date of last file modification/creation.

Definition at line 399 of file iofun.cpp.

400{
401 static char date[100];
402 struct stat b;
403 if( !stat( name, & b ) )
404 {
405 strftime( date, 100, "%d/%m/%Y %H:%M:%S", localtime( & b.st_mtime ) );
406 return date;
407 }
408 else
409 {
410 fprintf( stderr, "filename_date Error\n" );
411 return 0;
412 }
413}
static int stat(const char *f, struct stat *b)
Cross-platform function to stat() a file using a UTF-8 encoded name or value.
Definition iofun.cpp:382

Referenced by GRID_ARRAYS::ReadDAT(), GRID_ARRAYS::ReadDATw(), GRID_ARRAYS::ReadINP(), and GRID_ARRAYS::ReadWyn().

◆ filename_dir()

int IOFUN::filename_dir ( char * name)
static

returns the length of the path in (path)name

Definition at line 340 of file iofun.cpp.

341{
342 int ilen = strlen(name);
343 if( ilen == 0 )return 0;
344 int i = ilen-1;
345 while( name[i] != '/' && name[i] != '\\' && name[i] != ':' && i >= 0 )
346 i--;
347 int id = i+1;
348
349#ifdef WIN32
350 Unix2Win( name );
351#else
352 Win2Unix( name );
353#endif
354
355 return id;
356}

◆ filename_ext()

const char * IOFUN::filename_ext ( const char * buf)
static

Returns pointer to filename extension.

Definition at line 302 of file iofun.cpp.

303{
304 const char *q = 0;
305 const char *p = buf;
306 for (p=buf; *p; p++)
307 {
308 if (*p == '/') q = 0;
309#ifdef WIN32
310 else if (*p == '\\') q = 0;
311#endif
312 else if (*p == '.') q = p;
313 }
314 return q ? q : p;
315}

Referenced by filename_setext(), and MS2_Data::RemoveExt().

◆ filename_name()

const char * IOFUN::filename_name ( const char * name)
static

Returns pointer to filename without path.

Definition at line 284 of file iofun.cpp.

285{
286 const char *p, *q;
287 if (!name) return (0);
288 for ( p = q = name ; *p ; )
289 {
290 if ( ( p[0] == ':' ) && ( p[1] == ':' ) )
291 {
292 q = p+2;
293 p++;
294 }
295 else if (p[0] == '/' || p[0]=='\\' )
296 q = p + 1;
297 p++;
298 }
299 return q;
300}

Referenced by PRS_FILE::DefNames(), MS2_Data::ReadFusAirfoil(), MS2_Data::ReadProfile(), MS2_Data::ReadSection(), MS2_Data::ReadWing(), and MS2_Data::ReadWingModule().

◆ filename_setext()

char * IOFUN::filename_setext ( char * buf,
int buflen,
const char * ext )
static

set/change filename extension

Definition at line 317 of file iofun.cpp.

318{
319 char *q = (char *)filename_ext(buf);
320 if (ext)
321 strlcpy(q,ext,buflen - (q - buf));
322 else
323 *q = 0;
324 return (buf);
325}
static const char * filename_ext(const char *buf)
Returns pointer to filename extension.
Definition iofun.cpp:302
static size_t strlcpy(char *d, const char *s, size_t bufsize)
The implementation of nonstandard strlcpy function.
Definition iofun.cpp:415

Referenced by PRS_FILE::DefFile().

◆ fopen()

FILE * IOFUN::fopen ( const char * filename,
const char * mode )
static

Cross-platform function to fopen function that supports UTF-8 encoded name.

Definition at line 358 of file iofun.cpp.

359{
360#ifdef _WIN32
361 int fn_len_s = strlen(filename);
362 int m_len_s = strlen(mode);
363 if( fn_len_s == 0 ) return NULL;
364 if( m_len_s == 0 ) return NULL;
365 wchar_t path[MAX_PATH];
366 wchar_t wmode[MAX_PATH];
367
368 int new_Len_f = MultiByteToWideChar(CP_UTF8, 0, filename, fn_len_s, path, fn_len_s);
369 if( new_Len_f >= MAX_PATH ) return NULL;
370 path[new_Len_f] = L'\0';
371
372 int new_Len_m = MultiByteToWideChar(CP_UTF8, 0, mode, m_len_s, wmode, m_len_s);
373 if( new_Len_m >= MAX_PATH ) return NULL;
374 wmode[new_Len_m] = L'\0';
375
376 return _wfopen(path, wmode);
377#else
378 return ::fopen(filename, mode);
379#endif
380}

Referenced by file_exist(), SDSA_PARAMS::Read(), PANUKL_PLR::Read(), PANUKL_PRJ::Read(), PANUKL_AUTO::Read(), MS2_Data::Read(), SDSA_FILE::Read(), TXT_OUT_FILE::Read(), CON_FILE::ReadCON(), GRID_ARRAYS::ReadDAT(), GRID_ARRAYS::ReadDATw(), GRID_ARRAYS::ReadINP(), NGH_FILE::ReadNGH(), PAR_FILE::ReadPAR(), PRS_FILE::ReadPRS(), GRID_ARRAYS::ReadWyn(), SDSA_PARAMS::Write(), PANUKL_PLR::Write(), PANUKL_PRJ::Write(), PANUKL_AUTO::Write(), SDSA_FILE::Write(), TXT_OUT_FILE::Write(), CON_FILE::WriteCON(), GRID_ARRAYS::WriteDAT(), GRID_ARRAYS::WriteInpFromPanels(), GRID_ARRAYS::WriteInpFromPoints(), NGH_FILE::WriteNGH(), PAR_FILE::WritePAR(), PRS_FILE::WritePRS(), and GRID_ARRAYS::WriteWyn().

◆ isstrblank()

int IOFUN::isstrblank ( char * cc,
int iLen )
static

Checks if string (cc) is blank (1/0)

Definition at line 476 of file iofun.cpp.

477{
478 int iReturn = 1;
479 if( iLen > 0 )
480 {
481 for( int i=0; i<iLen; i++ )
482 {
483 if( !isblank(cc[i]) )
484 {
485 iReturn = 0;
486 break;
487 }
488 }
489 }
490// else
491// iReturn = 0;
492
493 return iReturn;
494}

Referenced by nLines().

◆ nColumns()

int IOFUN::nColumns ( FILE * stream,
char Par[][32] )
static

Returns number of columns of text file (number of strings in the first line). Names of columns are stored in Par array.

Definition at line 447 of file iofun.cpp.

448{
449 char cc , cc_old = ' ';
450
451 cc = fgetc( stream );
452 int i = 0;
453 int licz = -1;
454 while ( cc != '\n' && cc != EOF && cc != 0xD )
455 {
456 if( ( isblank(cc_old) && !isblank(cc) ) )
457 {
458 i = 0;
459 licz++;
460 Par[licz][i] = cc;
461 i++;
462 }
463 else if( !isblank(cc) )
464 {
465 Par[licz][i] = cc;
466 i++;
467 }
468 cc_old = cc;
469 cc = fgetc( stream);
470 }
471 if( cc == 0xD) cc = fgetc( stream);
472
473 return licz+1;
474}

Referenced by TXT_OUT_FILE::Read().

◆ nLines()

int IOFUN::nLines ( FILE * stream)
static

Returns number of lines of text file from current pointer to EOF.

Definition at line 426 of file iofun.cpp.

427{
428 long lPos = ftell( stream );
429
430 char cc[512];
431 long int i = 0;
432 int iLen = 0;
433 do
434 {
435 ReadStrL( stream, cc, &iLen );
436 if( isstrblank( cc, iLen ) ) continue;
437 i++;
438 }
439 while( iLen > 0 || cc[iLen+1] != EOF );
440 //i--;
441
442 fseek( stream, lPos, SEEK_SET );
443
444 return i;
445}
static void ReadStrL(FILE *stream, char *Par, int *len)
Function to read the string (Par) from FILE "stream". It reads from current pointer of FILE to the en...
Definition iofun.cpp:216
static int isstrblank(char *cc, int iLen)
Checks if string (cc) is blank (1/0)
Definition iofun.cpp:476

Referenced by TXT_OUT_FILE::Read().

◆ read() [1/7]

int IOFUN::read ( FILE * ff,
char * value_x )
static

Pascal style "read" function to read string.

Definition at line 561 of file iofun.cpp.

562{
563 fscanf( ff, "%s", value_x );
564 return 0;
565}

◆ read() [2/7]

int IOFUN::read ( FILE * ff,
double * value_x )
static

Pascal style "read" function to read double.

Definition at line 585 of file iofun.cpp.

586{
587 fscanf( ff, "%lf", value_x );
588 return 0;
589}

◆ read() [3/7]

int IOFUN::read ( FILE * ff,
float * value_x )
static

Pascal style "read" function to read float.

Definition at line 579 of file iofun.cpp.

580{
581 fscanf( ff, "%f", value_x );
582 return 0;
583}

◆ read() [4/7]

int IOFUN::read ( FILE * ff,
int * value_x )
static

Pascal style "read" function to read int.

Definition at line 567 of file iofun.cpp.

568{
569 fscanf( ff, "%d", value_x );
570 return 0;
571}

◆ read() [5/7]

int IOFUN::read ( FILE * ff,
long * value_x )
static

Pascal style "read" function to read long.

Definition at line 573 of file iofun.cpp.

574{
575 fscanf( ff, "%ld", value_x );
576 return 0;
577}

◆ read() [6/7]

int IOFUN::read ( FILE * ff,
long double * value_x )
static

Pascal style "read" function to read long double.

Definition at line 591 of file iofun.cpp.

592{
593 fscanf( ff, "%Lf", value_x);
594 return 0;
595}

◆ read() [7/7]

int IOFUN::read ( FILE * ff,
VECTOR_3D * vec )
static

Pascal style "read" function to read VECTOR_3D components.

Definition at line 597 of file iofun.cpp.

598{
599 fscanf( ff, "%lf%lf%lf", &vec->x, &vec->y, &vec->z );
600 return 0;
601}
double x
x coordinate
Definition vector3d.h:38
double z
z coordinate
Definition vector3d.h:38
double y
y coordinate
Definition vector3d.h:38

◆ ReadComm()

int IOFUN::ReadComm ( FILE * stream)
static

Function to read of a comment till the end of line. It returns 0 or EOF if it is performed.

Definition at line 42 of file iofun.cpp.

43{
44 char a;
45 while ( a = fgetc( stream ) , ( a != '\n' && a != EOF && a != 0xD ) ); /* omit comment */
46 if( a == EOF )return EOF;
47 return 0;
48}

Referenced by MS2_Data::find_section(), MS2_Data::has_section(), PANUKL_PLR::Read(), PANUKL_PRJ::Read(), MS2_Data::Read(), ReadDummy(), readln(), readln(), PAR_FILE::ReadPAR(), ReadPar(), ReadPar(), ReadPar(), ReadPar(), PRS_FILE::ReadPRS(), ReadVect(), ReadVect(), ReadVect(), ReadVect(), MS2_Data::ReadWing(), and GRID_ARRAYS::ReadWyn().

◆ ReadDummy()

void IOFUN::ReadDummy ( FILE * stream)
static

Function to read a comment line.

Definition at line 50 of file iofun.cpp.

51{
52 unsigned char ucRes = 1;
53 while ( ucRes )
54 {
55 char ch = fgetc(stream);
56 ucRes = (ch == '#');
57 ungetc(ch,stream);
58 //fseek( stream, -1, SEEK_CUR );
59 if( ucRes )ReadComm( stream );
60 }
61}
static int ReadComm(FILE *stream)
Function to read of a comment till the end of line. It returns 0 or EOF if it is performed.
Definition iofun.cpp:42

Referenced by MS2_Data::Read(), MS2_Data::ReadChordDivision(), ReadPar(), ReadPar(), ReadPar(), ReadPar(), ReadStr(), ReadVect(), ReadVect(), ReadVect(), ReadVect(), and MS2_Data::ReadWingModule().

◆ readln() [1/8]

int IOFUN::readln ( FILE * ff)
static

Pascal style "readln" function to read comment.

Definition at line 547 of file iofun.cpp.

548{
549 ReadComm( ff );
550 return 0;
551}

◆ readln() [2/8]

int IOFUN::readln ( FILE * ff,
char * value_x )
static

Pascal style "readln" function to read string.

Definition at line 510 of file iofun.cpp.

511{
512 fscanf( ff, "%s", value_x );
513 return ReadComm( ff );
514 //return 0;
515}

◆ readln() [3/8]

int IOFUN::readln ( FILE * ff,
double * value_x )
static

Pascal style "readln" function to read double.

Definition at line 535 of file iofun.cpp.

536{
537 ReadPar( ff, "%lf", value_x );
538 return 0;
539}
static int ReadPar(FILE *stream, const char *Format, void *Par)
Function to read one variable. The type of variable depends on Format, compatible with stdio library.
Definition iofun.cpp:67

◆ readln() [4/8]

int IOFUN::readln ( FILE * ff,
float * value_x )
static

Pascal style "readln" function to read float.

Definition at line 529 of file iofun.cpp.

530{
531 ReadPar( ff, "%f", value_x );
532 return 0;
533}

◆ readln() [5/8]

int IOFUN::readln ( FILE * ff,
int * value_x )
static

Pascal style "readln" function to read int.

Definition at line 517 of file iofun.cpp.

518{
519 ReadPar( ff, "%d", value_x );
520 return 0;
521}

◆ readln() [6/8]

int IOFUN::readln ( FILE * ff,
long * value_x )
static

Pascal style "readln" function to read long.

Definition at line 523 of file iofun.cpp.

524{
525 ReadPar( ff, "%ld", value_x );
526 return 0;
527}

◆ readln() [7/8]

int IOFUN::readln ( FILE * ff,
long double * value_x )
static

Pascal style "readln" function to read long double.

Definition at line 541 of file iofun.cpp.

542{
543 ReadPar( ff, "%Lf", value_x );
544 return 0;
545}

◆ readln() [8/8]

int IOFUN::readln ( FILE * ff,
VECTOR_3D * vec )
static

Pascal style "readln" function to read VECTOR_3D components.

Definition at line 553 of file iofun.cpp.

554{
555 ReadVect3( ff, vec );
556 return 0;
557}
static int ReadVect3(FILE *stream, double *Par, double dScal=1.)
Function to read double vector "Par" of "3" dimension from FILE "stream". The read values are scaled ...
Definition iofun.cpp:143

◆ ReadPar() [1/4]

int IOFUN::ReadPar ( FILE * stream,
const char * Format,
void * Par )
static

Function to read one variable. The type of variable depends on Format, compatible with stdio library.

Definition at line 67 of file iofun.cpp.

68{
69 ReadDummy( stream );
70 fscanf( stream, Format, Par ); /* read value */
71 return ReadComm( stream );
72}
static void ReadDummy(FILE *stream)
Function to read a comment line.
Definition iofun.cpp:50

Referenced by MS2_Data::find_section(), SDSA_PARAMS::Read(), PANUKL_PLR::Read(), PANUKL_PRJ::Read(), PANUKL_AUTO::Read(), MS2_Data::Read(), SDSA_FILE::Read(), CONNECT_DATA::Read(), MS2_Data::ReadChordDivision(), CON_FILE::ReadCON(), GRID_ARRAYS::ReadDAT(), GRID_ARRAYS::ReadDATw(), MS2_Data::ReadFusFromParams(), GRID_ARRAYS::ReadINP(), readln(), readln(), readln(), readln(), readln(), NGH_FILE::ReadNGH(), PAR_FILE::ReadPAR(), MS2_Data::ReadProfile(), PRS_FILE::ReadPRS(), MS2_Data::ReadSection(), MS2_Data::ReadWing(), and GRID_ARRAYS::ReadWyn().

◆ ReadPar() [2/4]

int IOFUN::ReadPar ( FILE * stream,
const char * Format,
void * Par1,
void * Par2 )
static

Function to read two variables. The type of variables depends on Format, compatible with stdio library.

Definition at line 74 of file iofun.cpp.

75{
76 ReadDummy( stream );
77 fscanf( stream, Format, Par1, Par2 );
78 return ReadComm( stream );
79}

◆ ReadPar() [3/4]

int IOFUN::ReadPar ( FILE * stream,
const char * Format,
void * Par1,
void * Par2,
void * Par3 )
static

Function to read three variables. The type of variables depends on Format, compatible with stdio library.

Definition at line 81 of file iofun.cpp.

82{
83 ReadDummy( stream );
84 fscanf( stream, Format, Par1, Par2, Par3 );
85 return ReadComm( stream );
86}

◆ ReadPar() [4/4]

int IOFUN::ReadPar ( FILE * stream,
const char * Format,
void * Par1,
void * Par2,
void * Par3,
void * Par4 )
static

Function to read four variables. The type of variables depends on Format, compatible with stdio library.

Definition at line 88 of file iofun.cpp.

89{
90 ReadDummy( stream );
91 fscanf( stream, Format, Par1, Par2, Par3, Par4 );
92 return ReadComm( stream );
93}

◆ ReadStr()

int IOFUN::ReadStr ( FILE * stream,
char * Par )
static

Function to read the new line from FILE "stream" and to store it in table of char "Par". The starting and ending blanc charaters are clipped.

Definition at line 163 of file iofun.cpp.

164{
165 ReadDummy( stream );
166
167 char cc;
168 int i;
169
170 cc = fgetc( stream );
171 i = 0;
172 while ( cc != '\n' && cc != EOF && cc != 0xD )
173 {
174 Par[i] = cc;
175 cc = fgetc( stream);
176 i++;
177 }
178 if( cc == 0xD )
179 {
180 cc = fgetc( stream );
181 if( cc != 0xA )ungetc( cc, stream );
182 }
183
184 Par[i]='\0';
185
186 int j;
187 for( j=i-1; j>0; j-- )
188 {
189 if( isblank(Par[j]) )
190 Par[j] = '\0';
191 else
192 break;
193 }
194
195 char *cRob = new char[j+2];
196 std::strcpy( cRob, Par );
197 int i0 = 0;
198 for( int i=0; i<j+1; i++ )
199 {
200 if( isblank(cRob[i]) )
201 i0 = i+1;
202 else
203 break;
204 }
205 strcpy( Par, cRob+i0 );
206 delete [] cRob;
207
208 if( cc == EOF )return EOF;
209 return strlen( Par );
210}

Referenced by SDSA_PARAMS::Read(), PANUKL_PLR::Read(), PANUKL_PRJ::Read(), PANUKL_AUTO::Read(), MS2_Data::Read(), CONNECT_DATA::Read(), CON_FILE::ReadCON(), GRID_ARRAYS::ReadDAT(), GRID_ARRAYS::ReadDATw(), MS2_Data::ReadFusAirfoil(), MS2_Data::ReadFusFromParams(), GRID_ARRAYS::ReadINP(), NGH_FILE::ReadNGH(), PAR_FILE::ReadPAR(), MS2_Data::ReadProfile(), MS2_Data::ReadProfile(), PRS_FILE::ReadPRS(), MS2_Data::ReadSection(), MS2_Data::ReadWing(), MS2_Data::ReadWingModule(), and GRID_ARRAYS::ReadWyn().

◆ ReadStrL()

void IOFUN::ReadStrL ( FILE * stream,
char * Par,
int * len )
static

Function to read the string (Par) from FILE "stream". It reads from current pointer of FILE to the end of line or EOF. Number of read characters is returned in "len".

Definition at line 216 of file iofun.cpp.

217{
218 char cc;
219 int i;
220
221 cc = fgetc( stream );
222 i = 0;
223 while ( cc != '\n' && cc != EOF && cc != 0xD )
224 {
225 Par[i] = cc;
226 cc = fgetc( stream);
227 i++;
228 }
229 if( cc == 0xD )
230 {
231 cc = fgetc( stream );
232 if( cc != 0xA )ungetc(cc,stream);
233 }
234
235 Par[i]='\0';
236 if( cc == EOF )Par[i+1]=EOF;
237 *len = i;
238
239}

Referenced by nLines().

◆ ReadVect() [1/4]

int IOFUN::ReadVect ( FILE * stream,
double * Par,
int n,
double dScal = 1. )
static

Function to read double vector "Par" of "n" dimension from FILE "stream". The read values are scaled by multiplier "dScal".

Definition at line 99 of file iofun.cpp.

100{
101 ReadDummy( stream );
102 int i, ierr = 0;
103 for( i=0; i<n; i++ ) ierr = fscanf( stream, "%lf", Par+i ); /* read values */
104 if( ierr == -1 ) return -1;
105 ReadComm( stream );
106 for( i=0; i<n; i++ ) Par[i] *= dScal;
107 return 0;
108}

Referenced by CON_FILE::ReadCON(), MS2_Data::ReadFusEllipse(), MS2_Data::ReadFusFromParams(), ReadVect3(), ReadVect3(), ReadVect3(), and ReadVect3().

◆ ReadVect() [2/4]

int IOFUN::ReadVect ( FILE * stream,
float * Par,
int n,
float fScal = 1. )
static

Function to read float vector "Par" of "n" dimension from FILE "stream". The read values are scaled by multiplier "fScal".

Definition at line 109 of file iofun.cpp.

110{
111 ReadDummy( stream );
112 int i, ierr = 0;
113 for( i=0; i<n; i++ ) ierr = fscanf( stream, "%f", Par+i );
114 if( ierr == -1 ) return -1;
115 ReadComm( stream );
116 for( i=0; i<n; i++ ) Par[i] *= fScal;
117 return 0;
118}

◆ ReadVect() [3/4]

int IOFUN::ReadVect ( FILE * stream,
int * Par,
int n,
int iScal = 1 )
static

Function to read int vector "Par" of "n" dimension from FILE "stream". The read values are scaled by multiplier "iScal".

Definition at line 129 of file iofun.cpp.

130{
131 ReadDummy( stream );
132 int i, ierr = 0;
133 for( i=0; i<n; i++ ) ierr = fscanf( stream, "%d", Par+i );
134 if( ierr == -1 ) return -1;
135 ReadComm( stream );
136 for( i=0; i<n; i++ ) Par[i] *= iScal;
137 return 0;
138}

◆ ReadVect() [4/4]

int IOFUN::ReadVect ( FILE * stream,
long * Par,
int n,
long lScal = 1 )
static

Function to read long vector "Par" of "n" dimension from FILE "stream". The read values are scaled by multiplier "lScal".

Definition at line 119 of file iofun.cpp.

120{
121 ReadDummy( stream );
122 int i, ierr = 0;
123 for( i=0; i<n; i++ ) ierr = fscanf( stream, "%ld", Par+i );
124 if( ierr == -1 ) return -1;
125 ReadComm( stream );
126 for( i=0; i<n; i++ ) Par[i] *= lScal;
127 return 0;
128}

◆ ReadVect3() [1/5]

int IOFUN::ReadVect3 ( FILE * stream,
double * Par,
double dScal = 1. )
static

Function to read double vector "Par" of "3" dimension from FILE "stream". The read values are scaled by multiplier "dScal".

Definition at line 143 of file iofun.cpp.

144{
145 return ReadVect( stream, Par, 3, dScal );
146}
static int ReadVect(FILE *stream, double *Par, int n, double dScal=1.)
Function to read double vector "Par" of "n" dimension from FILE "stream". The read values are scaled ...
Definition iofun.cpp:99

Referenced by readln(), and ReadVect3().

◆ ReadVect3() [2/5]

int IOFUN::ReadVect3 ( FILE * stream,
float * Par,
float fScal = 1. )
static

Function to read float vector "Par" of "3" dimension from FILE "stream". The read values are scaled by multiplier "fScal".

Definition at line 147 of file iofun.cpp.

148{
149 return ReadVect( stream, Par, 3, fScal );
150}

◆ ReadVect3() [3/5]

int IOFUN::ReadVect3 ( FILE * stream,
int * Par,
int iScal = 1 )
static

Function to read int vector "Par" of "3" dimension from FILE "stream". The read values are scaled by multiplier "iScal".

Definition at line 155 of file iofun.cpp.

156{
157 return ReadVect( stream, Par, 3, iScal );
158}

◆ ReadVect3() [4/5]

int IOFUN::ReadVect3 ( FILE * stream,
long * Par,
long lScal = 1 )
static

Function to read long vector "Par" of "3" dimension from FILE "stream". The read values are scaled by multiplier "lScal".

Definition at line 151 of file iofun.cpp.

152{
153 return ReadVect( stream, Par, 3, lScal );
154}

◆ ReadVect3() [5/5]

void IOFUN::ReadVect3 ( FILE * stream,
VECTOR_3D * Vec,
double dScal = 1. )
static

Function to read VECTOR_3D Vec components from FILE "stream". The read values are scaled by multiplier "dScal".

Definition at line 496 of file iofun.cpp.

497{
498 double Par[3];
499 ReadVect3( stream, Par, dScal );
500 Vec->GetFrom( Par );
501}
void GetFrom(double xp, double yp, double zp)
sets coordinates from three variables
Definition vector3d.h:65

◆ stat()

int IOFUN::stat ( const char * f,
struct stat * b )
static

Cross-platform function to stat() a file using a UTF-8 encoded name or value.

Definition at line 382 of file iofun.cpp.

383{
384#ifdef WIN32
385 int fn_len_s = strlen(f);
386 if( fn_len_s == 0 ) return 0;
387 wchar_t path[MAX_PATH];
388
389 int new_Len_f = MultiByteToWideChar(CP_UTF8, 0, f, fn_len_s, path, fn_len_s);
390 if( new_Len_f >= MAX_PATH ) return 0;
391 path[new_Len_f] = L'\0';
392
393 return _wstat(path, (struct _stat*)b);
394#else
395 return ::stat(f, b);
396#endif
397}

Referenced by filename_date().

◆ strlcpy()

size_t IOFUN::strlcpy ( char * d,
const char * s,
size_t bufsize )
static

The implementation of nonstandard strlcpy function.

Definition at line 415 of file iofun.cpp.

416{
417 if (size <= 0) return 0;
418 size_t len = strlen(s);
419 size_t retVal = len;
420 if (len >= size) len = size-1;
421 memcpy(d, s, len);
422 d[len] = '\0';
423 return retVal;
424}

Referenced by filename_setext().

◆ Unix2Win()

void IOFUN::Unix2Win ( char * s)
static

conversion of directory separators - Unix to MS Windows

Definition at line 33 of file iofun.cpp.

34{
35 for ( ; *s; s++ )
36 if ( *s == '/' ) *s = '\\';
37}

Referenced by ClipFileName(), and filename_dir().

◆ Win2Unix()

void IOFUN::Win2Unix ( char * s)
static

conversion of directory separators - MS Windows to Unix

Definition at line 25 of file iofun.cpp.

26{
27 for ( ; *s; s++ )
28 if ( *s == '\\' ) *s = '/';
29}

Referenced by ClipFileName(), and filename_dir().


The documentation for this class was generated from the following files: