file_io
file_io.h File Reference
#include <string>
#include <vector>
Include dependency graph for file_io.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void read_vector_from_file (const std::string &file_name, std::vector< double > &v)
 
void write_vector_to_file (const std::string &file_name, const std::vector< double > &v)
 
void fill_vector (std::istream &istr, std::vector< double > &v)
 

Function Documentation

◆ fill_vector()

void fill_vector ( std::istream &  istr,
std::vector< double > &  v 
)

Fills the double-vector v with data from an input stream istr until this input stream ends regularily. The vector is cleared and its memory is automatically allocated.

Parameters
[in]istrinput stream
[out]vC++ vector with double values
Warning
An exception is thrown in case of wrong data format or corrupted data.

◆ read_vector_from_file()

void read_vector_from_file ( const std::string &  file_name,
std::vector< double > &  v 
)

This function opens the ASCII-file named file_name and reads the double data into the C++ vector v. If the file file_name does not exist then the code stops with an appropriate message.

Parameters
[in]file_namename of the ASCII-file
[out]vC++ vector with double values

◆ write_vector_to_file()

void write_vector_to_file ( const std::string &  file_name,
const std::vector< double > &  v 
)

This function opens the ASCII-file named file_name and rewrites its with the double data from the C++ vector v. If there are problems in opening/generating file file_name then the code stops with an appropriate message.

Parameters
[in]file_namename of the ASCII-file
[in]vC++ vector with double values