process-cpp: /build/process-cpp/src/process-cpp-3.0.1/include/core/posix/this_process.h Source File

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 {
42 CORE_POSIX_DLL_PUBLIC void for_each(
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_
core::posix::this_process::env::get
CORE_POSIX_DLL_PUBLIC std::string get(const std::string &key, const std::string &default_value=std::string()) noexcept(true)
get queries the value of an environment variable.
Definition: this_process.cpp:84
core::posix::this_process::instance
CORE_POSIX_DLL_PUBLIC Process instance() noexcept(true)
Returns a Process instance corresponding to this process.
Definition: this_process.cpp:150
visibility.h
CORE_POSIX_DLL_PUBLIC
#define CORE_POSIX_DLL_PUBLIC
Definition: visibility.h:26
core::posix::this_process::env::set
CORE_POSIX_DLL_PUBLIC bool set(const std::string &key, const std::string &value, std::error_code &se) noexcept(true)
set will adjust the contents of the variable identified by key to the provided value.
Definition: this_process.cpp:131
core::posix::this_process::env::set_or_throw
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.
Definition: this_process.cpp:119
core::posix::this_process::env::get_or_throw
CORE_POSIX_DLL_PUBLIC std::string get_or_throw(const std::string &key)
get queries the value of an environment variable.
Definition: this_process.cpp:68
core::posix::this_process::cerr
CORE_POSIX_DLL_PUBLIC std::ostream & cerr() noexcept(true)
Access this process's stderr.
Definition: this_process.cpp:171
core
Definition: child_process.h:32
core::posix::this_process::cin
CORE_POSIX_DLL_PUBLIC std::istream & cin() noexcept(true)
Access this process's stdin.
Definition: this_process.cpp:161
core::posix::this_process::cout
CORE_POSIX_DLL_PUBLIC std::ostream & cout() noexcept(true)
Access this process's stdout.
Definition: this_process.cpp:166
core::posix::this_process::env::for_each
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.
Definition: this_process.cpp:55
core::posix::this_process::env::unset
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.
Definition: this_process.cpp:103
core::posix::this_process::parent
CORE_POSIX_DLL_PUBLIC Process parent() noexcept(true)
Query the parent of the process.
Definition: this_process.cpp:156
core::posix::this_process::env::unset_or_throw
CORE_POSIX_DLL_PUBLIC void unset_or_throw(const std::string &key)
unset_or_throw removes the variable with name key from the environment.
Definition: this_process.cpp:93
core::posix::Process
The Process class models a process and possible operations on it.
Definition: process.h:45