X-Git-Url: http://git.home-dn.net/?p=manu%2Fsuphp.git;a=blobdiff_plain;f=src%2FEnvironment.hpp;fp=src%2FEnvironment.hpp;h=c50cf0331bf793485de270e8eab313173763fb43;hp=0000000000000000000000000000000000000000;hb=873afb00229b8e205345b6895eaad6602d5e10f4;hpb=728a5b3f000f892e52ecea98fcc8f0c5d7275b7b diff --git a/src/Environment.hpp b/src/Environment.hpp new file mode 100644 index 0000000..c50cf03 --- /dev/null +++ b/src/Environment.hpp @@ -0,0 +1,83 @@ +/* + suPHP - (c)2002-2005 Sebastian Marsching + + This file is part of suPHP. + + suPHP is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + suPHP 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with suPHP; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef SUPHP_ENVIRONMENT_H + +namespace suPHP { + class Environment; +}; + +#define SUPHP_ENVIRONMENT_H + +#include +#include + +#include "KeyNotFoundException.hpp" + +namespace suPHP { + /** + * Class containing environment variables. + */ + class Environment { + private: + std::map vars; + + public: + /** + * Returns (copy of) variable content + */ + std::string getVar(const std::string& name) const + throw (KeyNotFoundException); + + /** + * Sets variable content + */ + void setVar(const std::string name, const std::string content) + throw (KeyNotFoundException); + + /** + * Adds variable to environment + */ + void putVar(const std::string name, const std::string content); + + /** + * Deletes variable from environment + */ + void deleteVar(const std::string& name) throw (KeyNotFoundException); + + /** + * Checks whether a variable is set + */ + bool hasVar(const std::string& name) const; + + /** + * Returns reference to variable with name + */ + std::string& operator[](const std::string& name) + throw (KeyNotFoundException); + + /** + * Returns const reference to the map which stores the variables + */ + const std::map& getBackendMap() const; + }; +}; + +#endif // SUPHP_ENVIRONMENT_H