-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDependencyLinkProperty.cpp
More file actions
136 lines (112 loc) · 4.94 KB
/
Copy pathDependencyLinkProperty.cpp
File metadata and controls
136 lines (112 loc) · 4.94 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#include "runcpp2/Data/DependencyLinkProperty.hpp"
#include "runcpp2/Data/ParseCommon.hpp"
#include "runcpp2/ParseUtil.hpp"
#include "ssLogger/ssLog.hpp"
bool runcpp2::Data::DependencyLinkProperty::ParseYAML_Node(ryml::ConstNodeRef& node)
{
INTERNAL_RUNCPP2_SAFE_START();
if(!node.is_map())
{
ssLOG_ERROR("DependencyLinkProperty: Node is not a Map");
return false;
}
for(int i = 0; i < node.num_children(); ++i)
{
ProfileName profile = GetKey(node[i]);
ryml::ConstNodeRef profileNode = node[i];
ProfileLinkProperty& property = ProfileProperties[profile];
std::vector<NodeRequirement> requirements =
{
NodeRequirement("SearchLibraryNames", ryml::NodeType_e::SEQ, true, false),
NodeRequirement("SearchDirectories", ryml::NodeType_e::SEQ, true, false),
NodeRequirement("ExcludeLibraryNames", ryml::NodeType_e::SEQ, false, true),
NodeRequirement("AdditionalLinkOptions", ryml::NodeType_e::SEQ, false, true)
};
if(!CheckNodeRequirements(profileNode, requirements))
{
ssLOG_ERROR("DependencyLinkProperty: Failed to meet requirements for profile " <<
profile);
return false;
}
for(int j = 0; j < profileNode["SearchLibraryNames"].num_children(); ++j)
property.SearchLibraryNames.push_back(GetValue(profileNode["SearchLibraryNames"][j]));
for(int j = 0; j < profileNode["SearchDirectories"].num_children(); ++j)
property.SearchDirectories.push_back(GetValue(profileNode["SearchDirectories"][j]));
if(ExistAndHasChild(profileNode, "ExcludeLibraryNames"))
{
for(int j = 0; j < profileNode["ExcludeLibraryNames"].num_children(); ++j)
{
property.ExcludeLibraryNames
.push_back(GetValue(profileNode["ExcludeLibraryNames"][j]));
}
}
if(ExistAndHasChild(profileNode, "AdditionalLinkOptions"))
{
for(int j = 0; j < profileNode["AdditionalLinkOptions"].num_children(); ++j)
{
property.AdditionalLinkOptions
.push_back(GetValue(profileNode["AdditionalLinkOptions"][j]));
}
}
}
return true;
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(false);
}
std::string runcpp2::Data::DependencyLinkProperty::ToString(std::string indentation) const
{
std::string out;
for(const std::pair<const ProfileName, ProfileLinkProperty>& profilePair : ProfileProperties)
{
out += indentation + profilePair.first + ":\n";
const ProfileLinkProperty& property = profilePair.second;
if(property.SearchLibraryNames.empty())
out += indentation + " SearchLibraryNames: []\n";
else
{
out += indentation + " SearchLibraryNames:\n";
for(const std::string& name : property.SearchLibraryNames)
out += indentation + " - " + GetEscapedYAMLString(name) + "\n";
}
if(property.SearchDirectories.empty())
out += indentation + " SearchDirectories: []\n";
else
{
out += indentation + " SearchDirectories:\n";
for(const std::string& dir : property.SearchDirectories)
out += indentation + " - " + GetEscapedYAMLString(dir) + "\n";
}
if(!property.ExcludeLibraryNames.empty())
{
out += indentation + " ExcludeLibraryNames:\n";
for(const std::string& name : property.ExcludeLibraryNames)
out += indentation + " - " + GetEscapedYAMLString(name) + "\n";
}
if(!property.AdditionalLinkOptions.empty())
{
out += indentation + " AdditionalLinkOptions:\n";
for(const std::string& option : property.AdditionalLinkOptions)
out += indentation + " - " + GetEscapedYAMLString(option) + "\n";
}
}
return out;
}
bool runcpp2::Data::DependencyLinkProperty::Equals(const DependencyLinkProperty& other) const
{
if(ProfileProperties.size() != other.ProfileProperties.size())
return false;
for(const auto& it : ProfileProperties)
{
if(other.ProfileProperties.count(it.first) == 0)
return false;
const ProfileLinkProperty& otherProperty = other.ProfileProperties.at(it.first);
const ProfileLinkProperty& property = it.second;
if( property.SearchLibraryNames != otherProperty.SearchLibraryNames ||
property.SearchDirectories != otherProperty.SearchDirectories ||
property.ExcludeLibraryNames != otherProperty.ExcludeLibraryNames ||
property.AdditionalLinkOptions != otherProperty.AdditionalLinkOptions)
{
return false;
}
}
return true;
}