Canoe
Comprehensive Atmosphere N' Ocean Engine
fileio.hpp
Go to the documentation of this file.
1 #ifndef SRC_UTILS_FILEIO_HPP_
2 #define SRC_UTILS_FILEIO_HPP_
3 
4 // C/C++
5 #include <iostream>
6 #include <map>
7 #include <string>
8 #include <vector>
9 
10 // canoe
11 #include <configure.hpp>
12 
13 // athena
14 #include <athena/athena.hpp>
15 
17 bool FileExists(std::string fname);
18 
20 bool IsBlankLine(char const* line);
21 bool IsBlankLine(std::string const& line);
22 
24 std::string DecommentFile(std::string fname);
25 
27 int GetNumCols(std::string fname, char c = ' ');
28 
30 int GetNumRows(std::string fname);
31 
33 void replaceChar(char* buf, char c_old, char c_new);
34 
35 template <typename T>
36 class AthenaArray;
37 
38 char* StripLine(char* line);
39 char* NextLine(char* line, int num, FILE* stream);
40 void read_data_table(char const* fname, double** data, int* rows, int* cols);
41 void ReadDataTable(AthenaArray<Real>* data, std::string fname, char c = ' ');
42 
43 using DataVector = std::map<std::string, std::vector<double>>;
44 DataVector read_data_vector(std::string fname);
45 
46 #endif // SRC_UTILS_FILEIO_HPP_
std::string DecommentFile(std::string fname)
decomment a file
Definition: fileio.cpp:30
int GetNumRows(std::string fname)
get number of rows in a data table
Definition: fileio.cpp:62
void ReadDataTable(AthenaArray< Real > *data, std::string fname, char c=' ')
bool FileExists(std::string fname)
test file existance
Definition: fileio.cpp:16
std::map< std::string, std::vector< double > > DataVector
Definition: fileio.hpp:43
char * StripLine(char *line)
Definition: fileio.cpp:77
void replaceChar(char *buf, char c_old, char c_new)
replace a character in a string
Definition: fileio.cpp:71
char * NextLine(char *line, int num, FILE *stream)
Definition: fileio.cpp:93
int GetNumCols(std::string fname, char c=' ')
get number of columns in a data table
Definition: fileio.cpp:50
bool IsBlankLine(char const *line)
test a blank line
Definition: fileio.cpp:21
DataVector read_data_vector(std::string fname)
Definition: fileio.cpp:102
void read_data_table(char const *fname, double **data, int *rows, int *cols)