]> git.tdb.fi Git - builder.git/blobdiff - source/androidtools.cpp
Replace basic for loops with range-based loops or algorithms
[builder.git] / source / androidtools.cpp
index 118926e1aa3e29dd277d77f138090c65305536b2..5ef2bec5f23b40ec3ff31a58be99d3d1189ece0e 100644 (file)
@@ -53,10 +53,8 @@ AndroidDevKit::AndroidDevKit(Builder &b, const string &type, const FS::Path &def
                return;
 
        builder.get_logger().log("files", format("Traversing %s", platforms_dir.str()));
-       vector<string> platforms = list_filtered(platforms_dir, "^android-[1-9][0-9]*$");
-
-       for(vector<string>::const_iterator i=platforms.begin(); i!=platforms.end(); ++i)
-               supported_api_levels.insert(lexical_cast<unsigned>(i->substr(8)));
+       for(const string &p: list_filtered(platforms_dir, "^android-[1-9][0-9]*$"))
+               supported_api_levels.insert(lexical_cast<unsigned>(p.substr(8)));
 }
 
 void AndroidDevKit::select_api_level(unsigned api)
@@ -84,16 +82,14 @@ void AndroidSdk::find_build_tools_dir()
        }
 
        builder.get_logger().log("files", format("Traversing %s", bt_dir.str()));
-       vector<string> tool_versions = list_files(bt_dir);
-
        string use_tools;
        unsigned latest_version = 0;
-       for(vector<string>::const_iterator i=tool_versions.begin(); i!=tool_versions.end(); ++i)
+       for(const string &v: list_files(bt_dir))
        {
-               unsigned version = parse_version(*i);
+               unsigned version = parse_version(v);
                if(version>latest_version)
                {
-                       use_tools = *i;
+                       use_tools = v;
                        latest_version = version;
                }
        }
@@ -152,13 +148,11 @@ void AndroidNdk::find_toolchain_dir()
 
        builder.get_logger().log("files", format("Traversing %s", toolchains_dir.str()));
        string prefix = architecture.get_cross_prefix()+"-";
-       vector<string> toolchains = list_filtered(toolchains_dir, "^"+prefix);
-
        string use_toolchain;
        unsigned latest_version = 0;
-       for(vector<string>::const_iterator i=toolchains.begin(); i!=toolchains.end(); ++i)
+       for(const string &t: list_filtered(toolchains_dir, "^"+prefix))
        {
-               string version_str = i->substr(prefix.size());
+               string version_str = t.substr(prefix.size());
                string compiler = "gcc";
                if(!isdigit(version_str[0]))
                {
@@ -174,7 +168,7 @@ void AndroidNdk::find_toolchain_dir()
                unsigned version = parse_version(version_str);
                if(version>latest_version)
                {
-                       use_toolchain = *i;
+                       use_toolchain = t;
                        latest_version = version;
                }
        }
@@ -206,8 +200,8 @@ void AndroidNdk::init_api_level(unsigned api)
        FS::Path platform_archs_dir = root/"platforms"/format("android-%d", api);
        builder.get_logger().log("files", format("Traversing %s", platform_archs_dir.str()));
        vector<string> platform_archs = list_filtered(platform_archs_dir, "^arch-");
-       for(vector<string>::iterator i=platform_archs.begin(); i!=platform_archs.end(); ++i)
-               i->erase(0, 5);
+       for(string &a: platform_archs)
+               a.erase(0, 5);
        string use_arch = architecture.best_match(platform_archs);
 
        if(use_arch.empty())
@@ -228,7 +222,7 @@ AndroidTools::AndroidTools(Builder &builder, const Architecture &arch):
        const set<unsigned> &sdk_api_levels = sdk.get_supported_api_levels();
        const set<unsigned> &ndk_api_levels = ndk.get_supported_api_levels();
        unsigned highest_common = 0;
-       for(set<unsigned>::const_reverse_iterator i=sdk_api_levels.rbegin(); (!highest_common && i!=sdk_api_levels.rend()); ++i)
+       for(auto i=sdk_api_levels.rbegin(); (!highest_common && i!=sdk_api_levels.rend()); ++i)
                if(ndk_api_levels.count(*i))
                        highest_common = *i;