From 17228b707863a918646e062435a9e5a052635643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Fri, 2 Dec 2011 19:07:35 +0100 Subject: [PATCH] Use a std::string rather than a char pointer to convey the file name. --- readvector.cpp | 10 ++++++---- readvector.hpp | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/readvector.cpp b/readvector.cpp index aae5869d..7b5adc5a 100644 --- a/readvector.cpp +++ b/readvector.cpp @@ -18,6 +18,8 @@ #include +#include "readvector.hpp" + struct ParserState { int error; }; @@ -260,21 +262,21 @@ static char *convert_string(double *value, char *str) /* ------------------------------------------------------------------ */ template -void read_vector_from_file(const char *fn, std::vector& v) +void read_vector_from_file(const std::string& fn, std::vector& 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& v) +void read_vector_from_file(const std::string& fn, std::vector& v) { read_vector_from_file(fn, v); } -void read_vector_from_file(const char *fn, std::vector& v) +void read_vector_from_file(const std::string& fn, std::vector& v) { read_vector_from_file(fn, v); } diff --git a/readvector.hpp b/readvector.hpp index 5f96fcca..04cdb977 100644 --- a/readvector.hpp +++ b/readvector.hpp @@ -16,7 +16,9 @@ #ifndef READVECTOR_HPP_HEADER #define READVECTOR_HPP_HEADER -void read_vector_from_file(const char *fn, std::vector& v); -void read_vector_from_file(const char *fn, std::vector& v); +#include + +void read_vector_from_file(const std::string&, std::vector& v); +void read_vector_from_file(const std::string&, std::vector& v); #endif /* READVECTOR_HPP_HEADER */