rllib  1
Public Member Functions | Public Attributes | Private Attributes
rlInterpreter Class Reference

#include <rlinterpreter.h>

List of all members.

Public Member Functions

 rlInterpreter (int Maxline=rl_PRINTF_LENGTH)
virtual ~rlInterpreter ()
int isCommand (const char *command)
void copyStringParam (char *destination, int index)
int maxchar ()

Public Attributes

char * line

Private Attributes

int maxline

Detailed Description

A class for interpreting text.

Definition at line 24 of file rlinterpreter.h.


Constructor & Destructor Documentation

rlInterpreter::rlInterpreter ( int  Maxline = rl_PRINTF_LENGTH)

Definition at line 19 of file rlinterpreter.cpp.

{
  line = NULL;
  maxline = Maxline;
  if(maxline <= 0) return;
  line = new char[maxline];
}
rlInterpreter::~rlInterpreter ( ) [virtual]

Definition at line 27 of file rlinterpreter.cpp.

{
  //if(line != NULL) delete [] line;
}

Member Function Documentation

void rlInterpreter::copyStringParam ( char *  destination,
int  index 
)

Definition at line 43 of file rlinterpreter.cpp.

{
  int iparen = 0;
  int i = 0;
  int ndest;
  *destination = '\0';
  // find " number index*2
  while(line[i] != '\0')
  {
    if(line[i] == '\"' && (i > 0 || line[i-1] != '\\')) iparen++;
    if(iparen == (2*index + 1))
    {
      ndest = 0;
      i++;
      while(line[i] != '\0' && (line[i] != '\"' && line[i-1] != '\\'))
      {
        if(ndest >= maxline-1)
        {
          *destination = '\0';
          return;
        }
        *destination++ = line[i++];
        ndest++;
      }
      *destination = '\0';
      return;
    }
    i++;
  }
}
int rlInterpreter::isCommand ( const char *  command)

Definition at line 32 of file rlinterpreter.cpp.

{
  int i = 0;
  while(command[i] != '\0')
  {
    if(command[i] != line[i]) return 0;
    i++;
  }
  return 1;
}
int rlInterpreter::maxchar ( )

Definition at line 74 of file rlinterpreter.cpp.

{
  return maxline-1;
}

Member Data Documentation

Definition at line 30 of file rlinterpreter.h.

int rlInterpreter::maxline [private]

Definition at line 36 of file rlinterpreter.h.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines