plebble
shell_args.h
Go to the documentation of this file.
1 /*
2 -------------------------------------------------------------------------------
3  PLEBBLE
4 -------------------------------------------------------------------------------
5  Copyright (C) 2019-2020 KATLAS Technology. (http://katlastechnology.com)
6  Copyright (C) 2017-2020 Marcos Mayorga. (mm@mm-studios.com)
7 
8  This file is part of our Plebble(R) Platform.
9 
10  The code below cannot be copied, used for any purpose other than the one
11  agreed and/or distributed without the express permission of
12  KATLAS Technology.
13 -------------------------------------------------------------------------------
14 
15 
16 */
17 #ifndef USGOV_46373a79c914cc1afc4dcf1f5c83a282d35ddf519feb546780be965072e21ade
18 #define USGOV_46373a79c914cc1afc4dcf1f5c83a282d35ddf519feb546780be965072e21ade
19 
20 #include <string>
21 #include <sstream>
23 #include "convert.h"
24 
25 namespace us { namespace gov {
26 namespace io {
27 
28 using namespace std;
29 
30 struct shell_args final {
32 
33  shell_args(int argc, char** argv);
34  shell_args(const string&args); //Copies *must* not live longer than the original
37 
38  shell_args& operator =(const shell_args&);
39 
40  template<typename T>
41  T next() {
42  if (n>=argc) {
43  return T();
44  }
45  string i=argv[n++];
46  return convert<T>(i);
47  }
48 
49  template<typename T>
50  T next(const T& default_value) {
51  if (n>=argc) {
52  return default_value;
53  }
54  string i=argv[n++];
55  return convert<T>(i);
56  }
57 
58  static hash_t next_token(istream& is);
60  string next_line();
61  int args_left() const;
62  void dump(const string& prefix, ostream&os) const;
63  void dump(ostream&os) const;
64 
65  bool del;
66  int argc;
67  char** argv;
68  int n{1};
69 };
70 
71 }
72 }}
73 
74 #endif
us::gov::io::shell_args::del
bool del
Definition: shell_args.h:65
us::gov::io::shell_args::dump
void dump(const string &prefix, ostream &os) const
us::gov::cash::hash_t
hasher_t::value_type hash_t
Definition: app.h:55
LGAS
#define LGAS
Definition: config.h:23
us::gov::io::shell_args::next_token
hash_t next_token()
convert.h
cfg0.h
us::gov::io::shell_args::n
int n
Definition: shell_args.h:68
us
Definition: daemon.h:22
us::gov::io::shell_args::next_line
string next_line()
shell_args.h
us::gov::crypto::ripemd160::value_type
Definition: ripemd160.h:38
us::gov::io::shell_args::next_token
static hash_t next_token(istream &is)
us::gov::io::shell_args::shell_args
shell_args(const string &args)
c
us::gov::io::shell_args c
Definition: shell_args.cpp:24
us::gov::io::shell_args::~shell_args
~shell_args()
us::gov::io::shell_args::shell_args
shell_args(const shell_args &)
us::gov::io::shell_args::dump
void dump(ostream &os) const
us::gov::io::shell_args::argc
int argc
Definition: shell_args.h:66
us::gov::io::shell_args::argv
char ** argv
Definition: shell_args.h:67
us::gov::io
Definition: cfg.h:26
ripemd160.h
us::gov::io::shell_args
Definition: shell_args.h:30
us::gov::io::shell_args::next
T next(const T &default_value)
Definition: shell_args.h:50
us::gov::io::shell_args::args_left
int args_left() const
std
Definition: app.h:380
us::gov::io::shell_args::shell_args
shell_args(int argc, char **argv)
config.h
us::gov::io::shell_args::next
T next()
Definition: shell_args.h:41
us::gov::io::shell_args::hash_t
crypto::ripemd160::value_type hash_t
Definition: shell_args.h:31
UGAS
#define UGAS
Definition: config.h:22