Flow123d  release_3.0.0-1182-ga9abfa7
Classes | Macros
xio.h File Reference

I/O functions with filename storing, able to track current line in opened file. All standard stdio functions working with files (not stdin, stdout, stderr) should be replaced by their equivalents from XIO library. More...

#include "global_defs.h"
#include "system/system.hh"
#include <map>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  xfile
 XFILE structure holds additional info to generic FILE. More...
 
class  Xio
 

Macros

#define LINE_SIZE   65536
 

Typedefs

typedef struct xfile XFILE
 XFILE structure holds additional info to generic FILE. More...
 

Functions

char * xio_getfname (FILE *f)
 XIO library extensions. More...
 
char * xio_getfmode (FILE *f)
 Get file mode from file stream. More...
 
int xio_getlinesread (FILE *f)
 Get number of read lines from stream. More...
 
char * xio_getfulldescription (FILE *f)
 Get pointer to string with full file description. More...
 
FILE * xfopen (const char *fname, const char *mode)
 File access. More...
 
FILE * xfopen (const std::string &fname, const char *mode)
 
int xfclose (FILE *stream)
 Close file (function) More...
 
int xfflush (FILE *f)
 Flush stream (function) More...
 
FILE * xfreopen (const char *filename, const char *mode, FILE *stream)
 Reopen stream with different file or mode. More...
 
int xfprintf (FILE *out, const char *fmt,...)
 Formatted input/output. More...
 
int xfscanf (FILE *in, const char *fmt,...)
 FSCANF WITH ERROR HANDLING. More...
 
char * xfgets (char *s, int n, FILE *in)
 Character input/output. More...
 
int xfgetc (FILE *f)
 Get character from stream (function) More...
 
int xgetc (FILE *f)
 Get character from stream (function) More...
 
int xungetc (int c, FILE *f)
 Unget character from stream (function) More...
 
size_t xfread (void *ptr, size_t size, size_t count, FILE *stream)
 Direct input/output. More...
 
size_t xfwrite (const void *ptr, size_t size, size_t count, FILE *stream)
 Write block of data to stream, handle errors. More...
 
void xrewind (FILE *f)
 File positioning. More...
 
int xfeof (FILE *f)
 Error-handling. More...
 

Detailed Description

I/O functions with filename storing, able to track current line in opened file. All standard stdio functions working with files (not stdin, stdout, stderr) should be replaced by their equivalents from XIO library.

 * Copyright (C) 2015 Technical University of Liberec. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Author
Jiri Jenicek

Definition in file xio.h.

Macro Definition Documentation

#define LINE_SIZE   65536

Definition at line 37 of file xio.h.

Typedef Documentation

typedef struct xfile XFILE

XFILE structure holds additional info to generic FILE.

Function Documentation

int xfclose ( FILE *  stream)

Close file (function)

Close file (function)

Parameters
[in,out]streampointer to FILE structure
Returns
same as ISO C fclose()

Definition at line 292 of file xio.cc.

Here is the caller graph for this function:

int xfeof ( FILE *  f)

Error-handling.

Check End-of-File indicator (function)

Error-handling.

Parameters
[in]fpointer to FILE structure
Returns
same as ISO C feof()

Definition at line 628 of file xio.cc.

int xfflush ( FILE *  f)

Flush stream (function)

Flush stream (function)

Parameters
[in,out]fpointer to FILE structure
Returns
same as ISO C fflush()

Definition at line 270 of file xio.cc.

int xfgetc ( FILE *  f)

Get character from stream (function)

Get character from stream (function)

Parameters
[in,out]fpointer to FILE structure
Returns
same as ISO C fgetc()

Definition at line 431 of file xio.cc.

Here is the caller graph for this function:

char* xfgets ( char *  s,
int  n,
FILE *  in 
)

Character input/output.

Get string from stream (function)

Character input/output.

Parameters
[out]sPointer to an array of chars where the string read is stored
[in]nMaximum number of characters to be read (including the final null-character)
[in,out]inPointer to a FILE
Returns
same as ISO C fgets()

Definition at line 563 of file xio.cc.

Here is the caller graph for this function:

FILE* xfopen ( const char *  fname,
const char *  mode 
)

File access.

Open file (function)

File access.

Parameters
[in]fnamefilename to open
[in]modeopening mode
Returns
same as ISO C fopen()

Definition at line 241 of file xio.cc.

FILE* xfopen ( const std::string &  fname,
const char *  mode 
)

Definition at line 229 of file xio.cc.

Here is the caller graph for this function:

int xfprintf ( FILE *  out,
const char *  fmt,
  ... 
)

Formatted input/output.

Write formatted output to stream (function)

Formatted input/output.

Definition at line 378 of file xio.cc.

Here is the caller graph for this function:

size_t xfread ( void *  ptr,
size_t  size,
size_t  count,
FILE *  stream 
)

Direct input/output.

Read block of data from stream (function)

Direct input/output.

Parameters
[out]ptrPointer to a block of memory with a minimum size of (size*count) bytes.
[in]sizeSize in bytes of each element to be read.
[in]countNumber of elements, each one with a size of size bytes.
[in,out]streamPointer to a FILE object that specifies an input stream.
Returns
same as ISO C fread()

Definition at line 518 of file xio.cc.

FILE* xfreopen ( const char *  filename,
const char *  mode,
FILE *  stream 
)

Reopen stream with different file or mode.

Parameters
[in]filenameName of the file to be opened
[in]modeFile access mode
[in,out]streamPointer to a FILE object that identifies the stream to be reopened
Returns
Same as ISO C freopen()

Definition at line 331 of file xio.cc.

int xfscanf ( FILE *  in,
const char *  fmt,
  ... 
)

FSCANF WITH ERROR HANDLING.

Read formatted data from stream (function)

Definition at line 395 of file xio.cc.

size_t xfwrite ( const void *  ptr,
size_t  size,
size_t  count,
FILE *  stream 
)

Write block of data to stream, handle errors.

Write block of data to stream (function)

Parameters
[in]ptrPointer to a block of memory with a minimum size of (size*count) bytes.
[in]sizeSize in bytes of each element to be written.
[in]countNumber of elements, each one with a size of size bytes.
[in,out]streamPointer to a FILE object that specifies an output stream.
Returns
same as ISO C fwrite()

Definition at line 541 of file xio.cc.

int xgetc ( FILE *  f)

Get character from stream (function)

Get character from stream (function)

Parameters
[in,out]fpointer to FILE structure
Returns
same as ISO C getc()

Definition at line 414 of file xio.cc.

char* xio_getfmode ( FILE *  f)

Get file mode from file stream.

Parameters
[in]fpointer to FILE structure
Returns
pointer to file opening mode if OK, NULL if file stream is not known

Definition at line 126 of file xio.cc.

char* xio_getfname ( FILE *  f)

XIO library extensions.

Get file name from file stream

XIO library extensions.

Parameters
[in]fpointer to FILE structure
Returns
pointer to file name if OK, NULL if file stream is not known

Definition at line 103 of file xio.cc.

Here is the caller graph for this function:

char* xio_getfulldescription ( FILE *  f)

Get pointer to string with full file description.

Get pointer to string with full file description

Parameters
[in]fpointer to FILE structure
Returns
pointer to string with description, null terminated, no LF

Definition at line 172 of file xio.cc.

int xio_getlinesread ( FILE *  f)

Get number of read lines from stream.

Get number of read lines from stream.

Parameters
[in]fpointer to FILE structure
Returns
number of lines read if OK, -1 if file stream is not known

Definition at line 149 of file xio.cc.

void xrewind ( FILE *  f)

File positioning.

Set position indicator to the beginning (function)

File positioning.

Parameters
[in,out]fpointer to FILE structure

Definition at line 602 of file xio.cc.

int xungetc ( int  c,
FILE *  f 
)

Unget character from stream (function)

Unget character from stream (function)

Parameters
[in]ccharacter to push back
[in,out]fpointer to FILE structure with INPUT stream
Returns
same as ISO C ungetc()

Definition at line 465 of file xio.cc.