Repository navigation
Expand file tree
/
Copy pathModDependency.cpp
More file actions
56 lines (47 loc) · 1.71 KB
/
Copy pathModDependency.cpp
File metadata and controls
56 lines (47 loc) · 1.71 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
#include "ModDependency.h"
#include <algorithm>
#include <cctype>
#include <iostream>
ModDependency::ModDependency(const std::optional<std::string>& version_id,
const std::optional<std::string>& project_id,
const std::optional<std::string>& file_name,
const std::optional<std::string>& dependency_type)
: version_id_(version_id),
project_id_(project_id),
file_name_(file_name),
dependency_type_(dependency_type) {}
const std::optional<std::string>& ModDependency::getVersionID() const {
return version_id_;
}
const std::optional<std::string>& ModDependency::getProjectID() const {
return project_id_;
}
const std::optional<std::string>& ModDependency::getFileName() const {
return file_name_;
}
const std::optional<std::string>& ModDependency::getDependencyType() const {
return dependency_type_;
}
bool ModDependency::isRequired() const {
if (!dependency_type_ || dependency_type_->empty()) {
return true;
}
std::string normalized = *dependency_type_;
std::transform(normalized.begin(), normalized.end(), normalized.begin(),
[](unsigned char ch) { return static_cast<char>(std::tolower(ch)); });
return normalized == "required";
}
void ModDependency::printDependency() const {
if (getFileName()) {
std::cout << "File name: " << *getFileName() << "\n";
}
if (getVersionID()) {
std::cout << "Version ID: " << *getVersionID() << "\n";
}
if (getProjectID()) {
std::cout << "Project ID: " << *getProjectID() << "\n";
}
if (getDependencyType()) {
std::cout << "Dependency type: " << *getDependencyType() << "\n";
}
}