-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProfilesFlagsOverride.cpp
More file actions
73 lines (57 loc) · 1.89 KB
/
Copy pathProfilesFlagsOverride.cpp
File metadata and controls
73 lines (57 loc) · 1.89 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
#include "runcpp2/Data/ProfilesFlagsOverride.hpp"
#include "runcpp2/ParseUtil.hpp"
#include "ssLogger/ssLog.hpp"
bool runcpp2::Data::ProfilesFlagsOverride::ParseYAML_Node(ryml::ConstNodeRef& node)
{
INTERNAL_RUNCPP2_SAFE_START();
if(!node.is_map())
{
ssLOG_ERROR("ProfilesFlagsOverrides: Not a map type");
return false;
}
for(int i = 0; i < node.num_children(); ++i)
{
if(!INTERNAL_RUNCPP2_BIT_CONTANTS(node[i].type().type, ryml::NodeType_e::MAP))
{
ssLOG_ERROR("ProfilesFlagsOverrides: FlagsOverrideInfo type requires a map");
return false;
}
ProfileName profile = GetKey(node[i]);
FlagsOverrideInfo flags;
ryml::ConstNodeRef flagsOverrideNode = node[i];
if(!flags.ParseYAML_Node(flagsOverrideNode))
{
ssLOG_ERROR("ProfilesFlagsOverrides: Unable to parse FlagsOverride.");
return false;
}
FlagsOverrides[profile] = flags;
}
return true;
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(false);
}
std::string runcpp2::Data::ProfilesFlagsOverride::ToString(std::string indentation) const
{
std::string out;
if(FlagsOverrides.empty())
return out;
for(auto it = FlagsOverrides.begin(); it != FlagsOverrides.end(); ++it)
{
out += indentation + it->first + ":\n";
out += it->second.ToString(indentation + " ");
}
return out;
}
bool runcpp2::Data::ProfilesFlagsOverride::Equals(const ProfilesFlagsOverride& other) const
{
if(FlagsOverrides.size() != other.FlagsOverrides.size())
return false;
for(const auto& it : FlagsOverrides)
{
if( other.FlagsOverrides.count(it.first) == 0 ||
!other.FlagsOverrides.at(it.first).Equals(it.second))
{
return false;
}
}
return true;
}