-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValidator.cpp
More file actions
66 lines (61 loc) · 1.39 KB
/
Copy pathValidator.cpp
File metadata and controls
66 lines (61 loc) · 1.39 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
#include "Validator.h"
#include <iostream>
#include <fstream>
#include <windows.h>
#include <string>
using namespace std;
Validator::Validator() {
}
Validator::~Validator() {
}
bool Validator::validateFileAndOpening(std::string fileLocation, std::ifstream* stream) {
if (fileLocation.size() <= 4) {
cout << "Wrong input!" << endl;
return false;
}
else if (fileLocation.substr(fileLocation.size() - 4, fileLocation.size()) != ".mid") {
cout << "Your file has extension of the wrong type!" << endl;
return false;
}
else if (!stream->is_open()) {
cout << "Failed to open your file!" << endl;
return false;
}
return true;
}
bool Validator::validateMidiOutOpen(MMRESULT err) {
if (err != MMSYSERR_NOERROR) {
cout << "Error ";
switch (err) {
case MMSYSERR_BADDEVICEID:
cout << "device ID out of range";
break;
case MMSYSERR_NOTENABLED:
cout << "driver failed enable";
break;
case MMSYSERR_ALLOCATED:
cout << "device already allocated";
break;
case MMSYSERR_INVALHANDLE:
cout << "device handle is invalid";
break;
default:
cout << "with code " + to_string(err);
break;
}
cout << " while opening MIDI output!" << endl;
return false;
}
else {
return true;
}
}
bool Validator::validateMidiFormat(int format) {
if (format == 0 || format == 1) {
return true;
}
else {
cout << "SMPTE time format isn't supported yet." << endl;
return false;
}
}