Use a std::string rather than a char pointer to convey the file name.
This commit is contained in:
parent
e6638e3892
commit
17228b7078
@ -18,6 +18,8 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "readvector.hpp"
|
||||
|
||||
struct ParserState {
|
||||
int error;
|
||||
};
|
||||
@ -260,21 +262,21 @@ static char *convert_string(double *value, char *str)
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
template <typename T>
|
||||
void read_vector_from_file(const char *fn, std::vector<T>& v)
|
||||
void read_vector_from_file(const std::string& fn, std::vector<T>& v)
|
||||
{
|
||||
FILE *fp = fopen(fn, "r");
|
||||
FILE *fp = fopen(fn.c_str(), "r");
|
||||
struct ParserState s = { 0 };
|
||||
readvector(fp, &s, v);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
|
||||
void read_vector_from_file(const char *fn, std::vector<int>& v)
|
||||
void read_vector_from_file(const std::string& fn, std::vector<int>& v)
|
||||
{
|
||||
read_vector_from_file<int>(fn, v);
|
||||
}
|
||||
|
||||
void read_vector_from_file(const char *fn, std::vector<double>& v)
|
||||
void read_vector_from_file(const std::string& fn, std::vector<double>& v)
|
||||
{
|
||||
read_vector_from_file<double>(fn, v);
|
||||
}
|
||||
|
@ -16,7 +16,9 @@
|
||||
#ifndef READVECTOR_HPP_HEADER
|
||||
#define READVECTOR_HPP_HEADER
|
||||
|
||||
void read_vector_from_file(const char *fn, std::vector<int>& v);
|
||||
void read_vector_from_file(const char *fn, std::vector<double>& v);
|
||||
#include <string>
|
||||
|
||||
void read_vector_from_file(const std::string&, std::vector<int>& v);
|
||||
void read_vector_from_file(const std::string&, std::vector<double>& v);
|
||||
|
||||
#endif /* READVECTOR_HPP_HEADER */
|
||||
|
Loading…
Reference in New Issue
Block a user