Added debug code

This commit is contained in:
arunmu 2016-03-17 11:51:11 +05:30
parent 6817d92533
commit 169bde5c08
3 changed files with 23 additions and 5 deletions

BIN
main

Binary file not shown.

View File

@ -9,8 +9,10 @@ int main() {
auto buf = check_output({"echo", "\"It works!\""}); auto buf = check_output({"echo", "\"It works!\""});
std::cout << buf.buf.data() << " :: " << buf.length << std::endl; std::cout << buf.buf.data() << " :: " << buf.length << std::endl;
auto buf2 = check_output("cat subprocess.hpp"); buf = check_output("cat subprocess.hpp");
std::cout << buf2.buf.data() << " :: " << buf2.length << std::endl; //std::cout << buf2.buf.data() << " :: " << buf2.length << std::endl;
//
return 0; return 0;
} }

View File

@ -279,6 +279,22 @@ public:
Buffer(size_t cap) { buf.resize(cap); } Buffer(size_t cap) { buf.resize(cap); }
void add_cap(size_t cap) { buf.resize(cap); } void add_cap(size_t cap) { buf.resize(cap); }
#if 0
Buffer(const Buffer& other):
buf(other.buf),
length(other.length)
{
std::cout << "COPY" << std::endl;
}
Buffer(Buffer&& other):
buf(std::move(other.buf)),
length(other.length)
{
std::cout << "MOVE" << std::endl;
}
#endif
public: public:
std::vector<char> buf; std::vector<char> buf;
size_t length = 0; size_t length = 0;
@ -1007,7 +1023,7 @@ namespace detail
if (retcode) { if (retcode) {
throw CalledProcessError("Command failed"); throw CalledProcessError("Command failed");
} }
return (res.first); return std::move(res.first);
} }
} }
@ -1021,13 +1037,13 @@ int call(Args&&... args)
template <typename... Args> template <typename... Args>
OutBuffer check_output(std::initializer_list<const char*> plist, Args&&... args) OutBuffer check_output(std::initializer_list<const char*> plist, Args&&... args)
{ {
return detail::check_output_impl(plist, std::forward<Args>(args)...); return (detail::check_output_impl(plist, std::forward<Args>(args)...));
} }
template <typename... Args> template <typename... Args>
OutBuffer check_output(const std::string& arg, Args&&... args) OutBuffer check_output(const std::string& arg, Args&&... args)
{ {
return detail::check_output_impl(arg, std::forward<Args>(args)...); return (detail::check_output_impl(arg, std::forward<Args>(args)...));
} }
}; };