Bayonne2 / Common C++ 2 Framework
|
This class holds the bound keyword set for a given Bayonne style script interpreter. More...
#include <script3.h>
Data Structures | |
struct | _keyword |
Public Types | |
enum | scrAccess { scrPUBLIC, scrPROTECTED, scrPRIVATE, scrFUNCTION, scrLOCAL } |
typedef enum scrAccess | scrAccess |
enum | symType { symNORMAL = 0, symCONST, symDYNAMIC, symFIFO, symSEQUENCE, symSTACK, symCOUNTER, symPOINTER, symREF, symARRAY, symASSOC, symINITIAL, symNUMBER, symLOCK, symPROPERTY, symORIGINAL, symMODIFIED, symTIMER, symBOOL } |
typedef enum symType | symType |
typedef bool(ScriptInterp::* | Method )(void) |
typedef const char *(ScriptCommand::* | Check )(Line *line, ScriptImage *img) |
typedef bool(* | Cond )(ScriptInterp *interp, const char *v) |
typedef long(* | Function )(long *args, unsigned prec) |
typedef const char *(* | Meta )(ScriptInterp *interp, const char *token) |
typedef const char *(* | Parse )(ScriptCompiler *img, const char *token) |
typedef void(* | Init )(void) |
typedef struct ost::Script::_symbol | Symbol |
typedef struct ost::Script::_array | Array |
Public Member Functions | |
virtual bool | isInput (Line *line) |
Checks if the line statement is an input statement. More... | |
Method | getHandler (const char *keyword) |
Get the method handler associated with a given keyword. More... | |
bool | control (char **args) |
Issue a control event against current image for attached modules until claimed. More... | |
ScriptImage * | getActive (void) |
Get the active script. More... | |
const char * | getTrapName (unsigned id) |
Get the name of a trap from it's id. More... | |
void | aliasModule (const char *id, const char *use) |
Alias use modules... More... | |
virtual void | errlog (const char *level, const char *text) |
Server level logging interface override. More... | |
ScriptCommand () | |
Create an initialized script command box. More... | |
ScriptCommand (ScriptCommand *ini) | |
Create a ScriptCommand box initialized from another. More... | |
unsigned | getActivity (void) |
Get activity counter. More... | |
unsigned | getIndex (char **data, unsigned max) |
Get an index array of ALL keywords that are stored by the current keydata object. More... | |
void | load (const char *keypath) |
Load additional key values into the currrent object from the specfied config source (a config file/section pair). More... | |
void | load (Define *pairs) |
Load default keywords into the current object. More... | |
void | loadPrefix (const char *prefix, const char *keypath) |
Load additional key values into the currrent object from the specfied config source (a config file/section pair). More... | |
void | loadFile (const char *filepath, const char *keys=NULL, const char *pre=NULL) |
Load additional keys into the current object using a real filename that is directly passed rather than a computed key path. More... | |
void | unlink (void) |
Unlink the keydata object from the cache file stream. More... | |
int | getCount (const char *sym) |
Get a count of the number of data "values" that is associated with a specific keyword. More... | |
const char * | getFirst (const char *sym) |
Get the first data value for a given keyword. More... | |
const char * | getLast (const char *sym) |
Get the last (most recently set) value for a given keyword. More... | |
bool | isKey (const char *sym) |
Find if a given key exists. More... | |
const char * | getString (const char *sym, const char *def=NULL) |
Get a string value, with an optional default if missing. More... | |
long | getLong (const char *sym, long def=0) |
Get a long value, with an optional default if missing. More... | |
bool | getBool (const char *key) |
Get a bool value. More... | |
double | getDouble (const char *key, double def=0.) |
Get a floating value. More... | |
void | setValue (const char *sym, const char *data) |
Set (replace) the value of a given keyword. More... | |
const char *const * | getList (const char *sym) |
Return a list of all values set for the given keyword returned in order. More... | |
void | clrValue (const char *sym) |
Clear all values associated with a given keyword. More... | |
const char * | operator[] (const char *keyword) |
A convient notation for accessing the keydata as an associative array of keyword/value pairs through the [] operator. More... | |
void | nameMutex (const char *name) |
Enable setting of mutex name for deadlock debug. More... | |
void | enterMutex (void) |
Entering a Mutex locks the mutex for the current thread. More... | |
void | enter (void) |
Future abi will use enter/leave/test members. More... | |
void | leave (void) |
Future abi will use enter/leave/test members. More... | |
bool | test (void) |
Future abi will use enter/leave/test members. More... | |
bool | tryEnterMutex (void) |
Tries to lock the mutex for the current thread. More... | |
void | leaveMutex (void) |
Leaving a mutex frees that mutex for use by another thread. More... | |
Static Public Member Functions | |
static const char * | findKeyword (Line *line, const char *keyword) |
Test for a specific keyword. More... | |
static const char * | findKeyword (ScriptImage *img, Line *line, const char *keyword) |
Test for a specific keyword or keydata filler. More... | |
static bool | useKeywords (Line *line, const char *list) |
Test current command against a list of valid keywords. More... | |
static unsigned | getCount (Line *line) |
Count non-keyword arguments. More... | |
static const char * | getMember (Line *line) |
Get the member id code of a line. More... | |
static void | end (void) |
static member to end keydata i/o allocations. More... | |
static void | setDebug (bool mode) |
Enable or disable deadlock debugging. More... | |
static bool | isScript (Name *scr) |
static bool | isSymbol (const char *id) |
static bool | use (const char *name) |
static unsigned | getIndex (const char *id) |
static Symbol * | deref (Symbol *sym) |
static bool | commit (Symbol *sym, const char *value) |
static bool | append (Symbol *sym, const char *value) |
static bool | symindex (Symbol *sym, short offset) |
static const char * | extract (Symbol *sym) |
static unsigned | count (Symbol *sym) |
static unsigned | storage (Symbol *sym) |
static void | clear (Symbol *sym) |
static void | addFunction (const char *name, unsigned count, Function i) |
static void | addConditional (const char *name, Cond test) |
static bool | isPrivate (Name *scr) |
static bool | isFunction (Name *scr) |
Data Fields | |
class __EXPORT | Line |
class __EXPORT | Name |
Static Public Attributes | |
static bool | fastStart |
static bool | useBigmem |
static unsigned | fastStepping |
static unsigned | autoStepping |
static size_t | pagesize |
static unsigned | symsize |
static unsigned | symlimit |
static char | decimal |
static bool | use_definitions |
static bool | use_macros |
static bool | use_prefix |
static bool | use_merge |
static bool | use_funcs |
static const char * | plugins |
static const char * | altplugins |
static const char * | access_user |
static const char * | access_pass |
static const char * | access_host |
static bool | exec_funcs |
static const char * | exec_extensions |
static const char * | exec_token |
static const char * | exec_prefix |
static const char * | exit_token |
static const char * | apps_extensions |
static const char * | apps_prefix |
static const char * | etc_prefix |
static const char * | var_prefix |
static const char * | log_prefix |
Protected Member Functions | |
virtual const char * | getExternal (const char *opt) |
bool | isInitial (const char *keyword) |
Fetch whether the given keyword is valid for constructor. More... | |
const char * | check (char *command, Line *line, ScriptImage *img) |
Check keyword syntax. More... | |
virtual unsigned | getTrapId (const char *name) |
Get the trap id number associated with a trap name. More... | |
virtual unsigned long | getTrapDefault (void) |
Get the mask bits for the default script. More... | |
virtual unsigned long | getTrapHandler (Name *script) |
Get the mask bits for a trap "handler". More... | |
virtual unsigned long | getTrapMask (unsigned id) |
Get a trap mask for a given identifer. More... | |
virtual unsigned long | getTrapModifier (const char *name) |
A helper method for the compiler. More... | |
virtual unsigned long | getTrapMask (const char *name) |
A helper method for the compiler used specifically for "^" trap subsection requests. More... | |
void | load (Script::Define *keywords) |
Load a set of keywords into the system keyword table. More... | |
int | trap (const char *name, bool inherited=true) |
Add a trap handler symbolic identity to the keyword table. More... | |
unsigned | getCount (void) |
Get count of active traps. More... | |
bool | isInherited (unsigned id) |
Return true if the trap id is inherited. More... | |
virtual const char * | check (Check chk, Line *line, ScriptImage *img) |
Perform compile time check of a specified symbol. More... | |
Keysym * | getSymbol (const char *sym, bool create) |
virtual void * | first (size_t size) |
Allocate first workspace from paged memory. More... | |
char * | first (char *str) |
Allocate a string from the memory pager pool and copy the string into it's new memory area. More... | |
virtual void * | alloc (size_t size) |
Allocate memory from either the currently active page, or allocate a new page for the object. More... | |
char * | alloc (const char *str) |
Allocate a string from the memory pager pool and copy the string inti it's new memory area. More... | |
void | purge (void) |
purge the current memory pool. More... | |
void | clean (void) |
Clean for memory cleanup before exiting. More... | |
int | getPages (void) |
Return the total number of pages that have been allocated for this memory pool. More... | |
Static Protected Member Functions | |
static bool | hasKeywords (Line *line) |
Test current command to see if it uses keyword syntax. More... | |
static bool | useMember (Line *line, const char *list) |
Check the member list. More... | |
static const char * | getOption (Line *line, unsigned *index) |
Get an option to examine in check routine. More... | |
Protected Attributes | |
bool | ripple |
unsigned | activity |
Static Protected Attributes | |
static ScriptCommand * | runtime |
static Test * | test |
static Fun * | ifun |
Private Types | |
typedef struct ost::ScriptCommand::_keyword | Keyword |
Private Attributes | |
ThreadQueue * | tq |
Keyword * | keywords [KEYDATA_INDEX_SIZE] |
char * | traps [(sizeof(unsigned long)*8)] |
ScriptImage * | active |
unsigned | keyword_count |
unsigned | trap_count |
unsigned long | imask |
unsigned | dbcount |
void * | dbc |
Friends | |
class __EXPORT | ScriptImage |
class __EXPORT | ScriptInterp |
class __EXPORT | ScriptCompiler |
class __EXPORT | ScriptBinder |
This class holds the bound keyword set for a given Bayonne style script interpreter.
Application specific dialects are created by deriving a application specific version of ScriptCommand which then binds application specific keywords and associated methods in an application derived ScriptInterp which are typecast to (scriptmethod_t).
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
private |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
ost::ScriptCommand::ScriptCommand | ( | ) |
Create an initialized script command box.
ost::ScriptCommand::ScriptCommand | ( | ScriptCommand * | ini | ) |
Create a ScriptCommand box initialized from another.
|
staticinherited |
|
staticinherited |
void ost::ScriptCommand::aliasModule | ( | const char * | id, |
const char * | use | ||
) |
Alias use modules...
id | to alias. |
id | to use. |
|
protectedvirtualinherited |
Allocate memory from either the currently active page, or allocate a new page for the object.
size | size of memory to allocate. |
Reimplemented in SharedMemPager.
|
protectedinherited |
Allocate a string from the memory pager pool and copy the string inti it's new memory area.
This checks only the last active page for available space before allocating a new page.
str | string to allocate and copy into paged memory pool. |
|
staticinherited |
|
protected |
Check keyword syntax.
command | name of keyword to check. |
line | pointer to line being compiled. |
img | pointer to image being compiled. |
|
protectedvirtual |
Perform compile time check of a specified symbol.
chk | object pointer to check member function. |
line | pointer to line being checked. |
img | pointer to image being compiled. |
|
protectedinherited |
Clean for memory cleanup before exiting.
|
staticinherited |
|
inherited |
Clear all values associated with a given keyword.
This does not de-allocate the keyword from memory, however.
|
staticinherited |
bool ost::ScriptCommand::control | ( | char ** | args | ) |
Issue a control event against current image for attached modules until claimed.
args | list of control command and arguments. |
|
staticinherited |
|
staticinherited |
static member to end keydata i/o allocations.
|
inlineinherited |
|
inherited |
Entering a Mutex locks the mutex for the current thread.
This also can be done using the ENTER_CRITICAL macro or by using the ++ operator on a mutex.
|
virtual |
Server level logging interface override.
level | of log message. |
text | of message. |
|
staticinherited |
|
static |
Test for a specific keyword.
line | pointer to record to examine in check routine. |
keyword | to search for. |
|
static |
Test for a specific keyword or keydata filler.
script | image for keydata. |
line | pointer to record to examine in check routine. |
keyword | to search for. |
|
protectedvirtualinherited |
Allocate first workspace from paged memory.
This method scans all currently allocated blocks for available space before adding new pages and hence is both slower and more efficient.
size | size of memory to allocate. |
Reimplemented in SharedMemPager.
|
protectedinherited |
Allocate a string from the memory pager pool and copy the string into it's new memory area.
This method allocates memory by first searching for an available page, and then allocating a new page if no space is found.
str | string to allocate and copy into paged memory pool. |
|
inline |
|
inline |
|
inherited |
Get a bool value.
sym | keyword name. |
|
inherited |
Get a count of the number of data "values" that is associated with a specific keyword.
Each value is from an accumulation of "<code>load()</code>" requests.
sym | keyword symbol name. |
|
static |
Count non-keyword arguments.
line | record to examine. |
|
inlineprotected |
|
inherited |
Get a floating value.
sym | keyword name. |
default | if not set. |
|
protectedvirtual |
|
inherited |
Get the first data value for a given keyword.
This will typically be the /etc
set global default.
sym | keyword symbol name. |
Method ost::ScriptCommand::getHandler | ( | const char * | keyword | ) |
Get the method handler associated with a given keyword.
This is used by ScriptImage when compiling.
keyword | to search for. |
|
staticinherited |
|
inherited |
Get an index array of ALL keywords that are stored by the current keydata object.
data | pointer of array to hold keyword strings. |
max | number of entries the array can hold. |
|
inherited |
Get the last (most recently set) value for a given keyword.
This is typically the value actually used.
sym | keyword symbol name. |
|
inherited |
Return a list of all values set for the given keyword returned in order.
sym | keyword name to fetch. |
|
inherited |
Get a long value, with an optional default if missing.
sym | keyword name. |
default | if not present. |
|
static |
Get the member id code of a line.
line | record to examine in check routine. |
|
staticprotected |
Get an option to examine in check routine.
line | record pointer to line to examine. |
index | pointer to index value. Start at 0. |
|
inlineinherited |
|
inherited |
Get a string value, with an optional default if missing.
sym | keyword name. |
default | if not present. |
|
protectedinherited |
|
protectedvirtual |
Get the mask bits for the default script.
|
protectedvirtual |
Get the mask bits for a trap "handler".
|
protectedvirtual |
Get the trap id number associated with a trap name.
name | of trap identifier. |
|
protectedvirtual |
Get a trap mask for a given identifer.
This is a virtual since some derived handlers may manipulate mask bits.
id | number of trap mask. |
|
protectedvirtual |
A helper method for the compiler used specifically for "^" trap subsection requests.
These will occasionally carry different attribute settings.
name | of trap identifier. |
|
protectedvirtual |
A helper method for the compiler.
Converts a named trap into it's bit shifted mask. By making it a virtual, derived dialects can add "aliases" to default trap names.
name | of trap identifier. |
const char* ost::ScriptCommand::getTrapName | ( | unsigned | id | ) |
Get the name of a trap from it's id.
id | of trap. |
|
staticprotected |
Test current command to see if it uses keyword syntax.
line | record to examine in check routine. |
|
staticinherited |
|
protected |
Return true if the trap id is inherited.
|
protected |
Fetch whether the given keyword is valid for constructor.
keyword | to search for. |
|
virtual |
Checks if the line statement is an input statement.
Used in some servers...
line | to examine. |
|
inherited |
Find if a given key exists.
sym | keyword to find. |
|
staticinherited |
|
staticinherited |
|
staticinherited |
|
inlineinherited |
|
inherited |
Leaving a mutex frees that mutex for use by another thread.
If the mutex has been entered (invoked) multiple times (recursivily) by the same thread, then it will need to be exited the same number of instances before it is free for re-use. This operation can also be done using the LEAVE_CRITICAL macro or by the – operator on a mutex.
|
inherited |
Load additional key values into the currrent object from the specfied config source (a config file/section pair).
These values will overlay the current keywords when matches are found. This can be used typically in a derived config object class constructor to first load a /etc
section, and then load a matching user specific entry from ~/.
to override default system values with user specific keyword values.
keypath | (filepath/section) |
|
inherited |
Load default keywords into the current object.
This only loads keyword entries which have not already been defined to reduce memory usage. This form of Load is also commonly used in the constructor of a derived Keydata class.
pairs | list of NULL terminated default keyword/value pairs. |
|
protected |
Load a set of keywords into the system keyword table.
This provides a convenient method of initializing and adding to the keyword indexes.
keywords | defined pair entries to load. |
|
inherited |
Load additional keys into the current object using a real filename that is directly passed rather than a computed key path.
This also uses a [keys] section as passed to the object.
filepath | to load from |
keys | section to parse from, or NULL to parse from head |
pre | optional key prefix |
|
inherited |
Load additional key values into the currrent object from the specfied config source (a config file/section pair).
These values will overlay the current keywords when matches are found. This can be used typically in a derived config object class constructor to first load a /etc
section, and then load a matching user specific entry from ~/.
to override default system values with user specific keyword values. This varient puts a prefix in front of the key name.
prefix | |
keypath | (filepath/section) |
|
inlineinherited |
|
inlineinherited |
|
protectedinherited |
purge the current memory pool.
|
inlinestaticinherited |
|
inherited |
|
staticinherited |
|
staticinherited |
|
inlineinherited |
|
protected |
Add a trap handler symbolic identity to the keyword table.
These are used to handle signal mask coercion and event branch points in the compiler.
name | of requested trap to add to the trap table. |
inherited | status of trap. |
|
inherited |
Tries to lock the mutex for the current thread.
Behaves like enterMutex , except that it doesn't block the calling thread if the mutex is already locked by another thread.
|
inherited |
Unlink the keydata object from the cache file stream.
This should be used if you plan to keepa Keydata object after it is loaded once all keydata objects have been loaded, otherwise the cfgFile stream will remain open. You can also use endKeydata().
|
staticinherited |
|
static |
Test current command against a list of valid keywords.
line | record to examine in check routine. |
list | of =xxx keyword entries. |
|
staticprotected |
Check the member list.
line | record to examine in check routine. |
list | of .members... |
|
friend |
|
friend |
|
friend |
|
friend |
|
private |
|
private |
|
inherited |
|
inherited |
|
staticprotected |
|
private |
|
private |