-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.cpp
38 lines (32 loc) · 918 Bytes
/
utils.cpp
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
#include "project.h"
#include <cctype>
#include <sstream>
#include <fstream>
#include <stdexcept>
namespace Utils{
std::string readFile(const char* fileName){
std::stringstream ss;
std::ifstream file(fileName,std::ios::binary);
ss<<file.rdbuf(); // read stream buffer
if(ss.str().empty()){
throw std::invalid_argument("File Error: Job description file cannot be found or an empty file!");
}
return ss.str();
}
bool isSpace(char ch){
if(isspace(ch) && ch!='\n'){
return true;
}
return false;
}
bool arg_check(char* str){
try{
std::string tmp(str);
int a = std::stoi(tmp);
}
catch (std::exception& e){
throw std::invalid_argument("Arguement Error: Argument is NaN or an overbound number!");
}
return true;
}
}