-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasescorechecker.cpp
More file actions
82 lines (80 loc) · 2.09 KB
/
basescorechecker.cpp
File metadata and controls
82 lines (80 loc) · 2.09 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*/////
// 2018
// BaseScoreChecker holds the basic information for all issues to be fixed
// This class is later used in derived classes
//
/////*/
#include "basescorechecker.h"
//#include "pathexistscorechecker.h"
BaseScoreChecker::BaseScoreChecker()
{
this->state=false;
this->description="Base score checker";
this->instructions="Instructions/Question";
}
BaseScoreChecker::BaseScoreChecker(std::string description)
{
this->state=false;
this->description=description;
}
void BaseScoreChecker::checkState(){
std::cerr << "Warning: Please use a derived class instead of BaseScoreChecker.\n";
}
bool BaseScoreChecker::getState()
{
return this->state;
}
std::string BaseScoreChecker::getDescription()
{
return this->description;
}
std::string BaseScoreChecker::getInstructions(){
return this->instructions;
}
std::string BaseScoreChecker::getCheckerType()
{
return this->checkerType;
}
int BaseScoreChecker::getPoints()
{
return this->points;
}
void BaseScoreChecker::setDescription(std::string newDescription)
{
this->description=newDescription;
}
void BaseScoreChecker::setInstructions(std::string newInstructions){
this->instructions = newInstructions;
}
void BaseScoreChecker::setPoints(int newPoints) //has built in max of 100 and min of -100
{
if (newPoints>10)
{
this->points=100;
}
else if (newPoints<-10)
{
this->points=-100;
}else
{
this->points=newPoints;
}
}
//used as a boost process replacement for Windows - from https://stackoverflow.com/questions/478898/how-to-execute-a-command-and-get-output-of-command-within-c-using-posix
#include <cstdio>
#include <iostream>
#include <memory>
#include <stdexcept>
#include <string>
#include <array>
std::string exec(const char* cmd) {
std::array<char, 128> buffer;
std::string result;
std::shared_ptr<FILE> pipe(popen(cmd, "r"), pclose);
if (!pipe) throw std::runtime_error("popen() failed!");
while (!feof(pipe.get())) {
if (fgets(buffer.data(), 128, pipe.get()) != nullptr)
result += buffer.data();
}
return result;
}