-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDefaultController.cpp
More file actions
50 lines (37 loc) · 1.01 KB
/
DefaultController.cpp
File metadata and controls
50 lines (37 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "DefaultController.h"
#include <iostream>
#include <fstream>
#include <sstream>
using namespace quantserver ;
#define FILEBASEPATH "C:\\workspaces\\cppFinance\\www\\"
std::string convertToFilePath(const std::string& path) ;
DefaultController::DefaultController(void)
{
}
DefaultController::~DefaultController(void)
{
}
//Grabs and return the contents of a file
ControllerReturnType DefaultController::operator() (const std::string& path , ModelMap& modelMap)
{
std::string fpath = convertToFilePath(path) ;
std::ifstream fileToRead(fpath) ;
if(fileToRead.good())
{
std::stringstream payload ;
//fileToRead.
payload << fileToRead.rdbuf() ;
return ControllerReturnType(STATUS_OK , payload.str() ) ;
}
else
{
return ControllerReturnType(STATUS_NOT_FOUND , "File Not Found") ;
}
}
std::string convertToFilePath(const std::string& path)
{
int lastOfPath = path.find_last_of("/") ;
std::string filename = path.substr(lastOfPath) ;
std::string toRt = FILEBASEPATH ;
return toRt.append(filename) ;
}