Project

General

Profile

Feature #1516 ยป readFile.cpp

workAround - Jeremy Minton, 11/09/2012 04:16 AM

 
#include <string>
#include <fstream>
#include <streambuf>
#include <Wt/WString>

Wt::WString readFile(std::string fileName);


Wt::WString readFile(std::string fileName){
std::string value;
std::ifstream file;
file.open(fileName.c_str());
if(!file.is_open())
throw("Error opening template file [" + fileName + "], please check it exists");
value.assign((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
return Wt::WString(value);
}
    (1-1/1)