about summary refs log tree commit diff
path: root/src/libstore/globals.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-09-19T19·43-0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-09-19T19·43-0400
commit76e88871b21c47c0216e160a5fb926f763ba64fe (patch)
tree815918838ee85fc3c655c55d6aca11c8a36bb502 /src/libstore/globals.cc
parent00092b2d356293a7af9d4d8125a689f90c461591 (diff)
Templatise tokenizeString()
Diffstat (limited to 'src/libstore/globals.cc')
-rw-r--r--src/libstore/globals.cc20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc
index 7e2624bbf712..9b22d54508c1 100644
--- a/src/libstore/globals.cc
+++ b/src/libstore/globals.cc
@@ -65,15 +65,7 @@ void Settings::processEnvironment()
         substituters.push_back(nixLibexecDir + "/nix/substituters/download-using-manifests.pl");
         substituters.push_back(nixLibexecDir + "/nix/substituters/download-from-binary-cache.pl");
     } else
-        substituters = tokenizeString(subs, ":");
-}
-
-
-string & at(Strings & ss, unsigned int n)
-{
-    Strings::iterator i = ss.begin();
-    advance(i, n);
-    return *i;
+        substituters = tokenizeString<Strings>(subs, ":");
 }
 
 
@@ -95,15 +87,15 @@ void Settings::loadConfFile()
         if (hash != string::npos)
             line = string(line, 0, hash);
 
-        Strings tokens = tokenizeString(line);
+        vector<string> tokens = tokenizeString<vector<string> >(line);
         if (tokens.empty()) continue;
 
-        if (tokens.size() < 2 || at(tokens, 1) != "=")
+        if (tokens.size() < 2 || tokens[1] != "=")
             throw Error(format("illegal configuration line `%1%' in `%2%'") % line % settingsFile);
 
-        string name = at(tokens, 0);
+        string name = tokens[0];
 
-        Strings::iterator i = tokens.begin();
+        vector<string>::iterator i = tokens.begin();
         advance(i, 2);
         settings[name] = concatStringsSep(" ", Strings(i, tokens.end())); // FIXME: slow
     };
@@ -170,7 +162,7 @@ void Settings::get(PathSet & res, const string & name)
     SettingsMap::iterator i = settings.find(name);
     if (i == settings.end()) return;
     res.clear();
-    Strings ss = tokenizeString(i->second);
+    Strings ss = tokenizeString<Strings>(i->second);
     res.insert(ss.begin(), ss.end());
 }