File indexing completed on 2025-01-18 09:50:14
0001
0002
0003
0004
0005
0006 #ifndef BOOST_PROCESS_IO_HPP_
0007 #define BOOST_PROCESS_IO_HPP_
0008
0009 #include <iosfwd>
0010 #include <cstdio>
0011 #include <functional>
0012 #include <utility>
0013 #include <boost/process/detail/config.hpp>
0014 #include <boost/process/pipe.hpp>
0015
0016 #include <future>
0017
0018 #if defined(BOOST_POSIX_API)
0019 #include <boost/process/detail/posix/asio_fwd.hpp>
0020 #include <boost/process/detail/posix/close_in.hpp>
0021 #include <boost/process/detail/posix/close_out.hpp>
0022 #include <boost/process/detail/posix/null_in.hpp>
0023 #include <boost/process/detail/posix/null_out.hpp>
0024 #include <boost/process/detail/posix/file_in.hpp>
0025 #include <boost/process/detail/posix/file_out.hpp>
0026 #include <boost/process/detail/posix/pipe_in.hpp>
0027 #include <boost/process/detail/posix/pipe_out.hpp>
0028 #elif defined(BOOST_WINDOWS_API)
0029 #include <boost/process/detail/windows/asio_fwd.hpp>
0030 #include <boost/process/detail/windows/close_in.hpp>
0031 #include <boost/process/detail/windows/close_out.hpp>
0032 #include <boost/process/detail/windows/null_in.hpp>
0033 #include <boost/process/detail/windows/null_out.hpp>
0034 #include <boost/process/detail/windows/file_in.hpp>
0035 #include <boost/process/detail/windows/file_out.hpp>
0036 #include <boost/process/detail/windows/pipe_in.hpp>
0037 #include <boost/process/detail/windows/pipe_out.hpp>
0038 #endif
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123 namespace boost { namespace process { namespace detail {
0124
0125
0126 template<typename T> using is_streambuf = typename std::is_same<T, boost::asio::streambuf>::type;
0127 template<typename T> using is_const_buffer =
0128 std::integral_constant<bool,
0129 std::is_same< boost::asio::const_buffer, T>::value |
0130 std::is_base_of<boost::asio::const_buffer, T>::value
0131 >;
0132 template<typename T> using is_mutable_buffer =
0133 std::integral_constant<bool,
0134 std::is_same< boost::asio::mutable_buffer, T>::value |
0135 std::is_base_of<boost::asio::mutable_buffer, T>::value
0136 >;
0137
0138
0139 struct null_t {constexpr null_t() = default;};
0140 struct close_t;
0141
0142 template<class>
0143 struct std_in_
0144 {
0145 constexpr std_in_() = default;
0146
0147 api::close_in close() const {return api::close_in(); }
0148 api::close_in operator=(const close_t &) const {return api::close_in();}
0149 api::close_in operator<(const close_t &) const {return api::close_in();}
0150
0151 api::null_in null() const {return api::null_in();}
0152 api::null_in operator=(const null_t &) const {return api::null_in();}
0153 api::null_in operator<(const null_t &) const {return api::null_in();}
0154
0155 api::file_in operator=(const boost::process::filesystem::path &p) const {return p;}
0156 api::file_in operator=(const std::string & p) const {return p;}
0157 api::file_in operator=(const std::wstring &p) const {return p;}
0158 api::file_in operator=(const char * p) const {return p;}
0159 api::file_in operator=(const wchar_t * p) const {return p;}
0160
0161 api::file_in operator<(const boost::process::filesystem::path &p) const {return p;}
0162 api::file_in operator<(const std::string &p) const {return p;}
0163 api::file_in operator<(const std::wstring &p) const {return p;}
0164 api::file_in operator<(const char*p) const {return p;}
0165 api::file_in operator<(const wchar_t * p) const {return p;}
0166
0167 api::file_in operator=(FILE * f) const {return f;}
0168 api::file_in operator<(FILE * f) const {return f;}
0169
0170 template<typename Char, typename Traits> api::pipe_in operator=(basic_pipe<Char, Traits> & p) const {return p;}
0171 template<typename Char, typename Traits> api::pipe_in operator<(basic_pipe<Char, Traits> & p) const {return p;}
0172 template<typename Char, typename Traits> api::pipe_in operator=(basic_opstream<Char, Traits> & p) const {return p.pipe();}
0173 template<typename Char, typename Traits> api::pipe_in operator<(basic_opstream<Char, Traits> & p) const {return p.pipe();}
0174 template<typename Char, typename Traits> api::pipe_in operator=(basic_pstream <Char, Traits> & p) const {return p.pipe();}
0175 template<typename Char, typename Traits> api::pipe_in operator<(basic_pstream <Char, Traits> & p) const {return p.pipe();}
0176
0177 api::async_pipe_in operator=(async_pipe & p) const {return p;}
0178 api::async_pipe_in operator<(async_pipe & p) const {return p;}
0179
0180 template<typename T, typename = typename std::enable_if<
0181 is_const_buffer<T>::value || is_mutable_buffer<T>::value
0182 >::type>
0183 api::async_in_buffer<const T> operator=(const T & buf) const {return buf;}
0184 template<typename T, typename = typename std::enable_if<is_streambuf<T>::value>::type >
0185 api::async_in_buffer<T> operator=(T & buf) const {return buf;}
0186
0187 template<typename T, typename = typename std::enable_if<
0188 is_const_buffer<T>::value || is_mutable_buffer<T>::value
0189 >::type>
0190 api::async_in_buffer<const T> operator<(const T & buf) const {return buf;}
0191 template<typename T, typename = typename std::enable_if<is_streambuf<T>::value>::type >
0192 api::async_in_buffer<T> operator<(T & buf) const {return buf;}
0193
0194 };
0195
0196
0197
0198
0199 template<int p1, int p2 = -1>
0200 struct std_out_
0201 {
0202 constexpr std_out_() = default;
0203
0204 api::close_out<p1,p2> close() const {return api::close_out<p1,p2>(); }
0205 api::close_out<p1,p2> operator=(const close_t &) const {return api::close_out<p1,p2>();}
0206 api::close_out<p1,p2> operator>(const close_t &) const {return api::close_out<p1,p2>();}
0207
0208 api::null_out<p1,p2> null() const {return api::null_out<p1,p2>();}
0209 api::null_out<p1,p2> operator=(const null_t &) const {return api::null_out<p1,p2>();}
0210 api::null_out<p1,p2> operator>(const null_t &) const {return api::null_out<p1,p2>();}
0211
0212 api::file_out<p1,p2> operator=(const boost::process::filesystem::path &p) const {return api::file_out<p1,p2>(p);}
0213 api::file_out<p1,p2> operator=(const std::string &p) const {return api::file_out<p1,p2>(p);}
0214 api::file_out<p1,p2> operator=(const std::wstring &p) const {return api::file_out<p1,p2>(p);}
0215 api::file_out<p1,p2> operator=(const char * p) const {return api::file_out<p1,p2>(p);}
0216 api::file_out<p1,p2> operator=(const wchar_t * p) const {return api::file_out<p1,p2>(p);}
0217
0218 api::file_out<p1,p2> operator>(const boost::process::filesystem::path &p) const {return api::file_out<p1,p2>(p);}
0219 api::file_out<p1,p2> operator>(const std::string &p) const {return api::file_out<p1,p2>(p);}
0220 api::file_out<p1,p2> operator>(const std::wstring &p) const {return api::file_out<p1,p2>(p);}
0221 api::file_out<p1,p2> operator>(const char * p) const {return api::file_out<p1,p2>(p);}
0222 api::file_out<p1,p2> operator>(const wchar_t * p) const {return api::file_out<p1,p2>(p);}
0223
0224 api::file_out<p1,p2> operator=(FILE * f) const {return f;}
0225 api::file_out<p1,p2> operator>(FILE * f) const {return f;}
0226
0227 template<typename Char, typename Traits> api::pipe_out<p1,p2> operator=(basic_pipe<Char, Traits> & p) const {return p;}
0228 template<typename Char, typename Traits> api::pipe_out<p1,p2> operator>(basic_pipe<Char, Traits> & p) const {return p;}
0229 template<typename Char, typename Traits> api::pipe_out<p1,p2> operator=(basic_ipstream<Char, Traits> & p) const {return p.pipe();}
0230 template<typename Char, typename Traits> api::pipe_out<p1,p2> operator>(basic_ipstream<Char, Traits> & p) const {return p.pipe();}
0231 template<typename Char, typename Traits> api::pipe_out<p1,p2> operator=(basic_pstream <Char, Traits> & p) const {return p.pipe();}
0232 template<typename Char, typename Traits> api::pipe_out<p1,p2> operator>(basic_pstream <Char, Traits> & p) const {return p.pipe();}
0233
0234 api::async_pipe_out<p1, p2> operator=(async_pipe & p) const {return p;}
0235 api::async_pipe_out<p1, p2> operator>(async_pipe & p) const {return p;}
0236
0237 api::async_out_buffer<p1, p2, const asio::mutable_buffer> operator=(const asio::mutable_buffer & buf) const {return buf;}
0238 api::async_out_buffer<p1, p2, const asio::mutable_buffers_1> operator=(const asio::mutable_buffers_1 & buf) const {return buf;}
0239 api::async_out_buffer<p1, p2, asio::streambuf> operator=(asio::streambuf & os) const {return os ;}
0240
0241 api::async_out_buffer<p1, p2, const asio::mutable_buffer> operator>(const asio::mutable_buffer & buf) const {return buf;}
0242 api::async_out_buffer<p1, p2, const asio::mutable_buffers_1> operator>(const asio::mutable_buffers_1 & buf) const {return buf;}
0243 api::async_out_buffer<p1, p2, asio::streambuf> operator>(asio::streambuf & os) const {return os ;}
0244
0245 api::async_out_future<p1,p2, std::string> operator=(std::future<std::string> & fut) const { return fut;}
0246 api::async_out_future<p1,p2, std::string> operator>(std::future<std::string> & fut) const { return fut;}
0247 api::async_out_future<p1,p2, std::vector<char>> operator=(std::future<std::vector<char>> & fut) const { return fut;}
0248 api::async_out_future<p1,p2, std::vector<char>> operator>(std::future<std::vector<char>> & fut) const { return fut;}
0249
0250 template<int pin, typename = typename std::enable_if<
0251 (((p1 == 1) && (pin == 2)) ||
0252 ((p1 == 2) && (pin == 1)))
0253 && (p2 == -1)>::type>
0254 constexpr std_out_<1, 2> operator& (const std_out_<pin>&) const
0255 {
0256 return std_out_<1, 2> ();
0257 }
0258
0259 };
0260
0261 struct close_t
0262 {
0263 constexpr close_t() = default;
0264 template<int T, int U>
0265 api::close_out<T,U> operator()(std_out_<T,U>) {return api::close_out<T,U>();}
0266 };
0267
0268
0269
0270 }
0271
0272 constexpr boost::process::detail::close_t close;
0273
0274 constexpr boost::process::detail::null_t null;
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298
0299
0300
0301
0302
0303
0304
0305
0306
0307
0308
0309
0310
0311
0312
0313
0314
0315
0316
0317
0318
0319
0320
0321
0322
0323
0324
0325
0326
0327
0328
0329
0330
0331
0332
0333
0334
0335
0336
0337
0338
0339
0340
0341
0342
0343
0344
0345
0346
0347
0348
0349
0350
0351
0352
0353
0354
0355
0356
0357
0358
0359
0360
0361
0362
0363
0364
0365
0366
0367
0368
0369
0370
0371
0372
0373
0374
0375
0376
0377
0378
0379
0380
0381
0382
0383
0384
0385
0386
0387
0388
0389
0390
0391
0392
0393
0394
0395
0396
0397
0398
0399
0400
0401
0402
0403
0404
0405
0406
0407
0408
0409
0410
0411
0412 constexpr boost::process::detail::std_in_<void> std_in;
0413
0414
0415
0416
0417
0418
0419
0420
0421
0422
0423
0424
0425
0426
0427
0428
0429
0430
0431
0432
0433
0434
0435
0436
0437
0438
0439
0440
0441
0442
0443
0444
0445
0446
0447
0448
0449
0450
0451
0452
0453
0454
0455
0456
0457
0458
0459
0460
0461
0462
0463
0464
0465
0466
0467
0468
0469
0470
0471
0472
0473
0474
0475
0476
0477
0478
0479
0480
0481
0482
0483
0484
0485
0486
0487
0488
0489
0490
0491
0492
0493
0494
0495
0496
0497
0498
0499
0500
0501
0502
0503
0504
0505
0506
0507
0508
0509
0510
0511
0512
0513
0514
0515
0516
0517
0518
0519
0520
0521
0522
0523
0524
0525
0526
0527
0528
0529
0530
0531
0532
0533
0534
0535
0536
0537
0538
0539
0540
0541
0542
0543
0544 constexpr boost::process::detail::std_out_<1> std_out;
0545
0546
0547
0548 constexpr boost::process::detail::std_out_<2> std_err;
0549
0550 }}
0551 #endif