|
CLASS moVariableReducerCommand_Basename
NAME
basename - removes the path and optionally the extension
VERSION
Version: 1.2.0
SYNOPSIS
&x24;(basename <param>)
DESCRIPTION
This system instruction returns the basename part of a
filename.
This is the filename including the extension but
without any path information.
Note that a 2nd parameter can be specified. If it matches
the extension, then the extension is removed from the
resulting string.
SEE ALSO
moVariableReducerCommand
COPYRIGHTS
This documentation and the code being documented is proprietary and cannot be duplicated without the express and written consent of Made to Order Software Coporation.
Copyright (c) 1999-2007 by Made to Order Software Corporation
All rights reserved.
AUTHORS
Alexis Wilke, Doug Barbieri
CLASS
moVariableReducerCommand_Capitalize
NAME
capitalize - transpose all lowercase characters to uppercase
VERSION
Version: 1.2.0
SYNOPSIS
&x24;(capitalize <string>,<true|false>)
PARAMETERS
<string> - the string to be capitalized
<true|false> - whether each word should be capitalized
DESCRIPTION
This system instruction transform the string so the very first
letter is an uppercase letter or the first letter of each word
is an uppercase letter.
The second parameter can either be true, false, 0 or 1.
SEE ALSO
moVariableReducerCommand
COPYRIGHTS
This documentation and the code being documented is proprietary and cannot be duplicated without the express and written consent of Made to Order Software Coporation.
Copyright (c) 1999-2007 by Made to Order Software Corporation
All rights reserved.
AUTHORS
Alexis Wilke, Doug Barbieri
CLASS
moVariableReducerCommand_Dirname
NAME
dirname - returns the path in a filename
VERSION
Version: 1.2.0
SYNOPSIS
&x24;(dirname <param>)
DESCRIPTION
This system instruction returns the path defined in a filename.
Note that all [back]slashes at the end of a filename are removed
before the command is applied. This the command dirname applied
to the path a/b/c/ returns /a/b, not /a/b/c.
SEE ALSO
moVariableReducerCommand
COPYRIGHTS
This documentation and the code being documented is proprietary and cannot be duplicated without the express and written consent of Made to Order Software Coporation.
Copyright (c) 1999-2007 by Made to Order Software Corporation
All rights reserved.
AUTHORS
Alexis Wilke, Doug Barbieri
CLASS
moVariableReducerCommand_Echo
NAME
echo - print out the parameters
VERSION
Version: 1.2.0
SYNOPSIS
&x24;(echo <param1>,<param2>,...)
DESCRIPTION
This system instruction uses printf(3C) to print all of its parameters
in the standard output.
SEE ALSO
moVariableReducerCommand
COPYRIGHTS
This documentation and the code being documented is proprietary and cannot be duplicated without the express and written consent of Made to Order Software Coporation.
Copyright (c) 1999-2007 by Made to Order Software Corporation
All rights reserved.
AUTHORS
Alexis Wilke, Doug Barbieri
CLASS
moVariableReducerCommand_Expr
NAME
expr - compute the following expression
VERSION
Version: 1.2.0
SYNOPSIS
&x24;(expr <param>)
DESCRIPTION
This system instruction returns result of the C like expression
defined in <param>. Please see the moExpr for more information
of all the supported expressions and types.
SEE ALSO
moVariableReducerCommand, moExpr
COPYRIGHTS
This documentation and the code being documented is proprietary and cannot be duplicated without the express and written consent of Made to Order Software Coporation.
Copyright (c) 1999-2007 by Made to Order Software Corporation
All rights reserved.
AUTHORS
Alexis Wilke, Doug Barbieri
CLASS
moVariableReducerCommand_Extension
NAME
extension - returns the filename extension
VERSION
Version: 1.2.0
SYNOPSIS
&x24;(extension <param>)
DESCRIPTION
This system instruction returns the extension part of a
filename.
Note that the point is included in the result.
SEE ALSO
moVariableReducerCommand
COPYRIGHTS
This documentation and the code being documented is proprietary and cannot be duplicated without the express and written consent of Made to Order Software Coporation.
Copyright (c) 1999-2007 by Made to Order Software Corporation
All rights reserved.
AUTHORS
Alexis Wilke, Doug Barbieri
CLASS
moVariableReducerCommand_Lowercase
NAME
lowercase - transpose all uppercase characters to lowercase
VERSION
Version: 1.2.0
SYNOPSIS
&x24;(lowercase <param>)
DESCRIPTION
This system instruction ensures that the parameter string is
only lowercase characters.
SEE ALSO
moVariableReducerCommand
COPYRIGHTS
This documentation and the code being documented is proprietary and cannot be duplicated without the express and written consent of Made to Order Software Coporation.
Copyright (c) 1999-2007 by Made to Order Software Corporation
All rights reserved.
AUTHORS
Alexis Wilke, Doug Barbieri
CLASS
moVariableReducerCommand_Reverse
NAME
reverse - reverse the string (last character first)
VERSION
Version: 1.2.0
SYNOPSIS
&x24;(reverse <param>)
DESCRIPTION
This system instruction returns the input string from the last
character to the first.
SEE ALSO
moVariableReducerCommand
COPYRIGHTS
This documentation and the code being documented is proprietary and cannot be duplicated without the express and written consent of Made to Order Software Coporation.
Copyright (c) 1999-2007 by Made to Order Software Corporation
All rights reserved.
AUTHORS
Alexis Wilke, Doug Barbieri
CLASS
moVariableReducerCommand_Shell
NAME
shell - execute a shell command
VERSION
Version: 1.2.0
SYNOPSIS
&x24;(shell <command params>)
DESCRIPTION
This is a system implementation of a moVariableReducerCommand
used to execute shell commands.
The standard output of the shell commands will be returned as
the result of the command.
The command takes exactly one parameter: the shell command
and its parameters. However, the command and parameter can
both include commas. These will be used in the command line.
SEE ALSO
moVariableReducerCommand
COPYRIGHTS
This documentation and the code being documented is proprietary and cannot be duplicated without the express and written consent of Made to Order Software Coporation.
Copyright (c) 1999-2007 by Made to Order Software Corporation
All rights reserved.
AUTHORS
Alexis Wilke, Doug Barbieri
CLASS
moVariableReducerCommand_Switchcase
NAME
switchcase - transpose all lowercase characters to uppercase and vice versa
VERSION
Version: 1.2.0
SYNOPSIS
&x24;(switchcase <param>)
DESCRIPTION
This system instruction returns the parameter string with all
of its lowercase transposed to uppercase and all of its uppercase
transposed to lowercase.
SEE ALSO
moVariableReducerCommand
COPYRIGHTS
This documentation and the code being documented is proprietary and cannot be duplicated without the express and written consent of Made to Order Software Coporation.
Copyright (c) 1999-2007 by Made to Order Software Corporation
All rights reserved.
AUTHORS
Alexis Wilke, Doug Barbieri
CLASS
moVariableReducerCommand_Uppercase
NAME
uppercase - transpose all lowercase characters to uppercase
VERSION
Version: 1.2.0
SYNOPSIS
&x24;(uppercase <param>)
DESCRIPTION
This system instruction ensures that the parameter string is
only uppercase characters.
SEE ALSO
moVariableReducerCommand
COPYRIGHTS
This documentation and the code being documented is proprietary and cannot be duplicated without the express and written consent of Made to Order Software Coporation.
Copyright (c) 1999-2007 by Made to Order Software Corporation
All rights reserved.
AUTHORS
Alexis Wilke, Doug Barbieri
CLASS
moVariableReducer
NAME
Constructor - initialize an moVariableReducer object
Destructor - virtual destructor to clean up this object
VERSION
Version: 1.2.0
SYNOPSIS
moVariableReducer(void);
virtual ~moVariableReducer();
DESCRIPTION
An moVariableReducer object can be used to reduce all variable
references to the actual content of these variables.
The parser is very basic in its primary functioning. It will
read a text stream using its GetC() function. A variable is
introduced by the sequence '&x24;(' (dollar and open parenthesis).
A variable ends when the corresponding closing parenthesis is
found. Within a variable you can declare other variables.
The assumption is that the input file can be of any time and
thus only the '&x24;(' will make an instance of this object react.
It still is necessary to be able to skip such a sequence in
case the file presents examples which require such sequences
to appear as is. This is done with a backslash: '\&x24;(' will
be returned as '&x24;(' and no variable parsing is performed.
Note that a stand alone &x24; or ( are taken as is also.
The reduction function is recursive and it can parse a variable
within another variable with a maximum of MO_VR_MAXDEPTH.
SEE ALSO
moVariable, moVariableList, moXML, Reduce
COPYRIGHTS
This documentation and the code being documented is proprietary and cannot be duplicated without the express and written consent of Made to Order Software Coporation.
Copyright (c) 1999-2007 by Made to Order Software Corporation
All rights reserved.
AUTHORS
Alexis Wilke, Doug Barbieri
CLASS
moVariableReducer
NAME
Reduce - the function to call to start reducing an input stream
Reducing - the actual command which parse the input
VERSION
Version: 1.2.0
SYNOPSIS
virtual int Reduce(moWCString& result);
private:
int Reducing(moWCString& result);
DESCRIPTION
The Reduce() function will be called to reduce the input so no
variables appear in the input afterward.
The Reducing() function will be used internally. It manages the
current depth properly.
RETURN VALUE
If an error occurs, -1 is returned, otherwise 0.
SEE ALSO
Name
BUGS
At this time there is no way to know whether an error occured
or the end of the file was found.
This function is NOT re-entrant within the same object. Watch
out in case you wanted to have some sort of recursivity.
COPYRIGHTS
This documentation and the code being documented is proprietary and cannot be duplicated without the express and written consent of Made to Order Software Coporation.
Copyright (c) 1999-2007 by Made to Order Software Corporation
All rights reserved.
AUTHORS
Alexis Wilke, Doug Barbieri
CLASS
moVariableReducer
NAME
GetC - get the next character of input
VERSION
Version: 1.2.0
SYNOPSIS
virtual mowc::wc_t GetC(unsigned long depth) = 0;
DESCRIPTION
The GetC() function is called by the variable reducer to
get the character from the input.
The input can be defined as a file, a string, etc. this
is user depend.
The function must be overridden as this is a pure virtual
function (abstract).
RETURN VALUE
The function is exepected to return either a Unicode
character or the special value moVariableReducer::MO_VR_EOF
when the input is empty.
SEE ALSO
Name
COPYRIGHTS
This documentation and the code being documented is proprietary and cannot be duplicated without the express and written consent of Made to Order Software Coporation.
Copyright (c) 1999-2007 by Made to Order Software Corporation
All rights reserved.
AUTHORS
Alexis Wilke, Doug Barbieri
CLASS
moVariableReducer
NAME
Undefined - called whenever a request is made for an undefined variable or command
VERSION
Version: 1.2.0
SYNOPSIS
virtual void Undefined(const moWCString& name, bool command = false);
PARAMETERS
name - the name of the undefined variable or command
command - whether a command (true) or a variable (false) is undefined
DESCRIPTION
The default (and certainly your) GetVariable() function will
call this Undefined() function whenever a request for a variable
can't be satisfied.
Similarly, the Command() function calls this Undefined() function
whenever a command can't be found in the list of registered commands.
You know whether the function is being called for a variable or
a command by testing the command parameter.
The result is implementation specific. The default function currently
does nothing. Your implementation can print out a warning or an
error message.
SEE ALSO
GetVariable, Command
COPYRIGHTS
This documentation and the code being documented is proprietary and cannot be duplicated without the express and written consent of Made to Order Software Coporation.
Copyright (c) 1999-2007 by Made to Order Software Corporation
All rights reserved.
AUTHORS
Alexis Wilke, Doug Barbieri
CLASS
moVariableReducer
NAME
GetVariable - get the value of a named variable
VERSION
Version: 1.2.0
SYNOPSIS
virtual moWCString moVariableReducer::GetVariable(const moWCString& name);
DESCRIPTION
The default GetVariable() function searches for an environment variable and
return its value. If the variable isn't defined, then the Undefined() function
is called and an empty string is returned.
You can override this function to acces your own variables and call this
one in case none of your variable has the specified name.
RETURN VALUE
The content of the named variable or the empty string
SEE ALSO
Undefined
COPYRIGHTS
This documentation and the code being documented is proprietary and cannot be duplicated without the express and written consent of Made to Order Software Coporation.
Copyright (c) 1999-2007 by Made to Order Software Corporation
All rights reserved.
AUTHORS
Alexis Wilke, Doug Barbieri
CLASS
moVariableReducer
NAME
RegisterCommand - add a command to the internal list of commands
UnregisterCommand - remove a command previous registered
Command - execute the named command with the specified parameters
VERSION
Version: 1.2.0
SYNOPSIS
bool RegisterCommand(const moVariableReducerCommand& command);
bool UnregisterCommand(const moVariableReducerCommand& command);
int Command(const moWCString& command, const moList& parameters, moWCString& result);
DESCRIPTION
The RegisterCommand() function is used internally to add all the
default commands (such as the &x24;(shell ...) command).
The user is welcome to implement his/her own commands. Two commands
can't have the same name. For this reason, this function returns
a boolean value which indicates whether the function being registered
is actually being refused.
The UnregisterCommand() function remove a command which was previously
registered with the RegisterCommand() function.
The Command() function is then used to call one registered command.
The parameters is a list of strings used by the command. The result
parameter should be empty on entry, thought, if not, it will represent
the default result (i.e. it will be unchanged if anything goes wrong
running the command -- WARNING: some commands may clear the result).
RETURN VALUE
RegisterCommand():
If the registred command is registered then true
If the registred command is rejected (a command of that name already exists) then false
Command():
0 when nothing goes wrong, the errno otherwise (Warning: the current errno may
be different than the returned errno value)
SEE ALSO
?
BUGS
Even thought the result should be modified by the command only if
a result is properly defined, it is possible that some functions
will change the result variable even thought they will fail.
COPYRIGHTS
This documentation and the code being documented is proprietary and cannot be duplicated without the express and written consent of Made to Order Software Coporation.
Copyright (c) 1999-2007 by Made to Order Software Corporation
All rights reserved.
AUTHORS
Alexis Wilke, Doug Barbieri
CLASS
moVariableReducerCommand
NAME
Execute - called whenever the command has to be executed
Name - returns the name of the command
MinimumParameterCount - the minimum number of parameters necessary
MaximumParameterCount - the maximum number of parameters
ParameterType - a function used to ensure the correct type of each parameter
VERSION
Version: 1.2.0
SYNOPSIS
virtual int Execute(const moListOfWCStrings& parameters, moWCString& result) = 0;
virtual const moWCString Name(void) const = 0;
virtual unsigned long MinimumParameterCount(void) const;
virtual unsigned long MaximumParameterCount(void) const;
virtual mo_vr_param_t ParameterType(unsigned long index) const;
private:
virtual compare_t Compare(const moBase& object) const;
PARAMETERS
parameters - a list of strings representing the paramaters
result -- the result to grow (i.e. do result += <execution result>)
index -- the parameter type at that position
object -- another command which name will be compared
DESCRIPTION
The moVariableReducerCommand class is defined in order to allow users of
the moVariableReducer to define additional commands to the system.
The system defines a certain number of internal functions which don't
require other objects to work. The following is a small list of these
internal commands:
&x24;(echo ...)
&x24;(first ...)
&x24;(last ...)
&x24;(shell ...)
&x24;(word ...)
&x24;(count ...)
Each command needs to overload the Execute() and Name() pure virtual
functions (abstract functions). The Execute() function is called
whenever the command needs to be executed. It receives a list with
all the parameters as expected by the command and a string to be
filled with the result. The list of parameters will have been tested
against the minimum, maximum and type as defined below. Thus, the
Execute() function doesn't need to test all the parameters again
(unless there is dynamism among the type of parameters).
The MinimumParameterCount() and MaximumParameterCount() functions
will return the minimum number of parameters and the maximum number
of parameters that the command supports. Most commands will accept
only a specific number of parameters in which case both functions
return that same number. Functions which accept a variable number
of parameters can return a minimum and a maximum which are different.
The maximum always needs to be larger than the minimum.
The default count for both of these functions is 1 (the minimum
number of parameters is at least 1 since to be detected as a
function, a variable name needs to be followed by at least one
parameter).
If the number of parameters is not limited, you don't need to
overload the MinimumParameterCount() function, and you can return
ULONG_MAX in your MaximumParameterCount() function.
The ParameterType() function accepts the parameter number (from
0 to MaximumParameterCount() - 1 or the actual number of parameters
when less than the maximum is defined). The function needs to return
one of the following type value:
enum mo_vr_param_t {
MO_VR_PARAM_ERROR = -1, // index out of bounds or some other error
MO_VR_PARAM_ANY = 0, // anything is fine
MO_VR_PARAM_INTEGER = 1, // an integer (vs a float)
MO_VR_PARAM_FLOAT = 2, // a floating point value
MO_VR_PARAM_NUMBER = 3, // either an integer or a float
MO_VR_PARAM_STRING = 4 // not a number
};
By default, the ParameterType() function returns MO_VR_PARAM_ANY
which means the parameter can be really anything. If you specify
MO_VR_PARAM_NUMBER, then an integer or a floating point value are
accepted for that parameter. At this time, the MO_VR_PARAM_STRING
is considered as not being neither an integer nor a floating point.
If there is an error while running the ParameterType() function,
it needs to return MO_VR_PARAM_ERROR. Usually, this happens when
the function is called with an index out of bounds.
The private Compare() function is used to ensure that these objects
are sorted alphabetically in the list of commands of an
moVariableReducer object.
RETURN VALUE
Execute():
Execute is expected to return 0 when no error occurs or errno
when an error occurs.
Name():
Returns the name of the command (such as "echo").
MinimumParameterCount():
By default, this function returns 1. It is expected to return
the minimum number of parameters required by the command so
the Execute() function works properly.
MaximumParameterCount():
By default, this function returns 1. It is expected to return
the maximum number of parameters supported by the command so
the Execute() function works properly.
ParameterType():
By default, this function returns MO_VR_PARAM_ANY.
If a specialized parameter is required, then return the type
of data you expect with one of the mo_vr_param_t values.
Compare():
The comparison result. It needs to not be redefined. This is
an internal function only.
SEE ALSO
?
BUGS
Even thought the result should be modified by the command only if
a result is properly defined, it is possible that some functions
will change the result variable even thought they will fail.
COPYRIGHTS
This documentation and the code being documented is proprietary and cannot be duplicated without the express and written consent of Made to Order Software Coporation.
Copyright (c) 1999-2007 by Made to Order Software Corporation
All rights reserved.
AUTHORS
Alexis Wilke, Doug Barbieri
Links:
molib
the sandbox
|