mirror of
https://github.com/arun11299/cpp-subprocess.git
synced 2025-09-09 23:38:20 -04:00
Make all static functions inline
This commit is contained in:
parent
55d9433422
commit
83da3cc629
@ -176,7 +176,7 @@ namespace util
|
|||||||
* Default constructed to ' ' (space).
|
* Default constructed to ' ' (space).
|
||||||
* [out] string: Joined string.
|
* [out] string: Joined string.
|
||||||
*/
|
*/
|
||||||
static
|
static inline
|
||||||
std::string join(const std::vector<std::string>& vec,
|
std::string join(const std::vector<std::string>& vec,
|
||||||
const std::string& sep = " ")
|
const std::string& sep = " ")
|
||||||
{
|
{
|
||||||
@ -196,7 +196,7 @@ namespace util
|
|||||||
* [in] set : If 'true', set FD_CLOEXEC.
|
* [in] set : If 'true', set FD_CLOEXEC.
|
||||||
* If 'false' unset FD_CLOEXEC.
|
* If 'false' unset FD_CLOEXEC.
|
||||||
*/
|
*/
|
||||||
static
|
static inline
|
||||||
void set_clo_on_exec(int fd, bool set = true)
|
void set_clo_on_exec(int fd, bool set = true)
|
||||||
{
|
{
|
||||||
int flags = fcntl(fd, F_GETFD, 0);
|
int flags = fcntl(fd, F_GETFD, 0);
|
||||||
@ -216,7 +216,7 @@ namespace util
|
|||||||
* First element of pair is the read descriptor of pipe.
|
* First element of pair is the read descriptor of pipe.
|
||||||
* Second element is the write descriptor of pipe.
|
* Second element is the write descriptor of pipe.
|
||||||
*/
|
*/
|
||||||
static
|
static inline
|
||||||
std::pair<int, int> pipe_cloexec() throw (OSError)
|
std::pair<int, int> pipe_cloexec() throw (OSError)
|
||||||
{
|
{
|
||||||
int pipe_fds[2];
|
int pipe_fds[2];
|
||||||
@ -243,7 +243,7 @@ namespace util
|
|||||||
* `buf` to `fd`.
|
* `buf` to `fd`.
|
||||||
* [out] int : Number of bytes written or -1 in case of failure.
|
* [out] int : Number of bytes written or -1 in case of failure.
|
||||||
*/
|
*/
|
||||||
static
|
static inline
|
||||||
int write_n(int fd, const char* buf, size_t length)
|
int write_n(int fd, const char* buf, size_t length)
|
||||||
{
|
{
|
||||||
int nwritten = 0;
|
int nwritten = 0;
|
||||||
@ -270,7 +270,7 @@ namespace util
|
|||||||
* will retry to read from `fd`, but only till the EINTR counter
|
* will retry to read from `fd`, but only till the EINTR counter
|
||||||
* reaches 50 after which it will return with whatever data it read.
|
* reaches 50 after which it will return with whatever data it read.
|
||||||
*/
|
*/
|
||||||
static
|
static inline
|
||||||
int read_atmost_n(int fd, char* buf, size_t read_upto)
|
int read_atmost_n(int fd, char* buf, size_t read_upto)
|
||||||
{
|
{
|
||||||
int rbytes = 0;
|
int rbytes = 0;
|
||||||
@ -308,7 +308,7 @@ namespace util
|
|||||||
*/
|
*/
|
||||||
template <typename Buffer>
|
template <typename Buffer>
|
||||||
// Requires Buffer to be of type class Buffer
|
// Requires Buffer to be of type class Buffer
|
||||||
static int read_all(int fd, Buffer& buf)
|
static inline int read_all(int fd, Buffer& buf)
|
||||||
{
|
{
|
||||||
size_t orig_size = buf.size();
|
size_t orig_size = buf.size();
|
||||||
size_t increment = orig_size;
|
size_t increment = orig_size;
|
||||||
@ -349,7 +349,7 @@ namespace util
|
|||||||
* NOTE: This is a blocking call as in, it will loop
|
* NOTE: This is a blocking call as in, it will loop
|
||||||
* till the child is exited.
|
* till the child is exited.
|
||||||
*/
|
*/
|
||||||
static
|
static inline
|
||||||
std::pair<int, int> wait_for_child_exit(int pid)
|
std::pair<int, int> wait_for_child_exit(int pid)
|
||||||
{
|
{
|
||||||
int status = 0;
|
int status = 0;
|
||||||
@ -1543,12 +1543,15 @@ namespace detail
|
|||||||
return Popen(std::forward<F>(farg), std::forward<Args>(args)...).wait();
|
return Popen(std::forward<F>(farg), std::forward<Args>(args)...).wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pipeline_impl(std::vector<Popen>& cmds) { /* EMPTY IMPL */ }
|
static inline void pipeline_impl(std::vector<Popen>& cmds)
|
||||||
|
{
|
||||||
|
/* EMPTY IMPL */
|
||||||
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
static void pipeline_impl(std::vector<Popen>& cmds,
|
static inline void pipeline_impl(std::vector<Popen>& cmds,
|
||||||
const std::string& cmd,
|
const std::string& cmd,
|
||||||
Args&&... args)
|
Args&&... args)
|
||||||
{
|
{
|
||||||
if (cmds.size() == 0) {
|
if (cmds.size() == 0) {
|
||||||
cmds.emplace_back(cmd, output{PIPE}, defer_spawn{true});
|
cmds.emplace_back(cmd, output{PIPE}, defer_spawn{true});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user