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
23 #include "KeyNotFoundException.hpp"
25 #include "IniSection.hpp"
27 using namespace suPHP;
29 void suPHP::IniSection::putValue(std::string key, std::string value) {
30 std::pair<std::string, std::string> p;
33 this->entries.insert(p);
36 std::vector<std::string> suPHP::IniSection::getValues(std::string key)
37 throw (KeyNotFoundException) {
38 std::vector<std::string> values;
39 for (std::multimap<std::string, std::string>::iterator pos =
40 this->entries.find(key);
41 pos != this->entries.end(); pos++) {
42 values.push_back(pos->second);
44 if (values.size() == 0) {
45 throw KeyNotFoundException("No value for key " + key + " found",
51 std::string suPHP::IniSection::getValue(std::string key)
52 throw (KeyNotFoundException) {
53 std::vector<std::string> values;
54 if (this->entries.find(key) != this->entries.end()) {
55 return this->entries.find(key)->second;
57 throw KeyNotFoundException("No value for key " + key + " found",
63 std::vector<std::string> suPHP::IniSection::getKeys() {
64 std::vector<std::string> keys;
65 for (std::multimap<std::string, std::string>::iterator pos =
66 this->entries.begin();
67 pos != this->entries.end(); pos++) {
68 keys.push_back(pos->first);
73 bool suPHP::IniSection::hasKey(std::string key) {
74 if (this->entries.find(key) != this->entries.end()) {
82 std::vector<std::string> suPHP::IniSection::operator[](std::string key)
83 throw (KeyNotFoundException) {
84 return this->getValues(key);