@@ -126,28 +126,35 @@ void Project::AddConfigurations(std::initializer_list<std::string> _configuratio
126126const wchar_t * PropertyGroup = L" PropertyGroup" ;
127127
128128
129- void Project::PlatformConfigurationsUpdated (initializer_list<string> items, bool bPlatforms, bool bAdd )
129+ vector<string>& Project::GetConfigurationNames ( )
130130{
131- vector<string>* pConfigurations = &configurations;
132-
133- if (configurations.size () == 0 )
131+ if (configurationNames.size () == 0 )
134132 {
135133 static vector<string> dummyDefaults;
136134
137- if (bPlatforms )
135+ if (dummyDefaults. size () == 0 )
138136 {
139- if (dummyDefaults.size () == 0 )
140- {
141- dummyDefaults.push_back (" Debug" );
142- dummyDefaults.push_back (" Release" );
143- }
144-
145- pConfigurations = &dummyDefaults;
137+ dummyDefaults.push_back (" Debug" );
138+ dummyDefaults.push_back (" Release" );
146139 }
140+
141+ return dummyDefaults;
142+ }
143+
144+ return configurationNames;
145+ }
146+
147+
148+ void Project::PlatformConfigurationsUpdated (initializer_list<string> items, bool bPlatforms, bool bAdd)
149+ {
150+ vector<string>* pConfigurations = &configurationNames;
151+
152+ if (configurationNames.size () == 0 )
153+ {
154+ if (bPlatforms)
155+ pConfigurations = &GetConfigurationNames ();
147156 else
148- {
149157 PlatformConfigurationsUpdated ({ " Debug" , " Release" }, false , false );
150- }
151158 }
152159
153160 vector<string>* listMain = (bPlatforms) ? &platforms : pConfigurations;
@@ -181,7 +188,7 @@ void Project::PlatformConfigurationsUpdated(initializer_list<string> items, bool
181188
182189 for (int j = from; j != to; j += inc)
183190 {
184- int to;
191+ int to; // Index where to insert / from where to remove within single configuration array
185192 string platform;
186193 string configuration;
187194
@@ -198,7 +205,15 @@ void Project::PlatformConfigurationsUpdated(initializer_list<string> items, bool
198205 configuration = name;
199206 }
200207
201- if (bAdd) to--;
208+ wstring platformConfiguration = as_wide (configuration + " |" + platform);
209+
210+ if (bAdd)
211+ {
212+ VCConfiguration conf;
213+ conf.ConfigurationPlatfom = platformConfiguration;
214+ configurations.insert (configurations.begin () + to, conf);
215+ to--; // Xml node backshift - previous node after which to insert.
216+ }
202217
203218 //
204219 // <ItemGroup Label="ProjectConfigurations">
@@ -211,8 +226,6 @@ void Project::PlatformConfigurationsUpdated(initializer_list<string> items, bool
211226 if (to != -1 )
212227 c = itemGroup.select_nodes (ProjectConfiguration)[to].node ();
213228
214- wstring platformConfiguration = as_wide (configuration + " |" + platform);
215-
216229 if (bAdd)
217230 {
218231 xml_node pc;
@@ -265,18 +278,6 @@ void Project::PlatformConfigurationsUpdated(initializer_list<string> items, bool
265278} // PlatformConfigurationsUpdated
266279
267280
268- // Gets list of currently supported configurations, in form "<configuration>|<platform>"
269- vector<string> Project::GetConfigurations ()
270- {
271- vector<string> confs;
272-
273- for (auto p : platforms)
274- for (auto c : configurations)
275- confs.push_back (c + " |" + p);
276-
277- return confs;
278- }
279-
280281// Queries for currently selected toolset, if none is selected, tries to determine from visual studio format version
281282std::string Project::GetToolset ()
282283{
@@ -363,6 +364,26 @@ void Project::AddFile(const wchar_t* file)
363364 files.push_back (p);
364365}
365366
367+ //
368+ // Visits each project configuration, if configurationName & platformName - uses additional filtering, otherwise visits all configurations.
369+ //
370+ void Project::VisitConfigurations (std::function<void (VCConfiguration&)> visitConf, const char* configurationName, const char* platformName)
371+ {
372+ vector<string>& confNames = GetConfigurationNames ();
373+ for (size_t p = 0 ; p < platforms.size (); p++)
374+ for ( size_t c = 0 ; c < confNames.size (); c++)
375+ {
376+ if (configurationName != nullptr && confNames[c] != configurationName)
377+ continue ;
378+
379+ if (platformName != nullptr && platforms[p] != platformName)
380+ continue ;
381+
382+ size_t i = platforms.size () * p + c;
383+ visitConf (configurations[i]);
384+ }
385+ }
386+
366387
367388//
368389// Clears existing project
0 commit comments