INGOR
Public Member Functions | List of all members
ytFile Class Reference

File stream related routines. More...

#include <ytFile.h>

Public Member Functions

int ytFile_readLine (FILE *fp, char **buff, size_t *size)
 Reads one line from the given file stream. More...
 
void ytFile_printComma_size_t (FILE *fp, size_t value)
 Prints a size_t value with delimiters for each 3-digit. More...
 
void ytFile_printBit64 (FILE *fp, uint64_t b)
 Prints a 64 unsigned integer value in binary. More...
 
ytIntArrayytFile_readNodes (FILE *fp, int col, ytIntArray *array, ytData *data)
 Reads a node list file. More...
 
FILE * ytFile_ropen (const char *filename)
 Opens the file for reading. More...
 
FILE * ytFile_wopen (const char *filename)
 Opens the file for writing. More...
 
void ytFile_flush ()
 Alias of ytStdioBuff_flush(). More...
 

Detailed Description

File stream related routines.

Member Function Documentation

◆ ytFile_flush()

void ytFile_flush ( )

Alias of ytStdioBuff_flush().

This outputs the buffered data for the standard output if available.

◆ ytFile_printBit64()

void ytFile_printBit64 ( FILE *  fp,
uint64_t  b 
)

Prints a 64 unsigned integer value in binary.

Parameters
fpfile stream.
bvalue to be printed.
Go to Top

◆ ytFile_printComma_size_t()

void ytFile_printComma_size_t ( FILE *  fp,
size_t  value 
)

Prints a size_t value with delimiters for each 3-digit.

Parameters
fpfile stream.
valuevalue to be printed.
Go to Top

◆ ytFile_readLine()

int ytFile_readLine ( FILE *  fp,
char **  buff,
size_t *  size 
)

Reads one line from the given file stream.

The read string is stored in buff. This automatically allocates memory for buff and extends the size required to read the entire line. To do so, user needs to pass the buffer and the size of it by pointers. The buffer can be empty (NULL). If so, set 0 to the variable pointed by size.

This regards all CR, CR+LF, and LF as a new line marker. The newline character at the end of line is removed.

Parameters
fpinput stream to be read.
buffpointer to the pointer to the buffer. The buffer needs to be the pointer returned by malloc and so on.
sizepointer to the buffer size.
Returns
0 if succeeded, or non-zero if failed or reached to the end of the file.
Go to Top

◆ ytFile_readNodes()

ytIntArray * ytFile_readNodes ( FILE *  fp,
int  col,
ytIntArray array,
ytData data 
)

Reads a node list file.

This reads a column of a tab-seperated text file consisting of node names, and returns their corresponding internal node IDs according to the given data.

The column position to read is given by the col parameter.

Parameters
fp
col
arrayNULL acceptable. If so, new ytIntArray instance is generated and returned. Othewise, this adds read node IDs to the given instance. This does not clear the given array instance before adding read IDs.
data

◆ ytFile_ropen()

FILE * ytFile_ropen ( const char *  filename)

Opens the file for reading.

If ytStdioBuff_read() has been already called, and the file name is STDIN_n, the file stream pointer of the n-th data set read from the standard input is returned.

Parameters
filenamefile name of the file to open, or "STDIN_n" to specify the data set from the standard input. n (≥1) represents the index of the order to read.

◆ ytFile_wopen()

FILE * ytFile_wopen ( const char *  filename)

Opens the file for writing.

If ytStdioBuff_prepare() has been already called, and file name is STDOUT_n, the file stream pointer of n-th data to write is return. The written data to the stream is buffered. To actually write them into the standard output, call ytFile_flush().

Parameters
filenamefile name of the file to open, or "STDOUT_n" to specify the file that is output to the standard output. n (≥1) represents the index of the order to write.

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