From 8276cb927bafd338be237adbecf437e70042da99 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 26 Apr 2017 15:52:15 +0200 Subject: Implement version module --- build2/utility | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'build2/utility') diff --git a/build2/utility b/build2/utility index 5e2fd22..2bcc52c 100644 --- a/build2/utility +++ b/build2/utility @@ -173,80 +173,83 @@ namespace build2 // is false and the program exits with the non-zero status, then an empty T // instance is returned). // - // If checksum is not NULL, then feed it the content of each line. + // If checksum is not NULL, then feed it the content of each tripped line + // (including those that come after the callback returns non-empty object). // - template + template T run (const process_path&, const char* args[], - T (*) (string&), + F&&, bool error = true, bool ignore_exit = false, sha256* checksum = nullptr); - template + template inline T run (const char* args[], - T (*f) (string&), + F&& f, bool error = true, bool ignore_exit = false, sha256* checksum = nullptr) { - return run (run_search (args[0]), args, f, error, ignore_exit, checksum); + return run ( + run_search ( + args[0]), args, forward (f), error, ignore_exit, checksum); } // run // - template + template inline T run (const path& prog, - T (*f) (string&), + F&& f, bool error = true, bool ignore_exit = false, sha256* checksum = nullptr) { const char* args[] = {prog.string ().c_str (), nullptr}; - return run (args, f, error, ignore_exit, checksum); + return run (args, forward (f), error, ignore_exit, checksum); } - template + template inline T run (const process_path& pp, - T (*f) (string&), + F&& f, bool error = true, bool ignore_exit = false, sha256* checksum = nullptr) { const char* args[] = {pp.recall_string (), nullptr}; - return run (pp, args, f, error, ignore_exit, checksum); + return run (pp, args, forward (f), error, ignore_exit, checksum); } // run // - template + template inline T run (const path& prog, const char* arg, - T (*f) (string&), + F&& f, bool error = true, bool ignore_exit = false, sha256* checksum = nullptr) { const char* args[] = {prog.string ().c_str (), arg, nullptr}; - return run (args, f, error, ignore_exit, checksum); + return run (args, forward (f), error, ignore_exit, checksum); } - template + template inline T run (const process_path& pp, const char* arg, - T (*f) (string&), + F&& f, bool error = true, bool ignore_exit = false, sha256* checksum = nullptr) { const char* args[] = {pp.recall_string (), arg, nullptr}; - return run (pp, args, f, error, ignore_exit, checksum); + return run (pp, args, forward (f), error, ignore_exit, checksum); } // Empty string and path. -- cgit v1.1