process-cpp  3.0.0
A simple convenience library for handling processes in C++11.
this_process.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Thomas Voß <thomas.voss@canonical.com>
17  */
18 
19 #ifndef CORE_POSIX_THIS_PROCESS_H_
20 #define CORE_POSIX_THIS_PROCESS_H_
21 
22 #include <core/posix/visibility.h>
23 
24 #include <functional>
25 #include <iosfwd>
26 #include <string>
27 #include <system_error>
28 
29 namespace core
30 {
31 namespace posix
32 {
33 class Process;
34 namespace this_process
35 {
36 namespace env
37 {
43  const std::function<void(const std::string&, const std::string&)>& functor) noexcept(true);
44 
51 CORE_POSIX_DLL_PUBLIC std::string get_or_throw(const std::string& key);
52 
59 CORE_POSIX_DLL_PUBLIC std::string get(
60  const std::string& key,
61  const std::string& default_value = std::string()) noexcept(true);
62 
68 CORE_POSIX_DLL_PUBLIC void unset_or_throw(const std::string& key);
69 
76 CORE_POSIX_DLL_PUBLIC bool unset(const std::string& key,
77  std::error_code& se) noexcept(true);
78 
85 CORE_POSIX_DLL_PUBLIC void set_or_throw(const std::string& key,
86  const std::string& value);
94 CORE_POSIX_DLL_PUBLIC bool set(const std::string &key,
95  const std::string &value,
96  std::error_code& se) noexcept(true);
97 }
98 
102 CORE_POSIX_DLL_PUBLIC Process instance() noexcept(true);
103 
108 CORE_POSIX_DLL_PUBLIC Process parent() noexcept(true);
109 
113 CORE_POSIX_DLL_PUBLIC std::istream& cin() noexcept(true);
114 
118 CORE_POSIX_DLL_PUBLIC std::ostream& cout() noexcept(true);
119 
123 CORE_POSIX_DLL_PUBLIC std::ostream& cerr() noexcept(true);
124 }
125 }
126 }
127 
128 #endif // CORE_POSIX_THIS_PROCESS_H_
#define CORE_POSIX_DLL_PUBLIC
Definition: visibility.h:26
The Process class models a process and possible operations on it.
Definition: process.h:44
CORE_POSIX_DLL_PUBLIC std::istream & cin() noexcept(true)
Access this process&#39;s stdin.
CORE_POSIX_DLL_PUBLIC void for_each(const std::function< void(const std::string &, const std::string &)> &functor) noexcept(true)
for_each invokes a functor for every key-value pair in the environment.
CORE_POSIX_DLL_PUBLIC std::ostream & cerr() noexcept(true)
Access this process&#39;s stderr.
CORE_POSIX_DLL_PUBLIC void set_or_throw(const std::string &key, const std::string &value)
set_or_throw will adjust the contents of the variable identified by key to the provided value...
CORE_POSIX_DLL_PUBLIC std::string get_or_throw(const std::string &key)
get queries the value of an environment variable.
CORE_POSIX_DLL_PUBLIC Process instance() noexcept(true)
Returns a Process instance corresponding to this process.
CORE_POSIX_DLL_PUBLIC void unset_or_throw(const std::string &key)
unset_or_throw removes the variable with name key from the environment.
CORE_POSIX_DLL_PUBLIC std::ostream & cout() noexcept(true)
Access this process&#39;s stdout.
CORE_POSIX_DLL_PUBLIC bool unset(const std::string &key, std::error_code &se) noexcept(true)
unset removes the variable with name key from the environment.
CORE_POSIX_DLL_PUBLIC Process parent() noexcept(true)
Query the parent of the process.