]> git.tdb.fi Git - builder.git/blobdiff - source/vssolutiongenerator.cpp
Replace basic for loops with range-based loops or algorithms
[builder.git] / source / vssolutiongenerator.cpp
index 43ed761cb52daa641388ad872596dacaa1ed30ce..0c60689a42094b3777256d1b4da9efa837ea487e 100644 (file)
@@ -33,43 +33,43 @@ VsSolutionGenerator::Worker::Worker(const VsSolutionFile &t):
 
 void VsSolutionGenerator::Worker::main()
 {
-       Builder &builder = target.get_package()->get_builder();
+       const SourcePackage &spkg = *target.get_package();
+       Builder &builder = spkg.get_builder();
 
        IO::BufferedFile out(target.get_path().str(), IO::M_WRITE);
        IO::print(out, "Microsoft Visual Studio Solution File, Format Version 12.00\n");
        IO::print(out, "MinimumVisualStudioVersion = 10.0.40219.1\n");
 
-       const Target::Dependencies &deps = target.get_dependencies();
        vector<const VcxProjectFile *> projects;
-       for(Target::Dependencies::const_iterator i=deps.begin(); i!=deps.end(); ++i)
-               if(const VcxProjectFile *project = dynamic_cast<const VcxProjectFile *>(*i))
+       for(const Target *t: target.get_dependencies())
+               if(const VcxProjectFile *project = dynamic_cast<const VcxProjectFile *>(t))
                        projects.push_back(project);
 
-       for(vector<const VcxProjectFile *>::const_iterator i=projects.begin(); i!=projects.end(); ++i)
+       for(const VcxProjectFile *p: projects)
        {
-               const SourcePackage *pkg = (*i)->get_package();
+               const SourcePackage *pkg = p->get_package();
                IO::print(out, "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"%s\", \"%s\", \"{%s}\"\nEndProject\n",
-                       pkg->get_name(), (*i)->get_path(), (*i)->get_guid());
+                       pkg->get_name(), p->get_path(), p->get_guid());
        }
 
        vector<string> build_types = builder.get_build_types();
-       const char *platforms[] = { "x86", "x64", 0 };
+       const char *platforms[] = { "x86", "x64" };
 
        IO::print(out, "Global\n");
        IO::print(out, "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n");
-       for(vector<string>::const_iterator i=build_types.begin(); i!=build_types.end(); ++i)
-               for(const char **j=platforms; *j; ++j)
-                       IO::print(out, "\t\t%s|%s = %s|%s\n", *i, *j, *i, *j);
+       for(const string &t: build_types)
+               for(const char *p: platforms)
+                       IO::print(out, "\t\t%s|%s = %s|%s\n", t, p, t, p);
        IO::print(out, "\tEndGlobalSection\n");
        IO::print(out, "\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n");
-       for(vector<const VcxProjectFile *>::const_iterator i=projects.begin(); i!=projects.end(); ++i)
-               for(vector<string>::const_iterator j=build_types.begin(); j!=build_types.end(); ++j)
-                       for(const char **k=platforms; *k; ++k)
+       for(const VcxProjectFile *p: projects)
+               for(const string &t: build_types)
+                       for(const char *f: platforms)
                        {
-                               const char *project_platform = (!strcmp(*k, "x86") ? "Win32" : *k);
-                               IO::print(out, "\t\t{%s}.%s|%s.ActiveCfg = %s|%s\n", (*i)->get_guid(), *j, *k, *j, project_platform);
-                               if(i==projects.begin())
-                                       IO::print(out, "\t\t{%s}.%s|%s.Build.0 = %s|%s\n", (*i)->get_guid(), *j, *k, *j, project_platform);
+                               const char *project_platform = (!strcmp(f, "x86") ? "Win32" : f);
+                               IO::print(out, "\t\t{%s}.%s|%s.ActiveCfg = %s|%s\n", p->get_guid(), t, f, t, project_platform);
+                               if(p->get_package()==&spkg)
+                                       IO::print(out, "\t\t{%s}.%s|%s.Build.0 = %s|%s\n", p->get_guid(), t, f, t, project_platform);
                        }
        IO::print(out, "\tEndGlobalSection\n");
        IO::print(out, "EndGlobal\n");