exe.hpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // Copyright (c) 2006, 2007 Julio M. Merino Vidal
  2. // Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
  3. // Copyright (c) 2009 Boris Schaeling
  4. // Copyright (c) 2010 Felipe Tanus, Boris Schaeling
  5. // Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
  6. // Copyright (c) 2016 Klemens D. Morgenstern
  7. //
  8. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  9. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  10. #ifndef BOOST_PROCESS_EXE_HPP
  11. #define BOOST_PROCESS_EXE_HPP
  12. #include <boost/process/detail/basic_cmd.hpp>
  13. /** \file boost/process/exe.hpp
  14. *
  15. * Header which provides the exe property.
  16. \xmlonly
  17. <programlisting>
  18. namespace boost {
  19. namespace process {
  20. <emphasis>unspecified</emphasis> <globalname alt="boost::process::exe">exe</globalname>;
  21. }
  22. }
  23. </programlisting>
  24. \endxmlonly
  25. */
  26. namespace boost {
  27. namespace filesystem { class path; }
  28. namespace process {
  29. namespace detail {
  30. struct exe_
  31. {
  32. template<typename = void>
  33. inline exe_setter_<typename boost::filesystem::path::value_type> operator()(const boost::filesystem::path & pth) const
  34. {
  35. return exe_setter_<typename boost::filesystem::path::value_type>(pth.native());
  36. }
  37. template<typename = void>
  38. inline exe_setter_<typename boost::filesystem::path::value_type> operator=(const boost::filesystem::path & pth) const
  39. {
  40. return exe_setter_<typename boost::filesystem::path::value_type>(pth.native());
  41. }
  42. template<typename Char>
  43. inline exe_setter_<Char> operator()(const Char *s) const
  44. {
  45. return exe_setter_<Char>(s);
  46. }
  47. template<typename Char>
  48. inline exe_setter_<Char> operator= (const Char *s) const
  49. {
  50. return exe_setter_<Char>(s);
  51. }
  52. template<typename Char>
  53. inline exe_setter_<Char> operator()(const std::basic_string<Char> &s) const
  54. {
  55. return exe_setter_<Char>(s);
  56. }
  57. template<typename Char>
  58. inline exe_setter_<Char> operator= (const std::basic_string<Char> &s) const
  59. {
  60. return exe_setter_<Char>(s);
  61. }
  62. };
  63. }
  64. /** The exe property allows to explicitly set the executable.
  65. The overload form applies when to the first, when several strings are passed to a launching
  66. function.
  67. The following expressions are valid, with `value` being either a C-String or
  68. a `std::basic_string` with `char` or `wchar_t` or a `boost::filesystem::path`.
  69. \code{.cpp}
  70. exe="value";
  71. exe(value);
  72. \endcode
  73. The property can only be used for assignments.
  74. */
  75. constexpr boost::process::detail::exe_ exe{};
  76. }}
  77. #endif