config.hpp
Go to the documentation of this file.
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 //
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 
10 /**
11  * \file boost/process/config.hpp
12  *
13  * Defines various macros.
14  */
15 
16 #pragma once
17 
18 #include <boost/config.hpp>
19 #include <boost/system/config.hpp>
20 #include <boost/system/error_code.hpp>
21 #include <boost/system/system_error.hpp>
22 
23 #if defined(BOOST_POSIX_API)
24 #include <errno.h>
25 #define BOOST_PROCESS_LAST_ERROR errno
26 #define BOOST_PROCESS_PLATFORM posix
27 #elif defined(BOOST_WINDOWS_API)
28 #include <Windows.h>
29 #define BOOST_PROCESS_LAST_ERROR GetLastError()
30 #define BOOST_PROCESS_PLATFORM windows
31 #endif
32 
33 /** \cond */
34 #define BOOST_PROCESS_PLATFORM_PROMOTE_PATH(COMPONENT) \
35 <boost/process/BOOST_PROCESS_PLATFORM/COMPONENT.hpp>
36 #define BOOST_PROCESS_PLATFORM_PROMOTE_NAMESPACE(COMPONENT) \
37  namespace boost::process \
38  { \
39  using BOOST_PROCESS_PLATFORM::COMPONENT; \
40  }
41 #define BOOST_PROCESS_PLATFORM_PROMOTE_INITIALIZERS_NAMESPACE \
42  namespace boost::process::initializers \
43  { \
44  using namespace boost::process::BOOST_PROCESS_PLATFORM::initializers; \
45  }
46 /** \endcond */
47 
48 #if defined(BOOST_PROCESS_DOXYGEN)
49 /**
50  * \def BOOST_POSIX_API
51  *
52  * This macro is defined on POSIX.
53  */
54 #define BOOST_POSIX_API
55 /**
56  * \def BOOST_WINDOWS_API
57  *
58  * This macro is defined on Windows.
59  */
60 #define BOOST_WINDOWS_API
61 #endif
62 
63 /**
64  * \def BOOST_PROCESS_THROW(EX)
65  *
66  * Defines how exceptions are thrown. Set this macro for example
67  * to \c BOOST_THROW_EXCEPTION if you like to use Boost.Exception.
68  */
69 #define BOOST_PROCESS_THROW(EX) throw EX
70 
71 /** \cond */
72 #define BOOST_PROCESS_SOURCE_LOCATION "in file '" __FILE__ "', line " BOOST_STRINGIZE(__LINE__) ": "
73 
74 #define BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR(what) \
75  BOOST_PROCESS_THROW(boost::system::system_error( \
76  boost::system::error_code(BOOST_PROCESS_LAST_ERROR, boost::system::system_category()), \
77  BOOST_PROCESS_SOURCE_LOCATION what))
78 
79 #define BOOST_PROCESS_RETURN_LAST_SYSTEM_ERROR(ec) \
80  ec = boost::system::error_code(BOOST_PROCESS_LAST_ERROR, boost::system::system_category())
81 /** \endcond */