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) {
40 if (pos >= this->arguments.size() || pos < 0) {
41 throw OutOfRangeException("Index out of range", __FILE__, __LINE__);
44 return this->arguments[pos];
45 } catch (std::out_of_range& e) {
46 throw OutOfRangeException("Index out of range", __FILE__, __LINE__);
50 void suPHP::CommandLine::setArgument(int pos, std::string arg) {
51 if (pos >= this->arguments.size()) {
52 for (int i=0; i<(this->arguments.size() - pos); i++) {
53 this->arguments.push_back(std::string(""));
56 this->arguments[pos] = arg;
59 void suPHP::CommandLine::putArgument(std::string arg) {
60 this->arguments.push_back(arg);
63 std::string& suPHP::CommandLine::operator[](int index)
64 throw (OutOfRangeException) {
65 if (index >= this->arguments.size() || index < 0) {
66 throw OutOfRangeException("Index out of range", __FILE__, __LINE__);
69 return this->arguments[index];
70 } catch (std::out_of_range& ex) {
71 throw OutOfRangeException("Index out of range", __FILE__, __LINE__);
76 int suPHP::CommandLine::size() const {
77 return this->arguments.size();