2 suPHP - (c)2002-2005 Sebastian Marsching <sebastian@marsching.com>
4 This file is part of suPHP.
6 suPHP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 suPHP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with suPHP; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "KeyNotFoundException.hpp"
26 #include "Environment.hpp"
28 using namespace suPHP
;
30 std::string
suPHP::Environment::getVar(const std::string
& name
) const
31 throw (KeyNotFoundException
) {
32 if (this->vars
.find(name
) != this->vars
.end()) {
33 return this->vars
.find(name
)->second
;
35 throw KeyNotFoundException("Key " + name
+ " not found",
40 void suPHP::Environment::setVar(const std::string name
,
41 const std::string content
)
42 throw (KeyNotFoundException
) {
43 if (this->vars
.find(name
) != this->vars
.end()) {
44 this->vars
.find(name
)->second
= content
;
46 throw KeyNotFoundException("Key " + name
+ " not found",
51 void suPHP::Environment::putVar(const std::string name
,
52 const std::string content
) {
53 if (this->vars
.find(name
) != this->vars
.end()) {
54 this->vars
.find(name
)->second
= content
;
56 std::pair
<std::string
, std::string
> p
;
64 void suPHP::Environment::deleteVar(const std::string
& name
)
65 throw (KeyNotFoundException
) {
66 if (this->vars
.find(name
) != this->vars
.end()) {
67 this->vars
.erase(name
);
69 throw KeyNotFoundException("Key " + name
+ " not found",
74 bool suPHP::Environment::hasVar(const std::string
& name
) const {
75 if (this->vars
.find(name
) != this->vars
.end()) {
83 std::string
& suPHP::Environment::operator[](const std::string
& name
)
84 throw (KeyNotFoundException
) {
85 if (this->vars
.find(name
) != this->vars
.end()) {
86 return this->vars
.find(name
)->second
;
88 throw KeyNotFoundException("Key " + name
+ " not found",
94 const std::map
<std::string
, std::string
>& suPHP::Environment::getBackendMap()