rllib  1
Public Member Functions | Public Attributes | Private Attributes | List of all members
rlInterpreter Class Reference

#include <rlinterpreter.h>

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::rlInterpreter ( int  Maxline = rl_PRINTF_LENGTH)

Definition at line 19 of file rlinterpreter.cpp.

20 {
21  line = NULL;
22  maxline = Maxline;
23  if(maxline <= 0) return;
24  line = new char[maxline];
25 }

◆ ~rlInterpreter()

rlInterpreter::~rlInterpreter ( )
virtual

Definition at line 27 of file rlinterpreter.cpp.

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

Member Function Documentation

◆ copyStringParam()

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

Definition at line 43 of file rlinterpreter.cpp.

44 {
45  int iparen = 0;
46  int i = 0;
47  int ndest;
48  *destination = '\0';
49  // find " number index*2
50  while(line[i] != '\0')
51  {
52  if(line[i] == '\"' && (i > 0 || line[i-1] != '\\')) iparen++;
53  if(iparen == (2*index + 1))
54  {
55  ndest = 0;
56  i++;
57  while(line[i] != '\0' && (line[i] != '\"' && line[i-1] != '\\'))
58  {
59  if(ndest >= maxline-1)
60  {
61  *destination = '\0';
62  return;
63  }
64  *destination++ = line[i++];
65  ndest++;
66  }
67  *destination = '\0';
68  return;
69  }
70  i++;
71  }
72 }

◆ isCommand()

int rlInterpreter::isCommand ( const char *  command)

Definition at line 32 of file rlinterpreter.cpp.

33 {
34  int i = 0;
35  while(command[i] != '\0')
36  {
37  if(command[i] != line[i]) return 0;
38  i++;
39  }
40  return 1;
41 }

◆ maxchar()

int rlInterpreter::maxchar ( )

Definition at line 74 of file rlinterpreter.cpp.

75 {
76  return maxline-1;
77 }

Member Data Documentation

◆ line

char* rlInterpreter::line

Definition at line 30 of file rlinterpreter.h.

◆ maxline

int rlInterpreter::maxline
private

Definition at line 36 of file rlinterpreter.h.


The documentation for this class was generated from the following files: