A collection of simple input / output methods. More...
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
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... | |
A collection of simple input / output methods.
Definition in file simple_io.hpp.
void binary_write_single_double | ( | double | d, |
ofstream & | fh | ||
) |
Writes a double to a binary file.
d | A double |
fh | File handle |
Definition at line 80 of file simple_io.cpp.
void binary_write_single_int | ( | int | n, |
ofstream & | fh | ||
) |
Writes a single integer to a binary file.
n | Integer |
fh | File handle |
Definition at line 75 of file simple_io.cpp.
void binary_write_single_size_t | ( | size_t | n, |
ofstream & | fh | ||
) |
Writes a single size_t to a binary file.
n | size_t |
fh | File handle |
Definition at line 85 of file simple_io.cpp.
int read_int | ( | string const & | fname | ) |
Reads a single integer from a file.
fname | Name of the file |
Definition at line 65 of file simple_io.cpp.
double read_number | ( | string const & | fname | ) |
Reads a single number from a file.
fname | Name of the file |
Definition at line 55 of file simple_io.cpp.
vector<double> read_vector | ( | string const & | fname | ) |
Reads a several numbers from a file.
fname | Name of the file |
Definition at line 43 of file simple_io.cpp.
void write_number | ( | double | num, |
string const & | fname, | ||
int | prec = 6 |
||
) |
Writes a single number to a file.
num | Number |
fname | Name of the file |
prec | Precision (number of digits) |
Definition at line 5 of file simple_io.cpp.
void write_vector | ( | vector< double > const & | v, |
string const & | fname, | ||
int | prec = 6 |
||
) |
Writes a list of numbers to a file.
v | List of numbers |
fname | Name of the file |
prec | Precision |
Definition at line 15 of file simple_io.cpp.
void write_vector | ( | vector< int > const & | v, |
string const & | fname | ||
) |
Writes a list of integers to a file.
v | List of integers |
fname | Name of file |
Definition at line 26 of file simple_io.cpp.