summaryrefslogtreecommitdiff
path: root/libcult/cult/cli/file-arguments.hxx
blob: e14f53c04bbc2b955a7196844b879fd5b84f7dff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// file      : cult/cli/file-arguments.hxx
// author    : Boris Kolpackov <boris@kolpackov.net>
// copyright : Copyright (c) 2005-2010 Boris Kolpackov
// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file

#ifndef CULT_CLI_FILE_ARGUMENTS_HXX
#define CULT_CLI_FILE_ARGUMENTS_HXX

#include <cult/types.hxx>
#include <cult/containers/vector.hxx>

#include <cult/cli/exceptions.hxx>
#include <cult/cli/arguments.hxx>

namespace Cult
{
  namespace CLI
  {
    class FileArguments: public Arguments
    {
    public:
      virtual
      ~FileArguments ();

      FileArguments (Int argc,
                     Char const* const* argv,
                     Char const* file_option);
    public:
      virtual Size
      size () const
      {
        return args_.size ();
      }

      virtual Char const*
      operator[] (Index i) const
      {
        if (i >= size ())
          throw Bounds ();

        return args_[i].c_str ();
      }

      virtual Void
      erase (Index i)
      {
        if (i >= size ())
          throw Bounds ();

        args_.erase (args_.begin () + i);
      }

    private:
      Containers::Vector<String> args_;
    };
  }
}

#endif  // CULT_CLI_FILE_ARGUMENTS_HXX