enums.cpp 2.32 KB
Newer Older
Matteo's avatar
update  
Matteo committed
1
2
3
#include <stdexcept>
#include "enums.h"

Matteo's avatar
Matteo committed
4
std::string sourceToString(Source source) {
Matteo's avatar
update  
Matteo committed
5
6
7
8
9
10
11
12
13
14
15
16
    switch (source) {
        case Audio:
            return "a";
        case Video:
            return "v";
        case Both:
            return "b";
        default:
            throw std::invalid_argument("Invalid Source");
    }
}

Matteo's avatar
Matteo committed
17
Source sourceFromString(std::string source) {
Matteo's avatar
update  
Matteo committed
18
19
20
21
22
23
24
25
26
27
    if (source == "a")
        return Audio;
    else if (source == "v")
        return Video;
    else if (source == "b")
        return Both;
    else
        throw std::invalid_argument("Invalid Source");
}

Matteo's avatar
Matteo committed
28
std::string irregularityTypeToString(IrregularityType type) {
Matteo's avatar
update  
Matteo committed
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
    switch (type) {
        case BRANDS_ON_TAPE:
            return "b";
        case SPLICE:
            return "sp";
        case START_OF_TAPE:
            return "sot";
        case ENDS_OF_TAPE:
            return "eot";
        case DAMAGED_TAPE:
            return "da";
        case DIRT:
            return "di";
        case MARKS:
            return "m";
        case SHADOWS:
            return "s";
        case WOW_AND_FLUTTER:
            return "wf";
        case PLAY_PAUSE_STOP:
            return "pps";
        case SPEED:
            return "ssv";
        case EQUALIZATION:
            return "esv";
        case SPEED_AND_EQUALIZATION:
            return "ssv";
        case BACKWARD:
            return "sb";
        default:
            throw std::invalid_argument("Invalid IrregularityType");
    }
}

Matteo's avatar
Matteo committed
63
IrregularityType irregularityTypeFromString(std::string type) {
Matteo's avatar
update  
Matteo committed
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
    if (type == "b")
        return BRANDS_ON_TAPE;
    else if (type == "sp")
        return SPLICE;
    else if (type == "sot")
        return START_OF_TAPE;
    else if (type == "eot")
        return ENDS_OF_TAPE;
    else if (type == "da")
        return DAMAGED_TAPE;
    else if (type == "di")
        return DIRT;
    else if (type == "m")
        return MARKS;
    else if (type == "s")
        return SHADOWS;
    else if (type == "wf")
        return WOW_AND_FLUTTER;
    else if (type == "pps")
        return PLAY_PAUSE_STOP;
    else if (type == "ssv")
        return SPEED;
    else if (type == "esv")
        return EQUALIZATION;
    else if (type == "ssv")
        return SPEED_AND_EQUALIZATION;
    else if (type == "sb")
        return BACKWARD;
    else
        throw std::invalid_argument("Invalid IrregularityType");
}