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 "OutOfRangeException.hpp"
26 #include "CommandLine.hpp"
28 using namespace suPHP;
30 suPHP::CommandLine::CommandLine() {
34 int suPHP::CommandLine::count() const {
35 return this->arguments.size();
38 std::string suPHP::CommandLine::getArgument(int pos) const
39 throw (OutOfRangeException) {
41 return this->arguments.at(pos);
42 } catch (std::out_of_range& e) {
43 throw OutOfRangeException("Index out of range", __FILE__, __LINE__);
47 void suPHP::CommandLine::setArgument(int pos, std::string arg) {
48 if (pos >= this->arguments.size()) {
49 for (int i=0; i<(this->arguments.size() - pos); i++) {
50 this->arguments.push_back(std::string(""));
53 this->arguments.at(pos) = arg;
56 void suPHP::CommandLine::putArgument(std::string arg) {
57 this->arguments.push_back(arg);
60 std::string& suPHP::CommandLine::operator[](int index)
61 throw (OutOfRangeException) {
63 return this->arguments.at(index);
64 } catch (std::out_of_range& ex) {
65 throw OutOfRangeException("Index out of range", __FILE__, __LINE__);
70 int suPHP::CommandLine::size() const {
71 return this->arguments.size();