From ed93e07b1b7a9e0ba99609a9223e43247ff4224e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 18 Apr 2017 10:40:18 +0200 Subject: Implement curl process --- butl/process | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 4 deletions(-) (limited to 'butl/process') diff --git a/butl/process b/butl/process index c138edc..282a994 100644 --- a/butl/process +++ b/butl/process @@ -9,6 +9,7 @@ # include // pid_t #endif +#include #include #include #include // uint32_t @@ -17,7 +18,9 @@ #include #include #include -#include // auto_fd, fdpipe +#include // auto_fd, fdpipe +#include +#include namespace butl { @@ -389,9 +392,8 @@ namespace butl // // The A arguments can be anything convertible to const char* via the // overloaded process_arg_as() (see below). Out of the box you can use const - // char*, std::string, path/dir_path, and numeric types. - // - // + // char*, std::string, path/dir_path, (as well as [small_]vector[_view] of + // these), and numeric types. // template inline const char* process_arg_as (const char (&s)[N], std::string&) {return s;} + + template + inline void + process_args_as (V& v, const T& x, std::string& storage) + { + v.push_back (process_arg_as (x, storage)); + } + + // [small_]vector[_view]<> + // + template + inline void + process_args_as (V& v, const std::vector& vs, std::string&) + { + for (const std::string& s: vs) + v.push_back (s.c_str ()); + } + + template + inline void + process_args_as (V& v, const small_vector& vs, std::string&) + { + for (const std::string& s: vs) + v.push_back (s.c_str ()); + } + + template + inline void + process_args_as (V& v, const vector_view& vs, std::string&) + { + for (const std::string& s: vs) + v.push_back (s.c_str ()); + } + + template + inline void + process_args_as (V& v, const std::vector& vs, std::string&) + { + for (const char* s: vs) + v.push_back (s); + } + + template + inline void + process_args_as (V& v, const small_vector& vs, std::string&) + { + for (const char* s: vs) + v.push_back (s); + } + + template + inline void + process_args_as (V& v, const vector_view& vs, std::string&) + { + for (const char* s: vs) + v.push_back (s); + } } #include -- cgit v1.1