Project

General

Profile

Feature #1516 ยป readFile.cpp

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

 
1
#include <string>
2
#include <fstream>
3
#include <streambuf>
4
#include <Wt/WString>
5

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

    
8

    
9
Wt::WString readFile(std::string fileName){
10
	
11
	std::string value;
12
	std::ifstream file;
13
	
14
	file.open(fileName.c_str());
15
	if(!file.is_open())
16
		throw("Error opening template file [" + fileName + "], please check it exists");
17
		
18
	value.assign((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
19
	
20
	return Wt::WString(value);
21
}
    (1-1/1)