The JShell clas can be used to interact with the shell via I/O streams.  
 More...
#include <JShell.hh>
 | 
| void  | execute (const char *path, const char *arg0, const char *arg1=(char *) NULL, const char *arg2=(char *) NULL, const char *arg3=(char *) NULL, const char *arg4=(char *) NULL, const char *arg5=(char *) NULL, const char *arg6=(char *) NULL, const char *arg7=(char *) NULL, const char *arg8=(char *) NULL, const char *arg9=(char *) NULL) | 
|   | Execute command.  More...
  | 
|   | 
| virtual int_type  | underflow () | 
|   | Check underflow.  More...
  | 
|   | 
| bool  | in_avail (JTimeval timeout=JTimeval::min()) const  | 
|   | Check availability of input.  More...
  | 
|   | 
| virtual int_type  | overflow (int_type c) | 
|   | Check overflow.  More...
  | 
|   | 
| virtual int  | sync () | 
|   | Synchronise buffer.  More...
  | 
|   | 
| bool  | out_avail (JTimeval timeout=JTimeval::min()) const  | 
|   | Check availability of output.  More...
  | 
|   | 
| int  | flush () | 
|   | Flush internal buffer.  More...
  | 
|   | 
The JShell clas can be used to interact with the shell via I/O streams. 
Definition at line 32 of file JShell.hh.
 
  
  
      
        
          | JSYSTEM::JShell::JShell  | 
          ( | 
          const std::size_t  | 
          size = 65536 | ) | 
           | 
         
       
   | 
  
inline   | 
  
 
Constructor. 
- Parameters
 - 
  
    | size | size of internal buffer  | 
  
   
Definition at line 47 of file JShell.hh.
   55       static_cast<ostream&
>(*this) << 
"set prompt=" << 
prompt << endl;
 
   56       static_cast<ostream&
>(*this) << 
"echo hello"            << endl;
 
int flush()
Flush internal buffer. 
 
JFileStream(const JAbstractFile &in, const JAbstractFile &out, const std::size_t size=65536)
Constructor. 
 
JProcess()
Default constructor. 
 
 
 
 
  
  
      
        
          | JSYSTEM::JShell::~JShell  | 
          ( | 
           | ) | 
           | 
         
       
   | 
  
inline   | 
  
 
Destructor. 
Definition at line 65 of file JShell.hh.
void exit()
Exit this shell. 
 
 
 
 
  
  
      
        
          | static JShell& JSYSTEM::JShell::getInstance  | 
          ( | 
           | ) | 
           | 
         
       
   | 
  
inlinestatic   | 
  
 
Get reference to unique instance of this class object. 
- Returns
 - reference to this class object 
 
Definition at line 76 of file JShell.hh.
The JShell clas can be used to interact with the shell via I/O streams. 
 
 
 
 
  
  
      
        
          | const std::string& JSYSTEM::JShell::getPrompt  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
inline   | 
  
 
Get prompt. 
- Returns
 - prompt 
 
Definition at line 89 of file JShell.hh.
 
 
template<class T > 
  
  
      
        
          | bool JSYSTEM::JShell::get  | 
          ( | 
          T &  | 
          value | ) | 
           | 
         
       
   | 
  
inline   | 
  
 
Get value. 
Note that
- in case of success, the input stream is flushed; and
 
- in case of failure, the input stream is cleared and flushed.
 
- Parameters
 - 
  
  
 
- Returns
 - true if valid; else false 
 
Definition at line 106 of file JShell.hh.
  110       if (*
this >> value) {
 
  118         static_cast<istream&
>(*this).clear();
 
int flush()
Flush internal buffer. 
 
 
 
 
  
  
      
        
          | bool JSYSTEM::JShell::getline  | 
          ( | 
          std::string &  | 
          buffer,  | 
         
        
           | 
           | 
          const char  | 
          eol = '\n'  | 
         
        
           | 
          ) | 
           |  | 
         
       
   | 
  
inline   | 
  
 
Get line of text. 
Extracts characters from this shell and stores them into the given buffer until the end of line character is found or the prompt is read.
- Parameters
 - 
  
    | buffer | buffer  | 
    | eol | end of line character  | 
  
   
- Returns
 - true if valid; else false 
 
Definition at line 137 of file JShell.hh.
  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();
 
virtual bool getStatus() const 
Get status of this shell. 
 
 
 
 
  
  
      
        
          | JShell& JSYSTEM::JShell::flush  | 
          ( | 
          std::ostream &  | 
          out = null | ) | 
           | 
         
       
   | 
  
inline   | 
  
 
Extracts characters from this shell and flush them to the given output stream until the prompt is read. 
- Parameters
 - 
  
  
 
- Returns
 - this shell 
 
Definition at line 184 of file JShell.hh.
  188       for (
string buffer; this->
getline(buffer); ) {
 
  189         out << buffer << endl;
 
bool getline(std::string &buffer, const char eol= '\n')
Get line of text. 
 
 
 
 
  
  
      
        
          | virtual bool JSYSTEM::JShell::getStatus  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
inlinevirtual   | 
  
 
Get status of this shell. 
- Returns
 - status of this shell 
 
Implements JLANG::JAbstractObjectStatus.
Definition at line 201 of file JShell.hh.
  203       return ((
bool) static_cast<const std::ostream&>(*
this) && 
 
  204               (
bool) static_cast<const std::istream&>(*
this));
 
 
 
 
  
  
      
        
          | void JSYSTEM::JShell::exit  | 
          ( | 
           | ) | 
           | 
         
       
   | 
  
inline   | 
  
 
Exit this shell. 
Definition at line 211 of file JShell.hh.
  215       static_cast<ostream&
>(*this) << 
"exit" << endl;
 
 
 
 
Get pointer to input stream buffer connected to the normal output stream. 
- Parameters
 - 
  
    | size | size of internal buffers  | 
  
   
- Returns
 - pointer input stream buffer 
 
Definition at line 86 of file JProcess.hh.
   89         gOut = 
new JFileInputStreamBuffer(
out, size);
 
JFileInputStreamBuffer * gOut
 
 
 
 
Get pointer to input stream buffer connected to the error output stream. 
- Parameters
 - 
  
    | size | size of internal buffers  | 
  
   
- Returns
 - pointer to input stream buffer 
 
Definition at line 102 of file JProcess.hh.
  105         gErr = 
new JFileInputStreamBuffer(
err, size);
 
JFileInputStreamBuffer * gErr
 
 
 
 
Get pointer to output stream buffer connected to the normal input stream. 
- Parameters
 - 
  
    | size | size of internal buffers  | 
  
   
- Returns
 - pointer to output stream buffer 
 
Definition at line 118 of file JProcess.hh.
  121         gIn = 
new JFileOutputStreamBuffer(
in, size);
 
JFileOutputStreamBuffer * gIn
 
 
 
 
  
  
      
        
          | void JSYSTEM::JProcess::execute  | 
          ( | 
          const char *  | 
          path,  | 
         
        
           | 
           | 
          const char *  | 
          arg0,  | 
         
        
           | 
           | 
          const char *  | 
          arg1 = (char*) NULL,  | 
         
        
           | 
           | 
          const char *  | 
          arg2 = (char*) NULL,  | 
         
        
           | 
           | 
          const char *  | 
          arg3 = (char*) NULL,  | 
         
        
           | 
           | 
          const char *  | 
          arg4 = (char*) NULL,  | 
         
        
           | 
           | 
          const char *  | 
          arg5 = (char*) NULL,  | 
         
        
           | 
           | 
          const char *  | 
          arg6 = (char*) NULL,  | 
         
        
           | 
           | 
          const char *  | 
          arg7 = (char*) NULL,  | 
         
        
           | 
           | 
          const char *  | 
          arg8 = (char*) NULL,  | 
         
        
           | 
           | 
          const char *  | 
          arg9 = (char*) NULL  | 
         
        
           | 
          ) | 
           |  | 
         
       
   | 
  
inlineprotectedinherited   | 
  
 
Execute command. 
- Parameters
 - 
  
    | path | path  | 
    | arg0 | comma separted argument list  | 
    | arg1 | comma separted argument list  | 
    | arg2 | comma separted argument list  | 
    | arg3 | comma separted argument list  | 
    | arg4 | comma separted argument list  | 
    | arg5 | comma separted argument list  | 
    | arg6 | comma separted argument list  | 
    | arg7 | comma separted argument list  | 
    | arg8 | comma separted argument list  | 
    | arg9 | comma separted argument list  | 
  
   
Definition at line 143 of file JProcess.hh.
  159       if (pipe(pipe_stdin))  { 
throw JPipeOpenException(
"Error at pipe of standard input.");  }
 
  160       if (pipe(pipe_stdout)) { 
throw JPipeOpenException(
"Error at pipe of standard output."); }
 
  161       if (pipe(pipe_stderr)) { 
throw JPipeOpenException(
"Error at pipe of standard error.");  }
 
  163       const pid_t pid = fork();
 
  169         throw JForkException(
"JProcess::fork() failed");
 
  175         close(pipe_stdin [1]);
 
  176         if (dup2 (pipe_stdin [0], STDIN_FILENO)  == -1) { JSystemException(
"dup2-stdin"); }
 
  178         close(pipe_stdout[0]);
 
  179         if (dup2 (pipe_stdout[1], STDOUT_FILENO) == -1) { JSystemException(
"dup2-stdout"); }
 
  181         close(pipe_stdout[0]);
 
  182         if (dup2 (pipe_stdout[1], STDERR_FILENO) == -1) { JSystemException(
"dup2-stderr"); }
 
  184         execl(path, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, (
char*) NULL);
 
  186         throw JSystemException(path);
 
  193         out = pipe_stdout[0];
 
  194         err = pipe_stderr[0];
 
  196         close(pipe_stdin [0]);
 
  197         close(pipe_stdout[1]);
 
  198         close(pipe_stderr[1]);
 
void close(std::istream *pf)
Close file. 
 
 
 
 
  
  
      
        
          | virtual int_type JLANG::JFileInputStreamBuffer::underflow  | 
          ( | 
           | ) | 
           | 
         
       
   | 
  
inlinevirtualinherited   | 
  
 
Check underflow. 
This method reads as many bytes as possible.
- Returns
 - first character if OK; else EOF 
 
Definition at line 60 of file JFileStreamBuffer.hh.
   62       if (gptr() >= egptr()) {
 
   64         char* __begin = this->data();
 
   66         if (eback() == __begin) { 
 
   75         const size_t len = 
in.
read(__begin, this->size() - (__begin - this->data()));
 
   78           setg(this->data(), __begin, __begin + len);
 
   80           return traits_type::eof();
 
virtual int read(char *buffer, const int length)
Read data from file. 
 
 
 
 
Check availability of input. 
This method returns true if at least one byte can be read without blocking.
- Parameters
 - 
  
  
 
- Returns
 - true if ready to read; else false 
 
Definition at line 94 of file JFileStreamBuffer.hh.
Auxiliary class for method select. 
 
bool in_avail(JTimeval timeout=JTimeval::min())
Check availability of input. 
 
 
 
 
Check overflow. 
This method writes one byte if possible.
- Parameters
 - 
  
  
 
- Returns
 - c if OK; else EOF 
 
Definition at line 153 of file JFileStreamBuffer.hh.
  155       if (c != traits_type::eof()) {
 
  161         if (
flush() == traits_type::eof()) {
 
  162           return traits_type::eof();
 
int flush()
Flush internal buffer. 
 
 
 
 
  
  
      
        
          | virtual int JLANG::JFileOutputStreamBuffer::sync  | 
          ( | 
           | ) | 
           | 
         
       
   | 
  
inlinevirtualinherited   | 
  
 
Synchronise buffer. 
Definition at line 173 of file JFileStreamBuffer.hh.
  175       if (
flush() == traits_type::eof())
 
int flush()
Flush internal buffer. 
 
 
 
 
Check availability of output. 
This method returns true if at least one byte can be written without blocking.
- Parameters
 - 
  
  
 
- Returns
 - true if ready to write; else false 
 
Definition at line 189 of file JFileStreamBuffer.hh.
bool out_avail(JTimeval timeout=JTimeval::min())
Check availability of output. 
 
Auxiliary class for method select. 
 
 
 
 
  
  
      
        
          | int JLANG::JFileOutputStreamBuffer::flush  | 
          ( | 
           | ) | 
           | 
         
       
   | 
  
inlineprotectedinherited   | 
  
 
Flush internal buffer. 
Definition at line 198 of file JFileStreamBuffer.hh.
  200       const int len = pptr() - pbase();
 
  204         if (
out.
write(this->data(), len) != len) {
 
  205           return traits_type::eof();
 
virtual int write(const char *buffer, const int length)
Write data to file. 
 
 
 
 
  
  
      
        
          | JLANG::JAbstractObjectStatus::operator bool  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
inlineinherited   | 
  
 
Type conversion operator. 
- Returns
 - status of this object 
 
Definition at line 33 of file JAbstractObjectStatus.hh.
virtual bool getStatus() const =0
Get status of object. 
 
 
 
 
  
  
      
        
          | bool JLANG::JAbstractObjectStatus::operator!  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
inlineinherited   | 
  
 
Negated status of this object. 
- Returns
 - negated status of this object 
 
Definition at line 44 of file JAbstractObjectStatus.hh.
virtual bool getStatus() const =0
Get status of object. 
 
 
 
 
  
  
      
        
          | std::string JSYSTEM::JShell::prompt | 
         
       
   | 
  
protected   | 
  
 
 
  
  
      
        
          | int JSYSTEM::JProcess::out | 
         
       
   | 
  
protectedinherited   | 
  
 
 
  
  
      
        
          | int JSYSTEM::JProcess::err | 
         
       
   | 
  
protectedinherited   | 
  
 
 
  
  
      
        
          | int JSYSTEM::JProcess::in | 
         
       
   | 
  
protectedinherited   | 
  
 
 
  
  
      
        
          | JFile JLANG::JFileInputStreamBuffer::in | 
         
       
   | 
  
protectedinherited   | 
  
 
 
  
  
      
        
          | std::size_t JLANG::JFileInputStreamBuffer::memory | 
         
       
   | 
  
protectedinherited   | 
  
 
 
  
  
      
        
          | JFile JLANG::JFileOutputStreamBuffer::out | 
         
       
   | 
  
protectedinherited   | 
  
 
 
The documentation for this class was generated from the following file: