aboutsummaryrefslogtreecommitdiff
path: root/build2/utility
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-04-26 15:52:15 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-04-26 15:53:23 +0200
commit8276cb927bafd338be237adbecf437e70042da99 (patch)
tree49218b58e1f50a65b58674177e6047f1ac9f6831 /build2/utility
parent2fd9d3f177429b20797897360931badedbb0f0ef (diff)
Implement version module
Diffstat (limited to 'build2/utility')
-rw-r--r--build2/utility39
1 files changed, 21 insertions, 18 deletions
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 <typename T>
+ template <typename T, typename F>
T
run (const process_path&,
const char* args[],
- T (*) (string&),
+ F&&,
bool error = true,
bool ignore_exit = false,
sha256* checksum = nullptr);
- template <typename T>
+ template <typename T, typename F>
inline T
run (const char* args[],
- T (*f) (string&),
+ F&& f,
bool error = true,
bool ignore_exit = false,
sha256* checksum = nullptr)
{
- return run<T> (run_search (args[0]), args, f, error, ignore_exit, checksum);
+ return run<T> (
+ run_search (
+ args[0]), args, forward<F> (f), error, ignore_exit, checksum);
}
// run <prog>
//
- template <typename T>
+ template <typename T, typename F>
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<T> (args, f, error, ignore_exit, checksum);
+ return run<T> (args, forward<F> (f), error, ignore_exit, checksum);
}
- template <typename T>
+ template <typename T, typename F>
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<T> (pp, args, f, error, ignore_exit, checksum);
+ return run<T> (pp, args, forward<F> (f), error, ignore_exit, checksum);
}
// run <prog> <arg>
//
- template <typename T>
+ template <typename T, typename F>
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<T> (args, f, error, ignore_exit, checksum);
+ return run<T> (args, forward<F> (f), error, ignore_exit, checksum);
}
- template <typename T>
+ template <typename T, typename F>
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<T> (pp, args, f, error, ignore_exit, checksum);
+ return run<T> (pp, args, forward<F> (f), error, ignore_exit, checksum);
}
// Empty string and path.