lftp  4.6.2
About: lftp is a command line ftp client (FTP, HTTP, ssl support, background transfer, reget, reput, ...).
  Fossies Dox: lftp-4.6.2.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

ArgV.h
Go to the documentation of this file.
1 /*
2  * lftp - file transfer program
3  *
4  * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net)
5  *
6  * This program 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 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program 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.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef ARGV_H
21 #define ARGV_H
22 
23 #include "trio.h"
24 #include "StringSet.h"
25 #include "getopt.h"
26 
27 class ArgV : public StringSet
28 {
29  int ind;
30 
31 public:
32  ArgV() { ind=0; }
33  ArgV(const char *a0) : StringSet(&a0,1) { ind=0; }
34  ArgV(const char *a0, const char *args);
35  ArgV(const ArgV& a) : StringSet(a) { ind=0; }
36  ArgV(const ArgV *a) : StringSet(*a) { ind=0; }
37  ArgV(int new_c,const char * const *new_v) : StringSet(new_v,new_c) { ind=0; }
38  ~ArgV();
39 
40  void Append(const char *s) { StringSet::Append(s); }
41  void Append(int a) { char buf[32]; sprintf(buf,"%d",a); Append(buf); }
42  void Add(const char *a) { Append(a); } // alias
43 
44  char *Combine(int start_index=0,int end_index=0) const;
45 
46  // for the UNIX shell
47  char *CombineShellQuoted(int start) const;
48  // for lftp's CmdExec
49  char *CombineQuoted(int start_index=0) const;
50  char *CombineCmd(int i=0) const;
51 
52  int getopt_long(const char *opts,const struct option *lopts,int *lind=0);
53  int getopt(const char *opts)
54  {
55  return getopt_long(opts,0,0);
56  }
57  const char *getopt_error_message(int e);
58 
59  void seek(int n);
60  void rewind() { seek(0); }
61  const char *getnext();
62 
63  const char *getarg(int n) const { return String(n); }
64  const char *getcurr() const { return ind<Count()?getarg(ind):0; }
65  int getindex() const { return ind; }
66  void setarg(int n,const char *s) { Replace(n,s); }
67  void delarg(int n) { if(ind>n)--ind; Remove(n); }
68  void insarg(int n,const char *s) { InsertBefore(n,s); }
69  const char *a0() const { return getarg(0); }
70  void back();
71  int count() const { return Count(); }
72  const char *const*GetV() const { return Set(); }
73  char **GetVNonConst() { return SetNonConst(); }
74 };
75 
76 #endif//ARGV_H
ArgV(const ArgV *a)
Definition: ArgV.h:36
int count() const
Definition: ArgV.h:71
void Replace(int, const char *)
Definition: StringSet.cc:56
ArgV(const ArgV &a)
Definition: ArgV.h:35
case a
Definition: strptime.c:305
char ** GetVNonConst()
Definition: ArgV.h:73
const char * getopt_error_message(int e)
Definition: ArgV.cc:102
void insarg(int n, const char *s)
Definition: ArgV.h:68
void back()
Definition: ArgV.cc:53
void seek(int n)
Definition: ArgV.cc:38
int getindex() const
Definition: ArgV.h:65
void Append(const char *)
Definition: StringSet.cc:50
void Remove(int i)
Definition: StringSet.h:47
void Add(const char *a)
Definition: ArgV.h:42
void rewind()
Definition: ArgV.h:60
char ** SetNonConst()
Definition: StringSet.h:50
void Append(int a)
Definition: ArgV.h:41
ArgV(int new_c, const char *const *new_v)
Definition: ArgV.h:37
const char * getarg(int n) const
Definition: ArgV.h:63
char * CombineCmd(int i=0) const
Definition: CmdExec.cc:1097
Definition: ArgV.h:27
ArgV()
Definition: ArgV.h:32
case n
Definition: strptime.c:497
int getopt_long(const char *opts, const struct option *lopts, int *lind=0)
Definition: ArgV.cc:94
ArgV(const char *a0)
Definition: ArgV.h:33
case s
Definition: strptime.c:563
const char * getcurr() const
Definition: ArgV.h:64
~ArgV()
Definition: ArgV.cc:34
const char * a0() const
Definition: ArgV.h:69
void Append(const char *s)
Definition: ArgV.h:40
void void InsertBefore(int, const char *)
Definition: StringSet.cc:67
const char * getnext()
Definition: ArgV.cc:45
char * CombineShellQuoted(int start) const
Definition: ArgV.cc:75
void delarg(int n)
Definition: ArgV.h:67
const char * String(int i) const
Definition: StringSet.h:52
int Count() const
Definition: StringSet.h:51
char * CombineQuoted(int start_index=0) const
Definition: CmdExec.cc:1083
void setarg(int n, const char *s)
Definition: ArgV.h:66
const char *const * Set() const
Definition: StringSet.h:49
int getopt(const char *opts)
Definition: ArgV.h:53
#define args
Definition: commands.cc:1360
char * Combine(int start_index=0, int end_index=0) const
Definition: ArgV.cc:59
const char *const * GetV() const
Definition: ArgV.h:72