Functions
simple_io.hpp File Reference

A collection of simple input / output methods. More...

#include <iostream>
#include <fstream>
#include <vector>
#include <string>
Include dependency graph for simple_io.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void write_number (double num, string const &fname, int prec=6)
 Writes a single number to a file. More...
 
void write_vector (vector< double > const &v, string const &fname, int prec=6)
 Writes a list of numbers to a file. More...
 
void write_vector (vector< int > const &v, string const &fname)
 Writes a list of integers to a file. More...
 
double read_number (string const &fname)
 Reads a single number from a file. More...
 
vector< double > read_vector (string const &fname)
 Reads a several numbers from a file. More...
 
int read_int (string const &fname)
 Reads a single integer from a file. More...
 
void binary_write_single_int (int n, ofstream &fh)
 Writes a single integer to a binary file. More...
 
void binary_write_single_double (double d, ofstream &fh)
 Writes a double to a binary file. More...
 
void binary_write_single_size_t (size_t n, ofstream &fh)
 Writes a single size_t to a binary file. More...
 

Detailed Description

A collection of simple input / output methods.

Author
Almog Yalinewich

Definition in file simple_io.hpp.

Function Documentation

◆ binary_write_single_double()

void binary_write_single_double ( double  d,
ofstream &  fh 
)

Writes a double to a binary file.

Parameters
dA double
fhFile handle

Definition at line 80 of file simple_io.cpp.

Here is the caller graph for this function:

◆ binary_write_single_int()

void binary_write_single_int ( int  n,
ofstream &  fh 
)

Writes a single integer to a binary file.

Parameters
nInteger
fhFile handle

Definition at line 75 of file simple_io.cpp.

Here is the caller graph for this function:

◆ binary_write_single_size_t()

void binary_write_single_size_t ( size_t  n,
ofstream &  fh 
)

Writes a single size_t to a binary file.

Parameters
nsize_t
fhFile handle

Definition at line 85 of file simple_io.cpp.

Here is the caller graph for this function:

◆ read_int()

int read_int ( string const &  fname)

Reads a single integer from a file.

Parameters
fnameName of the file
Returns
The integer

Definition at line 65 of file simple_io.cpp.

◆ read_number()

double read_number ( string const &  fname)

Reads a single number from a file.

Parameters
fnameName of the file
Returns
The number

Definition at line 55 of file simple_io.cpp.

◆ read_vector()

vector<double> read_vector ( string const &  fname)

Reads a several numbers from a file.

Parameters
fnameName of the file
Returns
The numbers

Definition at line 43 of file simple_io.cpp.

◆ write_number()

void write_number ( double  num,
string const &  fname,
int  prec = 6 
)

Writes a single number to a file.

Parameters
numNumber
fnameName of the file
precPrecision (number of digits)

Definition at line 5 of file simple_io.cpp.

Here is the caller graph for this function:

◆ write_vector() [1/2]

void write_vector ( vector< double > const &  v,
string const &  fname,
int  prec = 6 
)

Writes a list of numbers to a file.

Parameters
vList of numbers
fnameName of the file
precPrecision

Definition at line 15 of file simple_io.cpp.

Here is the caller graph for this function:

◆ write_vector() [2/2]

void write_vector ( vector< int > const &  v,
string const &  fname 
)

Writes a list of integers to a file.

Parameters
vList of integers
fnameName of file

Definition at line 26 of file simple_io.cpp.