From db0edaafe15831ba6fa9c2109da37942506c62b1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 23 Jan 2016 11:14:05 +0200 Subject: Cleanup absolute/relative path diagnostics by introducing stream verbosity --- build2/context | 49 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 8 deletions(-) (limited to 'build2/context') diff --git a/build2/context b/build2/context index 7bae8c3..e2732db 100644 --- a/build2/context +++ b/build2/context @@ -23,7 +23,6 @@ namespace build2 extern dir_path work; extern dir_path home; - extern string_pool path_pool; extern string_pool extension_pool; extern string_pool project_name_pool; @@ -146,18 +145,52 @@ namespace build2 diag_relative (const dir_path&, bool current = true); // Action phrases, e.g., "configure update exe{foo}", "updating exe{foo}", - // and "updating exe{foo} is configured". + // and "updating exe{foo} is configured". Use like this: + // + // info << "while " << diag_doing (a, t); // class target; - std::string - diag_do (const action&, const target&); + struct diag_phrase + { + const action& a; + const target& t; + void (*f) (ostream&, const action&, const target&); + }; - std::string - diag_doing (const action&, const target&); + inline ostream& + operator<< (ostream& os, const diag_phrase& p) + { + p.f (os, p.a, p.t); + return os; + } - std::string - diag_done (const action&, const target&); + void + diag_do (ostream&, const action&, const target&); + + inline diag_phrase + diag_do (const action& a, const target& t) + { + return diag_phrase {a, t, &diag_do}; + } + + void + diag_doing (ostream&, const action&, const target&); + + inline diag_phrase + diag_doing (const action& a, const target& t) + { + return diag_phrase {a, t, &diag_doing}; + } + + void + diag_done (ostream&, const action&, const target&); + + inline diag_phrase + diag_done (const action& a, const target& t) + { + return diag_phrase {a, t, &diag_done}; + } } #include -- cgit v1.1