From fbc39b856dc7b10e4d5dacb90741ea85f22da8bc Mon Sep 17 00:00:00 2001 From: thecharlesblake Date: Tue, 14 Nov 2017 01:50:18 +0000 Subject: Add util class, with read file to string method --- src/main/util/util.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/main/util/util.cpp') diff --git a/src/main/util/util.cpp b/src/main/util/util.cpp index ed46d3b..46038aa 100644 --- a/src/main/util/util.cpp +++ b/src/main/util/util.cpp @@ -2,4 +2,22 @@ // Created by thecharlesblake on 11/13/17. // +#include +#include + #include "util.h" + +using namespace std; +using namespace boost; + +const optional util::read_file(const string& filename) { + ifstream ifstr(filename); + stringstream buf; + buf << ifstr.rdbuf(); + + if (ifstr.fail()) { + return none; + } else { + return buf.str(); + } +} -- cgit v1.2.1