1.4.0
CCC
 
io.cpp File Reference
#include "geoslib_io.h"
#include "geoslib_old_f.h"
#include "Basic/Utilities.hpp"
#include "Basic/File.hpp"
#include "Basic/String.hpp"
#include "Basic/OptDbg.hpp"
#include "Core/io.hpp"
#include <string.h>
#include <stdarg.h>
#include <math.h>

Functions

static void st_print (const char *string)
 
static void st_read (const char *prompt, char *buffer)
 
static void st_exit (void)
 
void redefine_message (void(*write_func)(const char *))
 
void redefine_error (void(*warn_func)(const char *))
 
void redefine_read (void(*read_func)(const char *, char *))
 
void redefine_exit (void(*exit_func)(void))
 
void string_strip_blanks (char *string, int flag_lead)
 
void string_strip_quotes (char *string)
 
void message_extern (const char *string)
 
void exit_extern ()
 
void mem_error (int nbyte)
 
FILE * _file_open (const char *filename, int mode)
 
void _file_delimitors (char del_com, const char *del_sep, char del_blk)
 
void print_current_line (void)
 
static int st_only_blanks (char *string)
 
int _file_read (FILE *file, const char *format, va_list ap)
 
int _file_get_ncol (FILE *file)
 
void _erase_current_string (void)
 
int _buffer_read (char **buffer, const char *format, va_list ap)
 
void _file_write (FILE *file, const char *format, va_list ap)
 
void _buffer_write (char *buffer, const char *format, va_list ap)
 
void _lire_string (const char *question, int flag_def, const char *valdef, char *answer)
 
int _lire_int (const char *question, int flag_def, int valdef, int valmin, int valmax)
 
double _lire_double (const char *question, int flag_def, double valdef, double valmin, double valmax)
 
int _lire_logical (const char *question, int flag_def, int valdef)
 
void record_close (void)
 
int _record_read (FILE *file, const char *format,...)
 

Variables

static char BUFFER [STRING_LENGTH]
 
static char DEL_COM = '#'
 
static char DEL_BLK = ' '
 
const char * DEL_SEP = " "
 
static void(* WRITE_FUNC )(const char *) = (void (*)(const char*)) st_print
 
static void(* WARN_FUNC )(const char *) = (void (*)(const char*)) st_print
 
static void(* READ_FUNC )(const char *, char *) = st_read
 
static void(* EXIT_FUNC )(void) = st_exit
 
static char LINE [LONG_SIZE]
 
static char LINE_MEM [LONG_SIZE]
 
static char * LCUR
 
static char * LINEB
 
static char * cur = NULL
 

Function Documentation

◆ _buffer_read()

int _buffer_read ( char **  buffer,
const char *  format,
va_list  ap 
)

Read the next token from the buffer

Returns
-1 if the end-of-record has been found
1 for a decoding error
0 otherwise
Parameters
[in]bufferBuffer to be read
[in]formatformat
[out]apva_list containing the read variables

This method is not documented on purpose. It should remain private

◆ _buffer_write()

void _buffer_write ( char *  buffer,
const char *  format,
va_list  ap 
)

Write the next token into the buffer

Parameters
[in]bufferWriting buffer
[in]formatEncoding format
[in]apva_list to be written

This method is not documented on purpose. It should remain private

◆ _erase_current_string()

void _erase_current_string ( void  )

Erase the current decoding string

This method is not documented on purpose. It should remain private

◆ _file_delimitors()

void _file_delimitors ( char  del_com,
const char *  del_sep,
char  del_blk 
)

Define the file delimitors

Parameters
[in]del_comDelimitor for comments
[in]del_sepDelimitor for separator
[in]del_blkDelimitor for blank

This method is not documented on purpose. It should remain private

◆ _file_get_ncol()

int _file_get_ncol ( FILE *  file)

Get the number of tokens in the line

Returns
Number of tokens
Parameters
[in]fileFILE structure

This method is not documented on purpose. It should remain private

◆ _file_open()

FILE* _file_open ( const char *  filename,
int  mode 
)

Open an ASCII file

Returns
FILE returned pointer
Parameters
[in]filenameLocal file name
[in]modetype of file (OLD or NEW)

This method is not documented on purpose. It should remain private

◆ _file_read()

int _file_read ( FILE *  file,
const char *  format,
va_list  ap 
)

Read the next token from the file

Returns
-1 if the end-of-file has been found
1 for a decoding error
0 otherwise
Parameters
[in]fileFILE structure
[in]formatformat
[in]apValue to be read

This method is not documented on purpose. It should remain private

◆ _file_write()

void _file_write ( FILE *  file,
const char *  format,
va_list  ap 
)

Write the next token from the file

Parameters
[in]fileFILE structure
[in]formatEncoding format
[in]apValue to be written

This method is not documented on purpose. It should remain private

◆ _lire_double()

double _lire_double ( const char *  question,
int  flag_def,
double  valdef,
double  valmin,
double  valmax 
)

Read a double value

Returns
Double value
Parameters
[in]questionQuestion to be asked
[in]flag_def1 if the default is authorized; 0 otherwise
[in]valdefDefault value or TEST
[in]valminMinimum authorized value or TEST
[in]valmaxMaximum authorized value or TEST

This method is not documented on purpose. It should remain private

◆ _lire_int()

int _lire_int ( const char *  question,
int  flag_def,
int  valdef,
int  valmin,
int  valmax 
)

Read an integer value

Returns
Integer value
Parameters
[in]questionQuestion to be asked
[in]flag_def1 if the default is authorized; 0 otherwise
[in]valdefDefault value or ITEST
[in]valminMinimum authorized value or ITEST
[in]valmaxMaximum authorized value or ITEST

This method is not documented on purpose. It should remain private

◆ _lire_logical()

int _lire_logical ( const char *  question,
int  flag_def,
int  valdef 
)

Read a boolean answer

Returns
Integer value: 1 for 'yes' and 0 for 'no'
Parameters
[in]questionQuestion to be asked
[in]flag_def1 if the default is authorized; 0 otherwise
[in]valdefDefault value (0 for NO and 1 for YES)

This method is not documented on purpose. It should remain private

◆ _lire_string()

void _lire_string ( const char *  question,
int  flag_def,
const char *  valdef,
char *  answer 
)

Read astring

Parameters
[in]questionQuestion to be asked
[in]flag_def1 if the default is authorized; 0 otherwise
[in]valdefDefault string
[out]answerAnswering string

This method is not documented on purpose. It should remain private

◆ _record_read()

int _record_read ( FILE *  file,
const char *  format,
  ... 
)

Read the next record

Returns
Error return code
Parameters
[in]filePointer to the file to be read
[in]formatEncoding format
[in]...Value to be written

This method is not documented on purpose. It should remain private

◆ exit_extern()

void exit_extern ( )

External function to provoke an exit of API This call comes from AStringable where initial mes_abort() has been moved

◆ mem_error()

void mem_error ( int  nbyte)

Problem in memory allocation

Parameters
[in]nbytenumber of bytes to be allocated

◆ message_extern()

void message_extern ( const char *  string)

Print a message This call comes from AStringable where initial message() has been moved

Parameters
[in]stringString to be displayed

◆ print_current_line()

void print_current_line ( void  )

Print the current line read from an ASCII file

◆ record_close()

void record_close ( void  )

Read the next record

This method is not documented on purpose. It should remain private

◆ redefine_error()

void redefine_error ( void(*)(const char *)  warn_func)

Redefine the IO routine for printing error message

Parameters
[in]warn_funcWarning function

◆ redefine_exit()

void redefine_exit ( void(*)(void)  exit_func)

Redefine the exiting routine

Parameters
[in]exit_funcExiting function

◆ redefine_message()

void redefine_message ( void(*)(const char *)  write_func)

Redefine the IO routine for printing message

Parameters
[in]write_funcWriting function

◆ redefine_read()

void redefine_read ( void(*)(const char *, char *)  read_func)

Redefine the IO routine for Reading

Parameters
[in]read_funcReading function

◆ st_exit()

static void st_exit ( void  )
static

Exit from the gstlearn library (not killing the encapsulation if any)

◆ st_only_blanks()

static int st_only_blanks ( char *  string)
static

Check if a string is composed of blanks only

Returns
1 if it is only blanks
Parameters
[in]stringString to be checked

◆ st_print()

static void st_print ( const char *  string)
static

Internal print from the library

Parameters
[in]stringMessage to be printed

◆ st_read()

static void st_read ( const char *  prompt,
char *  buffer 
)
static

Read a string from the Standard Input

Parameters
[in]promptString to be prompted to ask the question
[in]bufferArray where the Input string is stored

◆ string_strip_blanks()

void string_strip_blanks ( char *  string,
int  flag_lead 
)

Strip the blanks from a string

Parameters
[in,out]stringString to be cleaned
[in]flag_lead1 to strip only the leading blanks

◆ string_strip_quotes()

void string_strip_quotes ( char *  string)

Strip the leading and trailing quotes from a string

Parameters
[in,out]stringString to be cleaned
Remarks
The quote is searched in first position. If not found, nothing done
If found, the trailing quote is stripped, if similar to the first
character

Variable Documentation

◆ BUFFER

char BUFFER[STRING_LENGTH]
static

◆ cur

char* cur = NULL
static

◆ DEL_BLK

char DEL_BLK = ' '
static

◆ DEL_COM

char DEL_COM = '#'
static

◆ DEL_SEP

const char* DEL_SEP = " "

◆ EXIT_FUNC

void(* EXIT_FUNC) (void) ( void  ) = st_exit
static

◆ LCUR

char * LCUR
static

◆ LINE

char LINE[LONG_SIZE]
static

◆ LINE_MEM

char LINE_MEM[LONG_SIZE]
static

◆ LINEB

char * LINEB
static

◆ READ_FUNC

void(* READ_FUNC) (const char *, char *) ( const char *  ,
char *   
) = st_read
static

◆ WARN_FUNC

void(* WARN_FUNC) (const char *) ( const char *  ) = (void (*)(const char*)) st_print
static

◆ WRITE_FUNC

void(* WRITE_FUNC) (const char *) ( const char *  ) = (void (*)(const char*)) st_print
static