|
CLASS moExpr
NAME
Constructor - create an expression string
VERSION
Version: 1.2.0
SYNOPSIS
moExpr(void);
moExpr(const moWCString& string);
moExpr(const moExpr& expr);
moExpr(const char *string, long length = -1, mowc::encoding_t encoding = mowc::MO_ENCODING_UTF8);
moExpr(const mowc::mc_t *string, long length = -1, mowc::encoding_t encoding = mowc::MO_ENCODING_UCS2_INTERNAL);
moExpr(const mowc::wc_t *string, long length = -1, mowc::encoding_t encoding = mowc::MO_ENCODING_UCS4_INTERNAL);
moExpr(const wchar_t *string, long length = -1);
DESCRIPTION
These constructors are similar to the moWCString() constructors.
Please, refer to the moWCString class for more information.
SEE ALSO
Result()
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
moExpr
NAME
Error - return the last error
VERSION
Version: 1.2.0
SYNOPSIS
mo_expr_errno_t Error(void) const;
DESCRIPTION
This function returns the last error the last Result() call
generated.
RETURN VALUE
one of MO_EXPR_ERROR_... values; NONE (0) means no error occured.
SEE ALSO
Result()
BUGS
Before a call to the Result() function, the error number is not
defined.
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
moExpr
NAME
Result - computes a C expression
VERSION
Version: 1.2.0
SYNOPSIS
moWCString Result(void) const;
DESCRIPTION
The Result() function transforms the C expression present in the
moExpr string object into a string with the result of the C
expression.
At this time, it supports the following types:
identifiers [a-zA-Z_][a-zA-Z_0-9]*
integers [0-9]+
floats [0-9]+\.[0-9]+([eE][-+][0-9]+)?
strings \"([^"]|\\\")\"
character \'...\' C like 8 bit characters
Identifiers are used to:
1. set variables and read them later (a = 5; b = a * 9),
2. function names: sin(3.14159),
3. casts: (long) "134"
The following are all the expression in their priority order
that are currently supported in this function:
Operator Name Types supported
<expr>++ postfix increment integer, float
<expr>-- postfix decrement integer, float
++<expr> prefix increment integer, float
--<expr> prefix increment integer, float
!<expr> logical not integer, float, string
see String.Reverse()
~<expr> bitwise not integer, string
see String.Switchcase()
+<expr> identity integer, float, string
see String.Uppercase()
-<expr> negate integer, float, string
see String.Lowercase()
(<expr>) grouping any
(<type>) <expr> cast any
<type> = int, long
float, double
string
<expr>(<expr>) function call see the list of supported
functions below
<expr>[<expr>] array string
also accepts: <expr>[<expr>..<expr>]
<expr>[<expr>..]
<expr>[..<expr>]
(negative values are indexes from the end)
<expr>**<expr> power integer, float
<expr>*<expr> multiply integer, float
<expr>/<expr> divide integer, float
<expr>%<expr> modulo integer, float
<expr>+<expr> add integer, float, string
see String.operator +
<expr>-<expr> substract integer, float
<expr> << <expr> shift left integer
<expr> >> <expr> shift right integer
<expr> < <expr> less than integer, float, string
<expr> <= <expr> less or equal integer, float, string
<expr> > <expr> greater than integer, float, string
<expr> >= <expr> greater or equal integer, float, string
<expr> == <expr> equal integer, float, string
<expr> != <expr> not equal integer, float, string
<expr>&<expr> bitwise and integer
<expr>^<expr> bitwise xor integer
<expr>|<expr> bitwise or integer
<expr>&&<expr> bitwise and integer, float, string
<expr>^^<expr> bitwise xor integer, float, string
<expr>||<expr> bitwise or integer, float, string
<expr>?<expr>:<expr> conditional integer, float, string
<expr> <assign op> <expr> assign identifier = anything
the assign operators are any of:
**=, *=, /=, %=, +=, -=, <<=, >>=, &=,
|=, ^=
<expr>,<expr> comma any
<expr>;<expr> end expression any
Notes:
The comma separator can be used within a list of parameter
for a function call as in regular C/C++.
The following is a list of the functions supported by this
object so far:
atol() accept a string as parameter; transforms it
to an integer
basename() returns the base name of the first parameter;
when a second parameter is specified, make
sure the first doesn't end with it (that is,
if it does, that part - extension - is also
removed)
capitalize_words()
force the first letter of each word to an
uppercase and all the others to lowercase
capitalize() force the very first letter to an uppercase
letter and all the others to lowercase
clip() returns the string without any spaces at the
start and at the end (see trim() also)
included() accept 2 or more parameters; it returns true
if the first parameter is equal to any of
the following parameters
Note: at this time only integers are
supported
lower() change all the letters to lowercase letters
regexpr() check whether parameter 2 matches the regular
expression defined in parameter 1; if the regular
expression does match then this function returns
true, otherwise it returns false
the following parameters are strings giving
variable names which are set to whatever
parameter fits in as defined in the regular
expression (see the \(...\))
(this last feature is not supported yet)
replace() the first parameter is a string which represents
a list of pairs separated by semi-colons; each
pair consists of a string element to replace
and what to replace it with the string element
and its replacement have to be separated by an
equal sign; as many pairs as you need can be
included; example:
"'=<single quote>;\"=<double quote>"
This replaces each instance of ' and " by
the full name of the quote.
the second parameter to this function is the
string on which these replacements are applied;
the result is the string with the characters
replaced
reverse() reverse the order; swap the first and last letters,
the second and one before last, etc.
strf() format a list of parameters; the first parameter
is the format (as in printf(3C) under Linux);
the following parameters are used as specified
in the format; the result is the formatted
string
strlen() return the length of a string in characters
switch_case() change all the lowercase letters in uppercase
and vice versa
trim() trim the specified string from space and newline
characters from the beginning and the end of the
string (like clip() but includes the new lines)
upper() change all the letters to uppercase letters
RETURN VALUE
a string with the result
or "ERROR" to indicate that some error occured
SEE ALSO
Constructors
BUGS
You can't distinguish a real error from an expression which
itself returns the string ERROR.
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
|