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

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
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  char *CombineQuoted(int start_index=0) const;
46  char *CombineCmd(int i=0) const;
47 
48  int getopt_long(const char *opts,const struct option *lopts,int *lind=0);
49  int getopt(const char *opts)
50  {
51  return getopt_long(opts,0,0);
52  }
53  const char *getopt_error_message(int e);
54 
55  void seek(int n);
56  void rewind() { seek(0); }
57  const char *getnext();
58 
59  const char *getarg(int n) const { return String(n); }
60  const char *getcurr() const { return ind<Count()?getarg(ind):0; }
61  int getindex() const { return ind; }
62  void setarg(int n,const char *s) { Replace(n,s); }
63  void delarg(int n) { if(ind>n)--ind; Remove(n); }
64  void insarg(int n,const char *s) { InsertBefore(n,s); }
65  const char *a0() const { return getarg(0); }
66  void back();
67  int count() const { return Count(); }
68  const char *const*GetV() const { return Set(); }
69  char **GetVNonConst() { return SetNonConst(); }
70 };
71 
72 #endif//ARGV_H
ArgV(const ArgV *a)
Definition: ArgV.h:36
int count() const
Definition: ArgV.h:67
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:69
const char * getopt_error_message(int e)
Definition: ArgV.cc:83
void insarg(int n, const char *s)
Definition: ArgV.h:64
void back()
Definition: ArgV.cc:53
void seek(int n)
Definition: ArgV.cc:38
int getindex() const
Definition: ArgV.h:61
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:56
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:59
char * CombineCmd(int i=0) const
Definition: CmdExec.cc:1096
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:75
ArgV(const char *a0)
Definition: ArgV.h:33
case s
Definition: strptime.c:563
const char * getcurr() const
Definition: ArgV.h:60
~ArgV()
Definition: ArgV.cc:34
const char * a0() const
Definition: ArgV.h:65
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
void delarg(int n)
Definition: ArgV.h:63
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:1082
void setarg(int n, const char *s)
Definition: ArgV.h:62
const char *const * Set() const
Definition: StringSet.h:49
int getopt(const char *opts)
Definition: ArgV.h:49
#define args
Definition: commands.cc:1359
char * Combine(int start_index=0, int end_index=0) const
Definition: ArgV.cc:59
const char *const * GetV() const
Definition: ArgV.h:68