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
23
24#include <functional>
25#include <iosfwd>
26#include <string>
27#include <system_error>
28
29namespace core
30{
31namespace posix
32{
33class Process;
34namespace this_process
35{
36namespace env
37{
43 const std::function<void(const std::string&, const std::string&)>& functor) noexcept(true);
44
51CORE_POSIX_DLL_PUBLIC std::string get_or_throw(const std::string& key);
52
59CORE_POSIX_DLL_PUBLIC std::string get(
60 const std::string& key,
61 const std::string& default_value = std::string()) noexcept(true);
62
68CORE_POSIX_DLL_PUBLIC void unset_or_throw(const std::string& key);
69
76CORE_POSIX_DLL_PUBLIC bool unset(const std::string& key,
77 std::error_code& se) noexcept(true);
78
85CORE_POSIX_DLL_PUBLIC void set_or_throw(const std::string& key,
86 const std::string& value);
94CORE_POSIX_DLL_PUBLIC bool set(const std::string &key,
95 const std::string &value,
96 std::error_code& se) noexcept(true);
97}
98
102CORE_POSIX_DLL_PUBLIC Process instance() noexcept(true);
103
108CORE_POSIX_DLL_PUBLIC Process parent() noexcept(true);
109
113CORE_POSIX_DLL_PUBLIC std::istream& cin() noexcept(true);
114
118CORE_POSIX_DLL_PUBLIC std::ostream& cout() noexcept(true);
119
123CORE_POSIX_DLL_PUBLIC std::ostream& cerr() noexcept(true);
124}
125}
126}
127
128#endif // CORE_POSIX_THIS_PROCESS_H_
The Process class models a process and possible operations on it.
Definition process.h:45
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.
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 std::string get(const std::string &key, const std::string &default_value=std::string()) noexcept(true)
get queries the value of an environment variable.
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 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 void unset_or_throw(const std::string &key)
unset_or_throw removes the variable with name key from the environment.
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 & cout() noexcept(true)
Access this process's stdout.
CORE_POSIX_DLL_PUBLIC Process parent() noexcept(true)
Query the parent of the process.
CORE_POSIX_DLL_PUBLIC std::ostream & cerr() noexcept(true)
Access this process's stderr.
CORE_POSIX_DLL_PUBLIC Process instance() noexcept(true)
Returns a Process instance corresponding to this process.
CORE_POSIX_DLL_PUBLIC std::istream & cin() noexcept(true)
Access this process's stdin.
#define CORE_POSIX_DLL_PUBLIC
Definition visibility.h:26