1240116Smarcel// Copyright (c) 2007 The NetBSD Foundation, Inc. 2240116Smarcel// All rights reserved. 3240116Smarcel// 4240116Smarcel// Redistribution and use in source and binary forms, with or without 5240116Smarcel// modification, are permitted provided that the following conditions 6240116Smarcel// are met: 7240116Smarcel// 1. Redistributions of source code must retain the above copyright 8240116Smarcel// notice, this list of conditions and the following disclaimer. 9240116Smarcel// 2. Redistributions in binary form must reproduce the above copyright 10240116Smarcel// notice, this list of conditions and the following disclaimer in the 11240116Smarcel// documentation and/or other materials provided with the distribution. 12240116Smarcel// 13240116Smarcel// THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND 14240116Smarcel// CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 15240116Smarcel// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16240116Smarcel// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17240116Smarcel// IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY 18240116Smarcel// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19240116Smarcel// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 20240116Smarcel// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21240116Smarcel// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 22240116Smarcel// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23240116Smarcel// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 24240116Smarcel// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25240116Smarcel 26273929Sjmmv#if !defined(ATF_CXX_DETAIL_ENV_HPP) 27273929Sjmmv#define ATF_CXX_DETAIL_ENV_HPP 28240116Smarcel 29240116Smarcel#include <string> 30240116Smarcel 31240116Smarcelnamespace atf { 32240116Smarcelnamespace env { 33240116Smarcel 34240116Smarcel// ------------------------------------------------------------------------ 35240116Smarcel// Free functions. 36240116Smarcel// ------------------------------------------------------------------------ 37240116Smarcel 38240116Smarcel//! 39240116Smarcel//! \brief Returns the value of an environment variable. 40240116Smarcel//! 41240116Smarcel//! Returns the value of the specified environment variable. The variable 42240116Smarcel//! must be defined. 43240116Smarcel//! 44240116Smarcelstd::string get(const std::string&); 45240116Smarcel 46240116Smarcel//! 47273929Sjmmv//! \brief Returns the value of an environment variable with a default. 48273929Sjmmv//! 49273929Sjmmvstd::string get(const std::string&, const std::string&); 50273929Sjmmv 51273929Sjmmv//! 52240116Smarcel//! \brief Checks if the environment has a variable. 53240116Smarcel//! 54240116Smarcel//! Checks if the environment has a given variable. 55240116Smarcel//! 56240116Smarcelbool has(const std::string&); 57240116Smarcel 58240116Smarcel//! 59240116Smarcel//! \brief Sets an environment variable to a given value. 60240116Smarcel//! 61240116Smarcel//! Sets the specified environment variable to the given value. Note that 62240116Smarcel//! variables set to the empty string are different to undefined ones. 63240116Smarcel//! 64240116Smarcel//! Be aware that this alters the program's global status, which in general 65240116Smarcel//! is a bad thing to do due to the side-effects it may have. There are 66240116Smarcel//! some legitimate usages for this function, though. 67240116Smarcel//! 68240116Smarcelvoid set(const std::string&, const std::string&); 69240116Smarcel 70240116Smarcel//! 71240116Smarcel//! \brief Unsets an environment variable. 72240116Smarcel//! 73240116Smarcel//! Unsets the specified environment variable Note that undefined 74240116Smarcel//! variables are different to those defined but set to an empty value. 75240116Smarcel//! 76240116Smarcel//! Be aware that this alters the program's global status, which in general 77240116Smarcel//! is a bad thing to do due to the side-effects it may have. There are 78240116Smarcel//! some legitimate usages for this function, though. 79240116Smarcel//! 80240116Smarcelvoid unset(const std::string&); 81240116Smarcel 82240116Smarcel} // namespace env 83240116Smarcel} // namespace atf 84240116Smarcel 85273929Sjmmv#endif // !defined(ATF_CXX_DETAIL_ENV_HPP) 86