Bayonne2 / Common C++ 2 Framework
|
A derivable class to hold compiled script images for active processes. More...
#include <script3.h>
Data Structures | |
struct | _merge |
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 | |
char * | getToken (char **pre=NULL) |
virtual void | fastBranch (ScriptInterp *interp) |
Fast branch linkback code. More... | |
ScriptCompiler (ScriptCommand *cmdset, const char *symset) | |
Construct a new working image. More... | |
Name * | include (const char *name) |
A method to invoke the script compiler to include a script only if it has not been included already. More... | |
int | compile (const char *file) |
The script compiler itself. More... | |
int | compile (const char *file, char *name) |
Compile a script from disk and give it a different internal "name" as passed. More... | |
int | compileDefinitions (const char *file) |
Compile a defintions library, commonly used for remapping tokens to macros. More... | |
int | compile (std::istream *stream, char *name, const char *file=NULL) |
Compile an open stream object into a script. More... | |
void | commit (void) |
Used in the derived constructor to "commit" the current image for new processes. More... | |
virtual const char * | getDefined (const char *token) |
Used to process '$const' inserts. More... | |
const char * | preproc (const char *token) |
Check for special preprocessor token. More... | |
std::istream * | getSource (void) |
Used by embedded interpreters to fetch script from the current source file. More... | |
void * | getMemory (size_t size) |
Get memory for assoc data... More... | |
const char * | dupString (const char *str) |
Duplicate string... More... | |
Name * | getCurrent (void) |
Get current entity being compiled... More... | |
void | addSelect (Line *line) |
Add a select record to the currently compiled script. More... | |
void | addRegistration (Line *line) |
Add a registration record to the compiled script. More... | |
ScriptRegistry * | getRegistry (void) |
Get a registration record to use. More... | |
void | addRoute (Line *line, unsigned pri) |
Add an advertised route in a priority slot. More... | |
Line * | getSelect (void) |
Get the selection list from the image. More... | |
Line * | getRegistration (void) |
Get the registration list from the image. More... | |
Line * | getRoute (unsigned pri) |
Get an advertised priority record from the image. More... | |
unsigned long | getInstance (void) |
Get the session instance of the image. More... | |
void | purge (void) |
Purge and reload the script image workspace. More... | |
void | load (Initial *ilist) |
Used by a derived constructor to load an initialization list. 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 | initial (const char *keyword, const char *value, unsigned size=0) |
Used to load a single initialization list entry. More... | |
virtual Name * | getScript (const char *name) |
Fetch named script. More... | |
ScriptCommand * | getCommand (void) |
Get the command object associated with the image. More... | |
bool | isRipple (void) |
Get the ripple flag for the current image. More... | |
unsigned | gather (const char *suffix, Name **array, unsigned size) |
Fetch list of relational scripts. More... | |
void | incRef (void) |
inc the reference count. More... | |
void | decRef (void) |
dec the reference count. More... | |
bool | isRef (void) |
See if the image is referenced... More... | |
ScriptImage * | getActive (void) |
Get the active image from command. More... | |
unsigned | getIndex (char **data, unsigned max) |
Get an index array of ALL keywords that are stored by the current keydata 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... | |
unsigned | getCount (void) |
Get the count of keyword indexes that are actually available so one can allocate a table to receive getIndex. 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 * | getPointer (const char *id) const |
void | setPointer (const char *id, void *data) |
Static Public Member Functions | |
static bool | commit (Symbol *sym, const char *value) |
static unsigned | count (Symbol *sym) |
static unsigned | getIndex (const char *id) |
static void | end (void) |
static member to end keydata i/o allocations. More... | |
static bool | isScript (Name *scr) |
static bool | isSymbol (const char *id) |
static bool | use (const char *name) |
static Symbol * | deref (Symbol *sym) |
static bool | append (Symbol *sym, const char *value) |
static bool | symindex (Symbol *sym, short offset) |
static const char * | extract (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 size_t | pagesize |
static bool | fastStart |
static bool | useBigmem |
static unsigned | fastStepping |
static unsigned | autoStepping |
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 Types | |
typedef struct ost::ScriptCompiler::_merge | merge_t |
Protected Member Functions | |
virtual bool | checkSegment (Name *scr) |
Method | getHandler (const char *keyword) |
Get the interpreter method pointer for a given keyword. 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 | 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... | |
void | clear (void) |
Protected Attributes | |
std::ifstream | scrSource |
std::istream * | scrStream |
char * | buffer |
unsigned | bufsize |
char * | bp |
bool | quote |
unsigned | paren |
unsigned | inccount |
const char * | incfiles [256] |
merge_t * | mlist |
ScriptCommand * | cmds |
unsigned | refcount |
Name * | index [KEYDATA_INDEX_SIZE+1] |
Name * | current |
Line * | select |
Line * | selecting |
Line * | registration |
Line * | advertising [16] |
Mutex | duplock |
ScriptObject * | objects |
unsigned long | instance |
ost::ScriptImage::InitialList * | ilist |
Static Protected Attributes | |
static unsigned long | serial |
static Test * | test |
static Fun * | ifun |
Friends | |
class __EXPORT | ScriptInterp |
A derivable class to hold compiled script images for active processes.
This includes the script image compiler itself. Typically, a script is compiled one file at a time from a directory, and the committed, during the constructor in a derived class.
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
protected |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
ost::ScriptCompiler::ScriptCompiler | ( | ScriptCommand * | cmdset, |
const char * | symset | ||
) |
Construct a new working image.
This must be derived to an application specific compiler that can scan directories and invoke the compiler as needed.
cmdset | of keyword table object used. |
symset | of symbols to set. |
|
staticinherited |
|
staticinherited |
|
inherited |
Add a registration record to the compiled script.
line | statement to add to list. |
|
inherited |
Add an advertised route in a priority slot.
line | statement to add to list. |
pri | of route to add to. |
|
inherited |
Add a select record to the currently compiled script.
line | statement to add to list. |
|
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 |
|
protectedvirtual |
|
protectedinherited |
Clean for memory cleanup before exiting.
|
staticinherited |
|
protectedinherited |
|
inherited |
Clear all values associated with a given keyword.
This does not de-allocate the keyword from memory, however.
|
staticinherited |
void ost::ScriptCompiler::commit | ( | void | ) |
Used in the derived constructor to "commit" the current image for new processes.
This is usually the last statement in the derived constructor.
int ost::ScriptCompiler::compile | ( | const char * | file | ) |
The script compiler itself.
This linearly compiles a Bayonne script file that is specified. Normally used along with a dir scanner in the constructor.
file | name of script file to compile. |
int ost::ScriptCompiler::compile | ( | const char * | file, |
char * | name | ||
) |
Compile a script from disk and give it a different internal "name" as passed.
file | name of script file to compile. |
name | of script to compile under. |
int ost::ScriptCompiler::compile | ( | std::istream * | stream, |
char * | name, | ||
const char * | file = NULL |
||
) |
Compile an open stream object into a script.
stream | object to use. |
name | of script save under. |
file | name to use in object. |
int ost::ScriptCompiler::compileDefinitions | ( | const char * | file | ) |
Compile a defintions library, commonly used for remapping tokens to macros.
file | name of defintions file to compile. |
|
staticinherited |
|
inlineinherited |
|
inherited |
Duplicate string...
string | requested. |
|
staticinherited |
static member to end keydata i/o allocations.
|
staticinherited |
|
virtual |
Fast branch linkback code.
Reimplemented from ost::ScriptImage.
|
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. |
|
inherited |
Fetch list of relational scripts.
suffix | extension of scripts being fetched. |
array | of script objects gathered from image. |
size | limit of array to gather. |
|
inlineinherited |
Get the active image from command.
Useful when compiling.
|
inherited |
Get a bool value.
sym | keyword name. |
|
inlineinherited |
|
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. |
|
inherited |
Get the count of keyword indexes that are actually available so one can allocate a table to receive getIndex.
|
inlineinherited |
|
virtual |
Used to process '$const' inserts.
token | string being substituted. |
|
inherited |
Get a floating value.
sym | keyword name. |
default | if not set. |
|
inherited |
Get the first data value for a given keyword.
This will typically be the /etc
set global default.
sym | keyword symbol name. |
|
inlineprotectedinherited |
|
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. |
|
inlineinherited |
|
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. |
|
virtualinherited |
Get memory for assoc data...
size | of memory request. |
Implements Assoc.
|
inlineinherited |
|
inherited |
|
inlineinherited |
|
inherited |
Get a registration record to use.
|
inlineinherited |
|
virtualinherited |
Fetch named script.
name | of script to find. |
|
inlineinherited |
|
inline |
|
inherited |
Get a string value, with an optional default if missing.
sym | keyword name. |
default | if not present. |
|
protectedinherited |
char* ost::ScriptCompiler::getToken | ( | char ** | pre = NULL | ) |
Name* ost::ScriptCompiler::include | ( | const char * | name | ) |
A method to invoke the script compiler to include a script only if it has not been included already.
name | of script file to compile. |
|
inlineinherited |
|
inherited |
Used to load a single initialization list entry.
keyword | name to initialize. |
value | of keyword. |
size | of keyword data field. |
|
staticinherited |
|
inherited |
Find if a given key exists.
sym | keyword to find. |
|
staticinherited |
|
inlineinherited |
|
inlineinherited |
|
staticinherited |
|
staticinherited |
|
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. |
|
inherited |
Used by a derived constructor to load an initialization list.
ilist | initialization list of symbol pairs 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 |
const char* ost::ScriptCompiler::preproc | ( | const char * | token | ) |
Check for special preprocessor token.
token | name of keyword to check. |
|
inherited |
Purge and reload the script image workspace.
|
inherited |
|
inherited |
|
staticinherited |
|
staticinherited |
|
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 |
|
friend |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
inherited |
|
inherited |
|
protectedinherited |
|
staticprotectedinherited |