aboutsummaryrefslogtreecommitdiff
path: root/butl/process
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-04-18 10:40:18 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-04-18 10:40:18 +0200
commited93e07b1b7a9e0ba99609a9223e43247ff4224e (patch)
treeaa203bdab5a5fc4f5fd8af16baf6903a7ee3dde0 /butl/process
parent4408607c51a7c6e293adae41403b21d4a2c9a429 (diff)
Implement curl process
Diffstat (limited to 'butl/process')
-rw-r--r--butl/process69
1 files changed, 65 insertions, 4 deletions
diff --git a/butl/process b/butl/process
index c138edc..282a994 100644
--- a/butl/process
+++ b/butl/process
@@ -9,6 +9,7 @@
# include <sys/types.h> // pid_t
#endif
+#include <vector>
#include <iosfwd>
#include <cassert>
#include <cstdint> // uint32_t
@@ -17,7 +18,9 @@
#include <butl/path>
#include <butl/export>
#include <butl/optional>
-#include <butl/fdstream> // auto_fd, fdpipe
+#include <butl/fdstream> // auto_fd, fdpipe
+#include <butl/vector-view>
+#include <butl/small-vector>
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 <typename I,
typename O,
@@ -480,6 +482,8 @@ namespace butl
return p.string ().c_str ();
}
+ // char[N]
+ //
inline const char*
process_arg_as (const char* s, std::string&) {return s;}
@@ -490,6 +494,63 @@ namespace butl
template <std::size_t N>
inline const char*
process_arg_as (const char (&s)[N], std::string&) {return s;}
+
+ template <typename V, typename T>
+ 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 <typename V>
+ inline void
+ process_args_as (V& v, const std::vector<std::string>& vs, std::string&)
+ {
+ for (const std::string& s: vs)
+ v.push_back (s.c_str ());
+ }
+
+ template <typename V, std::size_t N>
+ inline void
+ process_args_as (V& v, const small_vector<std::string, N>& vs, std::string&)
+ {
+ for (const std::string& s: vs)
+ v.push_back (s.c_str ());
+ }
+
+ template <typename V>
+ inline void
+ process_args_as (V& v, const vector_view<std::string>& vs, std::string&)
+ {
+ for (const std::string& s: vs)
+ v.push_back (s.c_str ());
+ }
+
+ template <typename V>
+ inline void
+ process_args_as (V& v, const std::vector<const char*>& vs, std::string&)
+ {
+ for (const char* s: vs)
+ v.push_back (s);
+ }
+
+ template <typename V, std::size_t N>
+ inline void
+ process_args_as (V& v, const small_vector<const char*, N>& vs, std::string&)
+ {
+ for (const char* s: vs)
+ v.push_back (s);
+ }
+
+ template <typename V>
+ inline void
+ process_args_as (V& v, const vector_view<const char*>& vs, std::string&)
+ {
+ for (const char* s: vs)
+ v.push_back (s);
+ }
}
#include <butl/process.ixx>