Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JShell.cc File Reference

Example program to test shell I/O (class JSYSTEM::JShell). More...

#include <string>
#include <iostream>
#include <iomanip>
#include "JSystem/JShell.hh"
#include "JSystem/JSystemToolkit.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to test shell I/O (class JSYSTEM::JShell).

Author
mdejong

Definition in file JShell.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 19 of file JShell.cc.

20{
21 using namespace std;
22
23 int debug;
24
25 try {
26
27 JParser<> zap("Example program to test shell I/O.");
28
29 zap['d'] = make_field(debug) = 3;
30
31 zap(argc, argv);
32 }
33 catch(const exception &error) {
34 FATAL(error.what() << endl);
35 }
36
37
38 using namespace JPP;
39
40 JShell shell;
41
42 for (string buffer; shell; ) {
43
44 cout << "> " << flush;
45
46 getline(cin, buffer);
47
48 if (buffer != "" && buffer != "exit") {
49
50 shell << buffer << endl;
51
52 while (shell.getline(buffer)) {
53 cout << buffer << endl;
54 }
55
56 } else {
57 break;
58 }
59 }
60}
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Utility class to parse command line options.
Definition JParser.hh:1698
The JShell clas can be used to interact with the shell via I/O streams.
Definition JShell.hh:36
bool getline(std::string &buffer, const char eol='\n')
Get line of text.
Definition JShell.hh:137
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition JString.hh:478
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).