this_process.h
Go to the documentation of this file.
/*
* Copyright © 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Thomas Voß <thomas.voss@canonical.com>
*/
#ifndef CORE_POSIX_THIS_PROCESS_H_
#define CORE_POSIX_THIS_PROCESS_H_
#include <core/posix/visibility.h>
#include <functional>
#include <iosfwd>
#include <string>
#include <system_error>
namespace core
{
namespace posix
{
class Process;
namespace this_process
{
namespace env
{
CORE_POSIX_DLL_PUBLIC void for_each(
const std::function<void(const std::string&, const std::string&)>& functor) noexcept(true);
CORE_POSIX_DLL_PUBLIC std::string get_or_throw(const std::string& key);
CORE_POSIX_DLL_PUBLIC std::string get(
const std::string& key,
const std::string& default_value = std::string()) noexcept(true);
CORE_POSIX_DLL_PUBLIC void unset_or_throw(const std::string& key);
CORE_POSIX_DLL_PUBLIC bool unset(const std::string& key,
std::error_code& se) noexcept(true);
CORE_POSIX_DLL_PUBLIC void set_or_throw(const std::string& key,
const std::string& value);
CORE_POSIX_DLL_PUBLIC bool set(const std::string &key,
const std::string &value,
std::error_code& se) noexcept(true);
}
CORE_POSIX_DLL_PUBLIC Process instance() noexcept(true);
CORE_POSIX_DLL_PUBLIC Process parent() noexcept(true);
CORE_POSIX_DLL_PUBLIC std::istream& cin() noexcept(true);
CORE_POSIX_DLL_PUBLIC std::ostream& cout() noexcept(true);
CORE_POSIX_DLL_PUBLIC std::ostream& cerr() noexcept(true);
}
}
}
#endif // CORE_POSIX_THIS_PROCESS_H_
core::posix::Process
The Process class models a process and possible operations on it.
Definition: process.h:45
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::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::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::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::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::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::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::cout
CORE_POSIX_DLL_PUBLIC std::ostream & cout() noexcept(true)
Access this process's stdout.
Definition: this_process.cpp:166
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::cerr
CORE_POSIX_DLL_PUBLIC std::ostream & cerr() noexcept(true)
Access this process's stderr.
Definition: this_process.cpp:171
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
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
Definition: child_process.h:32
visibility.h
CORE_POSIX_DLL_PUBLIC
#define CORE_POSIX_DLL_PUBLIC
Definition: visibility.h:26