@@ -9,52 +9,55 @@ bool runcpp2::Data::DependencyLinkProperty::ParseYAML_Node(ryml::ConstNodeRef& n
99
1010 if (!node.is_map ())
1111 {
12- ssLOG_ERROR (" DependencySearchProperty : Node is not a Map" );
12+ ssLOG_ERROR (" DependencyLinkProperty : Node is not a Map" );
1313 return false ;
1414 }
1515
16- std::vector<NodeRequirement> requirements =
16+ for ( int i = 0 ; i < node. num_children (); ++i)
1717 {
18- NodeRequirement (" SearchLibraryNames" , ryml::NodeType_e::SEQ, true , false ),
19- NodeRequirement (" SearchDirectories" , ryml::NodeType_e::SEQ, true , false ),
20- NodeRequirement (" ExcludeLibraryNames" , ryml::NodeType_e::SEQ, false , true ),
21- NodeRequirement (" AdditionalLinkOptions" , ryml::NodeType_e::MAP, false , true )
22- };
23-
24- if (!CheckNodeRequirements (node, requirements))
25- {
26- ssLOG_ERROR (" DependencySource: Failed to meet requirements" );
27- return false ;
28- }
29-
30- for (int i = 0 ; i < node[" SearchLibraryNames" ].num_children (); ++i)
31- SearchLibraryNames.push_back (GetValue (node[" SearchLibraryNames" ][i]));
32-
33- for (int i = 0 ; i < node[" SearchDirectories" ].num_children (); ++i)
34- SearchDirectories.push_back (GetValue (node[" SearchDirectories" ][i]));
35-
36- for (int i = 0 ; i < node[" ExcludeLibraryNames" ].num_children (); ++i)
37- ExcludeLibraryNames.push_back (GetValue (node[" ExcludeLibraryNames" ][i]));
38-
39- if (ExistAndHasChild (node, " AdditionalLinkOptions" ))
40- {
41- ryml::ConstNodeRef additionalLinkNode = node[" AdditionalLinkOptions" ];
18+ ProfileName profile = GetKey (node[i]);
19+ ryml::ConstNodeRef profileNode = node[i];
20+
21+ ProfileLinkProperty& property = ProfileProperties[profile];
22+
23+ std::vector<NodeRequirement> requirements =
24+ {
25+ NodeRequirement (" SearchLibraryNames" , ryml::NodeType_e::SEQ, true , false ),
26+ NodeRequirement (" SearchDirectories" , ryml::NodeType_e::SEQ, true , false ),
27+ NodeRequirement (" ExcludeLibraryNames" , ryml::NodeType_e::SEQ, false , true ),
28+ NodeRequirement (" AdditionalLinkOptions" , ryml::NodeType_e::SEQ, false , true )
29+ };
30+
31+ if (!CheckNodeRequirements (profileNode, requirements))
32+ {
33+ ssLOG_ERROR (" DependencyLinkProperty: Failed to meet requirements for profile " <<
34+ profile);
35+ return false ;
36+ }
37+
38+ for (int j = 0 ; j < profileNode[" SearchLibraryNames" ].num_children (); ++j)
39+ property.SearchLibraryNames .push_back (GetValue (profileNode[" SearchLibraryNames" ][j]));
40+
41+ for (int j = 0 ; j < profileNode[" SearchDirectories" ].num_children (); ++j)
42+ property.SearchDirectories .push_back (GetValue (profileNode[" SearchDirectories" ][j]));
4243
43- for ( int i = 0 ; i < additionalLinkNode. num_children (); ++i )
44+ if ( ExistAndHasChild (profileNode, " ExcludeLibraryNames " ) )
4445 {
45- ryml::ConstNodeRef currentLinkNode = additionalLinkNode[i];
46-
47- if (!currentLinkNode.is_seq ())
46+ for (int j = 0 ; j < profileNode[" ExcludeLibraryNames" ].num_children (); ++j)
4847 {
49- ssLOG_ERROR ( " Sequence is expected for AdditionalLinkOptions at " <<
50- GetKey (currentLinkNode ));
48+ property. ExcludeLibraryNames
49+ . push_back ( GetValue (profileNode[ " ExcludeLibraryNames " ][j] ));
5150
52- return false ;
5351 }
54-
55- const std::string currentPlatform = GetKey (currentLinkNode);
56- for (int j = 0 ; j < currentLinkNode.num_children (); ++j)
57- AdditionalLinkOptions[currentPlatform].push_back (GetValue (currentLinkNode[j]));
52+ }
53+
54+ if (ExistAndHasChild (profileNode, " AdditionalLinkOptions" ))
55+ {
56+ for (int j = 0 ; j < profileNode[" AdditionalLinkOptions" ].num_children (); ++j)
57+ {
58+ property.AdditionalLinkOptions
59+ .push_back (GetValue (profileNode[" AdditionalLinkOptions" ][j]));
60+ }
5861 }
5962 }
6063
@@ -66,24 +69,33 @@ bool runcpp2::Data::DependencyLinkProperty::ParseYAML_Node(ryml::ConstNodeRef& n
6669std::string runcpp2::Data::DependencyLinkProperty::ToString (std::string indentation) const
6770{
6871 std::string out;
69- out += indentation + " SearchLibraryName: \n " ;
70-
71- for (int i = 0 ; i < SearchLibraryNames.size (); ++i)
72- out += indentation + " - " + SearchLibraryNames[i] + " \n " ;
73-
74- out += indentation + " SearchDirectories: \n " ;
75-
76- for (int i = 0 ; i < SearchDirectories.size (); ++i)
77- out += indentation + " - " + SearchDirectories[i] + " \n " ;
78-
79- out += indentation + " AdditionalLinkOptions: \n " ;
80-
81- for (auto it = AdditionalLinkOptions.begin (); it != AdditionalLinkOptions.end (); ++it)
72+ for (const std::pair<const ProfileName, ProfileLinkProperty>& profilePair : ProfileProperties)
8273 {
83- out += indentation + " - " + it->first + " :\n " ;
84- for (int i = 0 ; i < it->second .size (); ++i)
85- out += indentation + " - " + it->second [i] + " \n " ;
74+ out += indentation + profilePair.first + " :\n " ;
75+ const ProfileLinkProperty& property = profilePair.second ;
76+
77+ out += indentation + " SearchLibraryNames:\n " ;
78+ for (const std::string& name : property.SearchLibraryNames )
79+ out += indentation + " - " + name + " \n " ;
80+
81+ out += indentation + " SearchDirectories:\n " ;
82+ for (const std::string& dir : property.SearchDirectories )
83+ out += indentation + " - " + dir + " \n " ;
84+
85+ if (!property.ExcludeLibraryNames .empty ())
86+ {
87+ out += indentation + " ExcludeLibraryNames:\n " ;
88+ for (const std::string& name : property.ExcludeLibraryNames )
89+ out += indentation + " - " + name + " \n " ;
90+ }
91+
92+ if (!property.AdditionalLinkOptions .empty ())
93+ {
94+ out += indentation + " AdditionalLinkOptions:\n " ;
95+ for (const std::string& option : property.AdditionalLinkOptions )
96+ out += indentation + " - " + option + " \n " ;
97+ }
8698 }
8799
88100 return out;
89- }
101+ }
0 commit comments