summaryrefslogtreecommitdiff
path: root/boost/process/detail/traits
diff options
context:
space:
mode:
Diffstat (limited to 'boost/process/detail/traits')
-rw-r--r--boost/process/detail/traits/async.hpp34
-rw-r--r--boost/process/detail/traits/cmd_or_exe.hpp85
-rw-r--r--boost/process/detail/traits/decl.hpp76
-rw-r--r--boost/process/detail/traits/env.hpp53
-rw-r--r--boost/process/detail/traits/error.hpp27
-rw-r--r--boost/process/detail/traits/group.hpp37
-rw-r--r--boost/process/detail/traits/wchar_t.hpp274
7 files changed, 586 insertions, 0 deletions
diff --git a/boost/process/detail/traits/async.hpp b/boost/process/detail/traits/async.hpp
new file mode 100644
index 0000000000..da7ed79aae
--- /dev/null
+++ b/boost/process/detail/traits/async.hpp
@@ -0,0 +1,34 @@
+// Copyright (c) 2016 Klemens D. Morgenstern
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_PROCESS_DETAIL_TRAITS_ASYNC_HPP_
+#define BOOST_PROCESS_DETAIL_TRAITS_ASYNC_HPP_
+
+#include <boost/process/detail/config.hpp>
+#include <boost/process/detail/traits/decl.hpp>
+
+namespace boost { namespace asio {
+
+class io_service;
+}}
+
+namespace boost { namespace process { namespace detail {
+
+struct async_tag {};
+
+template<>
+struct initializer_builder<async_tag>;
+
+template<> struct initializer_tag<::boost::asio::io_service> { typedef async_tag type;};
+
+
+
+
+}}}
+
+
+
+#endif /* BOOST_PROCESS_DETAIL_HANDLER_HPP_ */
diff --git a/boost/process/detail/traits/cmd_or_exe.hpp b/boost/process/detail/traits/cmd_or_exe.hpp
new file mode 100644
index 0000000000..f6a8ae7cd3
--- /dev/null
+++ b/boost/process/detail/traits/cmd_or_exe.hpp
@@ -0,0 +1,85 @@
+// Copyright (c) 2016 Klemens D. Morgenstern
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_PROCESS_DETAIL_TRAITS_CMD_OR_EXE_HPP_
+#define BOOST_PROCESS_DETAIL_TRAITS_CMD_OR_EXE_HPP_
+
+#include <string>
+#include <vector>
+#include <type_traits>
+#include <initializer_list>
+#include <boost/filesystem/path.hpp>
+#include <boost/process/detail/traits/decl.hpp>
+namespace boost { namespace process { namespace detail {
+
+template<typename Char>
+struct cmd_or_exe_tag {};
+
+struct shell_;
+
+
+template<> struct initializer_tag<const char* > { typedef cmd_or_exe_tag<char> type;};
+template<> struct initializer_tag<const wchar_t* > { typedef cmd_or_exe_tag<wchar_t> type;};
+
+template<> struct initializer_tag<char* > { typedef cmd_or_exe_tag<char> type;};
+template<> struct initializer_tag<wchar_t* > { typedef cmd_or_exe_tag<wchar_t> type;};
+
+template<std::size_t Size> struct initializer_tag<const char [Size]> { typedef cmd_or_exe_tag<char> type;};
+template<std::size_t Size> struct initializer_tag<const wchar_t [Size]> { typedef cmd_or_exe_tag<wchar_t> type;};
+
+template<std::size_t Size> struct initializer_tag<const char (&)[Size]> { typedef cmd_or_exe_tag<char> type;};
+template<std::size_t Size> struct initializer_tag<const wchar_t (&)[Size]> { typedef cmd_or_exe_tag<wchar_t> type;};
+
+template<> struct initializer_tag<std::basic_string<char >> { typedef cmd_or_exe_tag<char> type;};
+template<> struct initializer_tag<std::basic_string<wchar_t >> { typedef cmd_or_exe_tag<wchar_t> type;};
+
+template<> struct initializer_tag<std::vector<std::basic_string<char >>> { typedef cmd_or_exe_tag<char> type;};
+template<> struct initializer_tag<std::vector<std::basic_string<wchar_t >>> { typedef cmd_or_exe_tag<wchar_t> type;};
+
+template<> struct initializer_tag<std::initializer_list<std::basic_string<char >>> { typedef cmd_or_exe_tag<char> type;};
+template<> struct initializer_tag<std::initializer_list<std::basic_string<wchar_t >>> { typedef cmd_or_exe_tag<wchar_t> type;};
+
+template<> struct initializer_tag<std::vector<char *>> { typedef cmd_or_exe_tag<char> type;};
+template<> struct initializer_tag<std::vector<wchar_t *>> { typedef cmd_or_exe_tag<wchar_t> type;};
+
+template<> struct initializer_tag<std::initializer_list<char *>> { typedef cmd_or_exe_tag<char> type;};
+template<> struct initializer_tag<std::initializer_list<wchar_t *>> { typedef cmd_or_exe_tag<wchar_t> type;};
+
+template<> struct initializer_tag<std::initializer_list<const char *>> { typedef cmd_or_exe_tag<char> type;};
+template<> struct initializer_tag<std::initializer_list<const wchar_t *>> { typedef cmd_or_exe_tag<wchar_t> type;};
+
+template<> struct initializer_tag<shell_>
+{
+ typedef cmd_or_exe_tag<typename boost::filesystem::path::value_type> type;
+};
+
+template<> struct initializer_tag<boost::filesystem::path>
+{
+ typedef cmd_or_exe_tag<typename boost::filesystem::path::value_type> type;
+};
+
+template <typename Char>
+struct exe_setter_;
+template <typename Char, bool Append = false>
+struct arg_setter_;
+
+template <typename Char, bool Append>
+struct initializer_tag<arg_setter_<Char, Append>> { typedef cmd_or_exe_tag<Char> type;};
+
+template<typename Char> struct initializer_tag<exe_setter_<Char>> { typedef cmd_or_exe_tag<Char> type;};
+
+template<>
+struct initializer_builder<cmd_or_exe_tag<char>>;
+
+template<>
+struct initializer_builder<cmd_or_exe_tag<wchar_t>>;
+
+
+}}}
+
+
+
+#endif /* BOOST_PROCESS_DETAIL_STRING_TRAITS_HPP_ */
diff --git a/boost/process/detail/traits/decl.hpp b/boost/process/detail/traits/decl.hpp
new file mode 100644
index 0000000000..48f8022f73
--- /dev/null
+++ b/boost/process/detail/traits/decl.hpp
@@ -0,0 +1,76 @@
+// Copyright (c) 2016 Klemens D. Morgenstern
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_PROCESS_DETAIL_TRAITS_DECL_HPP_
+#define BOOST_PROCESS_DETAIL_TRAITS_DECL_HPP_
+
+#include <boost/process/detail/config.hpp>
+#include <boost/none.hpp>
+#include <type_traits>
+
+#if defined(BOOST_POSIX_API)
+#include <boost/process/detail/posix/handler.hpp>
+#elif defined(BOOST_WINDOWS_API)
+#include <boost/process/detail/windows/handler.hpp>
+#endif
+
+
+namespace boost { namespace process { namespace detail {
+
+
+template<typename T>
+struct is_initializer : std::is_base_of<handler_base, T> {};
+
+
+template<typename T>
+struct is_initializer<T&> : std::is_base_of<handler_base, T> {};
+
+
+template<typename T>
+struct initializer_tag;// { typedef void type; };
+
+
+//remove const
+template<typename T>
+struct initializer_tag<const T> { typedef typename initializer_tag<T>::type type; };
+
+//remove &
+template<typename T>
+struct initializer_tag<T&> { typedef typename initializer_tag<T>::type type; };
+
+//remove const &
+template<typename T>
+struct initializer_tag<const T&> { typedef typename initializer_tag<T>::type type; };
+
+template<typename T>
+struct initializer_builder;
+
+
+template<typename First, typename ...Args>
+struct valid_argument_list;
+
+template<typename First>
+struct valid_argument_list<First>
+{
+ constexpr static bool value = is_initializer<First>::value || !std::is_void<typename initializer_tag<First>::type>::value;
+ typedef std::integral_constant<bool, value> type;
+};
+
+template<typename First, typename ...Args>
+struct valid_argument_list
+{
+ constexpr static bool my_value = is_initializer<First>::value || !std::is_void<typename initializer_tag<First>::type>::value;
+ constexpr static bool value = valid_argument_list<Args...>::value && my_value;
+ typedef std::integral_constant<bool, value> type;
+};
+
+
+
+}}}
+
+
+
+#endif /* BOOST_PROCESS_DETAIL_HANDLER_HPP_ */
diff --git a/boost/process/detail/traits/env.hpp b/boost/process/detail/traits/env.hpp
new file mode 100644
index 0000000000..ccdcad046a
--- /dev/null
+++ b/boost/process/detail/traits/env.hpp
@@ -0,0 +1,53 @@
+// Copyright (c) 2016 Klemens D. Morgenstern
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_PROCESS_DETAIL_TRAITS_ENV_HPP_
+#define BOOST_PROCESS_DETAIL_TRAITS_ENV_HPP_
+
+
+#include <boost/process/detail/traits/decl.hpp>
+
+
+namespace boost { namespace process {
+
+template<typename Char>
+class basic_environment;
+
+template<typename Char>
+class basic_native_environment;
+
+namespace detail {
+
+template<typename Char>
+struct env_tag {};
+
+
+
+
+template<typename Char> struct env_set;
+template<typename Char> struct env_append;
+
+template<typename Char> struct env_reset;
+template<typename Char> struct env_init;
+
+
+template<typename Char> struct initializer_tag<env_set<Char>> { typedef env_tag<Char> type; };
+template<typename Char> struct initializer_tag<env_append<Char>> { typedef env_tag<Char> type; };
+
+template<typename Char> struct initializer_tag<env_reset<Char>> { typedef env_tag<Char> type;};
+template<typename Char> struct initializer_tag<env_init <Char>> { typedef env_tag<Char> type;};
+
+template<typename Char> struct initializer_tag<::boost::process::basic_environment<Char>> { typedef env_tag<Char> type; };
+template<typename Char> struct initializer_tag<::boost::process::basic_native_environment<Char>> { typedef env_tag<Char> type; };
+
+template<> struct initializer_builder<env_tag<char>>;
+template<> struct initializer_builder<env_tag<wchar_t>>;
+
+}
+
+
+}}
+
+#endif /* INCLUDE_BOOST_PROCESS_DETAIL_ENV_HPP_ */
diff --git a/boost/process/detail/traits/error.hpp b/boost/process/detail/traits/error.hpp
new file mode 100644
index 0000000000..2d1912bda9
--- /dev/null
+++ b/boost/process/detail/traits/error.hpp
@@ -0,0 +1,27 @@
+// Copyright (c) 2016 Klemens D. Morgenstern
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_PROCESS_DETAIL_TRAITS_ERROR_HPP_
+#define BOOST_PROCESS_DETAIL_TRAITS_ERROR_HPP_
+
+#include <boost/process/detail/config.hpp>
+#include <system_error>
+#include <boost/process/detail/traits/decl.hpp>
+
+
+
+namespace boost { namespace process { namespace detail {
+
+struct error_tag;
+
+template<>
+struct initializer_tag<std::error_code>;
+
+}}}
+
+
+
+#endif /* BOOST_PROCESS_DETAIL_HANDLER_HPP_ */
diff --git a/boost/process/detail/traits/group.hpp b/boost/process/detail/traits/group.hpp
new file mode 100644
index 0000000000..3e7897c689
--- /dev/null
+++ b/boost/process/detail/traits/group.hpp
@@ -0,0 +1,37 @@
+// Copyright (c) 2016 Klemens D. Morgenstern
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_PROCESS_DETAIL_TRAITS_GROUP_HPP_
+#define BOOST_PROCESS_DETAIL_TRAITS_GROUP_HPP_
+
+#include <boost/process/detail/config.hpp>
+#include <boost/process/detail/traits/decl.hpp>
+
+
+
+namespace boost { namespace process {
+
+struct group;
+
+namespace detail {
+
+
+struct group_tag {};
+
+template<>
+struct make_initializer_t<group_tag>;
+
+
+template<> struct initializer_tag_t<::boost::process::group> { typedef group_tag type;};
+
+
+
+
+}}}
+
+
+
+#endif /* BOOST_PROCESS_DETAIL_HANDLER_HPP_ */
diff --git a/boost/process/detail/traits/wchar_t.hpp b/boost/process/detail/traits/wchar_t.hpp
new file mode 100644
index 0000000000..812a92cf13
--- /dev/null
+++ b/boost/process/detail/traits/wchar_t.hpp
@@ -0,0 +1,274 @@
+// Copyright (c) 2016 Klemens D. Morgenstern
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_PROCESS_DETAIL_TRAITS_WCHAR_T_HPP_
+#define BOOST_PROCESS_DETAIL_TRAITS_WCHAR_T_HPP_
+
+#include <boost/process/detail/traits/decl.hpp>
+#include <boost/process/detail/traits/cmd_or_exe.hpp>
+#include <boost/process/detail/traits/env.hpp>
+#include <boost/process/locale.hpp>
+
+namespace boost { namespace process { namespace detail {
+
+//template
+
+template<typename T> struct is_wchar_t : std::false_type {};
+
+template<> struct is_wchar_t<boost::filesystem::path> : std::is_same<typename boost::filesystem::path::value_type, wchar_t>
+{
+};
+
+template<> struct is_wchar_t<const wchar_t* > : std::true_type {};
+
+template<> struct is_wchar_t<wchar_t* > : std::true_type {};
+
+template<std::size_t Size> struct is_wchar_t<const wchar_t [Size]> : std::true_type {};
+template<std::size_t Size> struct is_wchar_t<const wchar_t (&)[Size]> : std::true_type {};
+
+template<> struct is_wchar_t<std::wstring> : std::true_type {};
+template<> struct is_wchar_t<std::vector<std::wstring>> : std::true_type {};
+template<> struct is_wchar_t<std::initializer_list<std::wstring>> : std::true_type {};
+template<> struct is_wchar_t<std::vector<wchar_t *>> : std::true_type {};
+template<> struct is_wchar_t<std::initializer_list<wchar_t *>> : std::true_type {};
+
+
+
+template<typename Char, typename T>
+struct char_converter
+{
+ static T& conv(T & in)
+ {
+ return in;
+ }
+ static T&& conv(T&& in)
+ {
+ return std::move(in);
+ }
+ static const T& conv(const T & in)
+ {
+ return in;
+ }
+};
+
+template<typename Char, typename T>
+using char_converter_t = char_converter<Char,
+ typename std::remove_cv<typename std::remove_reference<T>::type>::type>;
+
+
+template<>
+struct char_converter<char, const wchar_t*>
+{
+ static std::string conv(const wchar_t* in)
+ {
+ std::size_t size = 0;
+ while (in[size] != L'\0') size++;
+ return ::boost::process::detail::convert(in, in + size);
+ }
+};
+
+template<>
+struct char_converter<char, wchar_t*>
+{
+ static std::string conv(wchar_t* in)
+ {
+ std::size_t size = 0;
+ while (in[size] != L'\0') size++;
+ return ::boost::process::detail::convert(in, in + size);
+ }
+};
+
+template<std::size_t Size>
+struct char_converter<char, wchar_t[Size]>
+{
+ static std::string conv(const wchar_t(&in)[Size])
+ {
+ return ::boost::process::detail::convert(in, in + Size -1);
+ }
+};
+
+template<>
+struct char_converter<wchar_t, const char*>
+{
+ static std::wstring conv(const char* in)
+ {
+ std::size_t size = 0;
+ while (in[size] != '\0') size++;
+ return ::boost::process::detail::convert(in, in + size);
+ }
+};
+
+template<>
+struct char_converter<wchar_t, char*>
+{
+ static std::wstring conv(char* in)
+ {
+ std::size_t size = 0;
+ while (in[size] != '\0') size++;
+ return ::boost::process::detail::convert(in, in + size);
+ }
+};
+
+
+template<std::size_t Size>
+struct char_converter<wchar_t, char[Size]>
+{
+ static std::wstring conv(const char(&in)[Size])
+ {
+ return ::boost::process::detail::convert(in, in + Size -1);
+ }
+};
+
+//all the containers.
+template<>
+struct char_converter<wchar_t, std::string>
+{
+ static std::wstring conv(const std::string & in)
+ {
+ return ::boost::process::detail::convert(in);
+ }
+};
+
+template<>
+struct char_converter<char, std::wstring>
+{
+ static std::string conv(const std::wstring & in)
+ {
+ return ::boost::process::detail::convert(in);
+ }
+};
+
+template<>
+struct char_converter<wchar_t, std::vector<std::string>>
+{
+ static std::vector<std::wstring> conv(const std::vector<std::string> & in)
+ {
+ std::vector<std::wstring> ret(in.size());
+ std::transform(in.begin(), in.end(), ret.begin(),
+ [](const std::string & st)
+ {
+ return convert(st);
+ });
+ return ret;
+ }
+};
+
+template<>
+struct char_converter<wchar_t, std::initializer_list<std::string>>
+{
+ static std::vector<std::wstring> conv(const std::initializer_list<std::string> & in)
+ {
+ std::vector<std::wstring> ret(in.size());
+ std::transform(in.begin(), in.end(), ret.begin(),
+ [](const std::string & st)
+ {
+ return convert(st);
+ });
+ return ret;
+ }
+};
+
+template<>
+struct char_converter<wchar_t, std::vector<char* >>
+{
+ static std::vector<std::wstring> conv(const std::vector<char* > & in)
+ {
+ std::vector<std::wstring> ret(in.size());
+ std::transform(in.begin(), in.end(), ret.begin(),
+ [](const char* st)
+ {
+ std::size_t sz = 0;
+ while (st[sz] != '\0') sz++;
+ return convert(st, st + sz);
+ });
+ return ret;
+ }
+};
+
+template<>
+struct char_converter<wchar_t, std::initializer_list<char *>>
+{
+ static std::vector<std::wstring> conv(const std::initializer_list<char * > & in)
+ {
+ std::vector<std::wstring> ret(in.size());
+ std::transform(in.begin(), in.end(), ret.begin(),
+ [](const char* st)
+ {
+ std::size_t sz = 0;
+ while (st[sz] != '\0') sz++;
+ return convert(st, st + sz);
+ });
+ return ret;
+ }
+};
+
+template<>
+struct char_converter<char, std::vector<std::wstring>>
+{
+ static std::vector<std::string> conv(const std::vector<std::wstring> & in)
+ {
+ std::vector<std::string> ret(in.size());
+ std::transform(in.begin(), in.end(), ret.begin(),
+ [](const std::wstring & st)
+ {
+ return convert(st);
+ });
+ return ret;
+ }
+};
+
+template<>
+struct char_converter<char, std::initializer_list<std::wstring>>
+{
+ static std::vector<std::string> conv(const std::initializer_list<std::wstring> & in)
+ {
+ std::vector<std::string> ret(in.size());
+ std::transform(in.begin(), in.end(), ret.begin(),
+ [](const std::wstring & st)
+ {
+ return convert(st);
+ });
+ return ret;
+ }
+};
+
+template<>
+struct char_converter<char, std::vector<wchar_t* >>
+{
+ static std::vector<std::string> conv(const std::vector<wchar_t* > & in)
+ {
+ std::vector<std::string> ret(in.size());
+ std::transform(in.begin(), in.end(), ret.begin(),
+ [](const wchar_t* st)
+ {
+ std::size_t sz = 0;
+ while (st[sz] != L'\0') sz++;
+ return convert(st, st + sz);
+ });
+ return ret;
+ }
+};
+
+template<>
+struct char_converter<char, std::initializer_list<wchar_t * >>
+{
+ static std::vector<std::string> conv(const std::initializer_list<wchar_t *> & in)
+ {
+ std::vector<std::string> ret(in.size());
+ std::transform(in.begin(), in.end(), ret.begin(),
+ [](const wchar_t* st)
+ {
+ std::size_t sz = 0;
+ while (st[sz] != L'\0') sz++;
+ return convert(st, st + sz);
+ });
+ return ret;
+ }
+};
+
+
+}}}
+#endif /* BOOST_PROCESS_DETAIL_TRAITS_WCHAR_T_HPP_ */