1#ifndef __JSYSTEM__JSHELL__
2#define __JSYSTEM__JSHELL__
39 using std::istream::get;
40 using JAbstractObjectStatus::operator bool;
47 JShell(
const std::size_t size = 65536) :
55 static_cast<ostream&
>(*this) <<
"set prompt=" <<
prompt << endl;
56 static_cast<ostream&
>(*this) <<
"echo hello" << endl;
110 if (*
this >> value) {
118 static_cast<istream&
>(*this).clear();
137 inline bool getline(std::string& buffer,
const char eol =
'\n')
145 const int c = this->
get();
147 if (c == streambuf::traits_type::eof()) {
149 return !buffer.empty();
151 }
else if (c == eol) {
159 if (buffer.size() >=
prompt.size()) {
161 const size_t pos = buffer.size() - this->
prompt.size();
163 if (buffer.substr(pos) == this->prompt) {
167 return !buffer.empty();
188 for (
string buffer; this->
getline(buffer); ) {
189 out << buffer << endl;
203 return ((
bool)
static_cast<const std::ostream&
>(*
this) &&
204 (
bool)
static_cast<const std::istream&
>(*
this));
215 static_cast<ostream&
>(*this) <<
"exit" << endl;
int flush()
Flush internal buffer.
Streaming of input and output.
Streaming of input and output from Linux command.
The JShell clas can be used to interact with the shell via I/O streams.
JShell & operator=(JShell &&)
JShell & operator=(const JShell &)
JShell & flush(std::ostream &out=null)
Extracts characters from this shell and flush them to the given output stream until the prompt is rea...
void exit()
Exit this shell.
static JShell & getInstance()
Get reference to unique instance of this class object.
JShell(const std::size_t size=65536)
Constructor.
const std::string & getPrompt() const
Get prompt.
bool getline(std::string &buffer, const char eol='\n')
Get line of text.
bool get(T &value)
Get value.
virtual bool getStatus() const override
Get status of this shell.
static JNullStream null
Null I/O stream.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for operating system calls.
Interface for status of object.