// file : bbot/utility.hxx -*- C++ -*- // license : MIT; see accompanying LICENSE file #ifndef BBOT_UTILITY_HXX #define BBOT_UTILITY_HXX #include // make_shared() #include // to_string(), stoull() #include // move(), forward(), declval(), make_pair() #include // assert() #include // make_move_iterator() #include // * #include #include #include #include #include // icasecmp(), reverse_iterate(), etc #include #include #include namespace bbot { using std::move; using std::forward; using std::declval; using std::make_pair; using std::make_shared; using std::make_move_iterator; using std::to_string; using std::stoull; // // using butl::icasecmp; using butl::sanitize_identifier; using butl::reverse_iterate; using butl::make_guard; using butl::make_exception_guard; using butl::getenv; using butl::setenv; using butl::unsetenv; // // using butl::auto_rmdir; using butl::auto_rmfile; // Process execution. // class tracer; using butl::process; using butl::process_env; using butl::process_exit; using butl::process_error; template void run_io (tracer&, I&& in, O&& out, E&& err, const P&, A&&...); template process_exit::code_type run_io_exit (tracer&, I&& in, O&& out, E&& err, const P&, A&&...); template process run_io_start (tracer&, I&& in, O&& out, E&& err, const process_env&, A&&...); template void run_io_finish (tracer&, process&, const P&, bool fail_hard = true); template process_exit::code_type run_io_finish_exit (tracer&, process&, const P&, bool fail_hard = true); template inline void run (tracer& t, const P& p, A&&... a) { run_io (t, butl::fdopen_null (), 2, 2, p, forward (a)...); } template inline process_exit::code_type run_exit (tracer& t, const P& p, A&&... a) { return run_io_exit ( t, butl::fdopen_null (), 2, 2, p, forward (a)...); } // The curl process wrapper (command line tracing, etc). // class http_curl: public butl::curl { public: template http_curl (tracer&, I&& in, O&& out, method_type, const string& url, A&&... options); }; class tftp_curl: public butl::curl { public: template tftp_curl (tracer&, I&& in, O&& out, method_type, const string& url, A&&... options); }; // Manifest parsing and serialization. // // For parsing, if path is '-', then read from stdin. If path has the .lz4 // extension, then assume the content is compressed. // template T parse_manifest (const path&, const char* what, bool fail_hard = true, bool ignore_unknown = true); template T parse_manifest (istream&, const string& name, const char* what, bool fail_hard = true, bool ignore_unknown = true); template void serialize_manifest (const T&, const path&, const char* what, bool long_lines = false); template void serialize_manifest (const T&, ostream&, const string& name, const char* what, bool fail_hard = true, bool long_lines = false); } #include #endif // BBOT_UTILITY_HXX