class
ComTerpServ
: public
ComTerp
(Return to index)
extended
ComTerp
that works with buffered IO.
Type:
Instantiable
Base Classes:
public
ComTerp
Derived Classes
Include file:
ComTerp/comterpserv.h
Public:
ComTerpServ
(int bufsize = 1024, int fd = -1)
construct with optional 'bufsize', and on an optional 'fd'.
void
add_defaults
()
add a default list of
ComFunc
objects to this interpreter.
boolean
delete_later
()
void
delete_later
(boolean flag)
postfix_token*
gen_code
(const char*, int& codelen)
generate buffer of length 'codelen' of postfix tokens ready to be converted into
ComValue
objects and executed.
virtual boolean
is_serv
()
flag to test if
ComTerp
or
ComTerpServ
void
load_string
(const char*)
load string to be interpreted into buffer.
void
read_string
(const char*)
load string to be interpreted into buffer, and read postfix tokens from it.
virtual int
run
(boolean one_expr=false, boolean nested=false)
run this interpreter until quit or exit command.
virtual
ComValue
run
(const char*, boolean nested=false)
interpret and return value of expression. 'nested' flag used to indicated nested call to the run() method, to avoid re-initialization.
virtual
ComValue
run
(postfix_token*, int)
execute a buffer of postfix tokens and return the value.
virtual int
runfile
(const char*)
run interpreter on commands read from a file.
~ComTerpServ
()
Protected:
int
_delete_later
int
_fd
FILE*
_fptr
int
_inpos
int
_instat
char*
_instr
int
_logger_mode
int
_outpos
char*
_outstr
static char*
fd_fgets
(char* s, int n, void* serv)
signature like fgets used to explicitly read from an filedescriptor.
static int
fd_fputs
(const char* s, void* serv)
signature like fputs used to explicitly read from an filedescriptor.
static int
s_feof
(void* serv)
signature like feof used to relay end-of-file.
static int
s_ferror
(void* serv)
signature like ferror used to relay error info.
static char*
s_fgets
(char* s, int n, void* serv)
signature like fgets used to copy input from a buffer.
static int
s_fputs
(const char* s, void* serv)
signature like fputs used to copy output back to buffer.
Friend methods:
friend class
ComTerpIOHandler
friend class
ComterpHandler
(more documentation)