cmd_or_exe.hpp 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // Copyright (c) 2016 Klemens D. Morgenstern
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_PROCESS_DETAIL_TRAITS_CMD_OR_EXE_HPP_
  6. #define BOOST_PROCESS_DETAIL_TRAITS_CMD_OR_EXE_HPP_
  7. #include <string>
  8. #include <vector>
  9. #include <type_traits>
  10. #include <initializer_list>
  11. #include <boost/filesystem/path.hpp>
  12. #include <boost/process/detail/traits/decl.hpp>
  13. namespace boost { namespace process { namespace detail {
  14. template<typename Char>
  15. struct cmd_or_exe_tag {};
  16. struct shell_;
  17. template<> struct initializer_tag<const char* > { typedef cmd_or_exe_tag<char> type;};
  18. template<> struct initializer_tag<const wchar_t* > { typedef cmd_or_exe_tag<wchar_t> type;};
  19. template<> struct initializer_tag<char* > { typedef cmd_or_exe_tag<char> type;};
  20. template<> struct initializer_tag<wchar_t* > { typedef cmd_or_exe_tag<wchar_t> type;};
  21. template<std::size_t Size> struct initializer_tag<const char [Size]> { typedef cmd_or_exe_tag<char> type;};
  22. template<std::size_t Size> struct initializer_tag<const wchar_t [Size]> { typedef cmd_or_exe_tag<wchar_t> type;};
  23. template<std::size_t Size> struct initializer_tag<const char (&)[Size]> { typedef cmd_or_exe_tag<char> type;};
  24. template<std::size_t Size> struct initializer_tag<const wchar_t (&)[Size]> { typedef cmd_or_exe_tag<wchar_t> type;};
  25. template<> struct initializer_tag<std::basic_string<char >> { typedef cmd_or_exe_tag<char> type;};
  26. template<> struct initializer_tag<std::basic_string<wchar_t >> { typedef cmd_or_exe_tag<wchar_t> type;};
  27. template<> struct initializer_tag<std::vector<std::basic_string<char >>> { typedef cmd_or_exe_tag<char> type;};
  28. template<> struct initializer_tag<std::vector<std::basic_string<wchar_t >>> { typedef cmd_or_exe_tag<wchar_t> type;};
  29. template<> struct initializer_tag<std::initializer_list<std::basic_string<char >>> { typedef cmd_or_exe_tag<char> type;};
  30. template<> struct initializer_tag<std::initializer_list<std::basic_string<wchar_t >>> { typedef cmd_or_exe_tag<wchar_t> type;};
  31. template<> struct initializer_tag<std::vector<char *>> { typedef cmd_or_exe_tag<char> type;};
  32. template<> struct initializer_tag<std::vector<wchar_t *>> { typedef cmd_or_exe_tag<wchar_t> type;};
  33. template<> struct initializer_tag<std::initializer_list<char *>> { typedef cmd_or_exe_tag<char> type;};
  34. template<> struct initializer_tag<std::initializer_list<wchar_t *>> { typedef cmd_or_exe_tag<wchar_t> type;};
  35. template<> struct initializer_tag<std::initializer_list<const char *>> { typedef cmd_or_exe_tag<char> type;};
  36. template<> struct initializer_tag<std::initializer_list<const wchar_t *>> { typedef cmd_or_exe_tag<wchar_t> type;};
  37. template<> struct initializer_tag<shell_>
  38. {
  39. typedef cmd_or_exe_tag<typename boost::filesystem::path::value_type> type;
  40. };
  41. template<> struct initializer_tag<boost::filesystem::path>
  42. {
  43. typedef cmd_or_exe_tag<typename boost::filesystem::path::value_type> type;
  44. };
  45. template <typename Char>
  46. struct exe_setter_;
  47. template <typename Char, bool Append = false>
  48. struct arg_setter_;
  49. template <typename Char, bool Append>
  50. struct initializer_tag<arg_setter_<Char, Append>> { typedef cmd_or_exe_tag<Char> type;};
  51. template<typename Char> struct initializer_tag<exe_setter_<Char>> { typedef cmd_or_exe_tag<Char> type;};
  52. template<>
  53. struct initializer_builder<cmd_or_exe_tag<char>>;
  54. template<>
  55. struct initializer_builder<cmd_or_exe_tag<wchar_t>>;
  56. }}}
  57. #endif /* BOOST_PROCESS_DETAIL_STRING_TRAITS_HPP_ */