Meta::MNode Class Reference
Used by the framework for symbolic manipulation, e.g: in parsing, interpretation, etc.
More...
#include <MNode.h>
List of all members.
Public Types |
|
typedef uint16_t | Type |
Public Member Functions |
| | MNode () |
| | MNode (const MNode &n) |
|
| MNode (const MVar &v) |
|
| MNode (MObject *obj, Type t=ObjectPointer) |
|
| MNode (const MObject &obj) |
|
| MNode (Type type, const mstr &value) |
|
| MNode (const MVar *v) |
|
| MNode (MVar *v) |
|
| MNode (MStr *s) |
|
| MNode (const MStr &s) |
|
| MNode (const char *s) |
|
| MNode (bool x) |
|
| MNode (uint8_t x) |
|
| MNode (int8_t x) |
|
| MNode (uint16_t x) |
|
| MNode (int16_t x) |
|
| MNode (uint32_t x) |
|
| MNode (int32_t x) |
|
| MNode (uint64_t x) |
|
| MNode (int64_t x) |
|
| MNode (double x) |
|
| MNode (float x) |
|
| MNode (const MVector< MVar > &v) |
|
| MNode (const MList< MVar > &l) |
|
| MNode (const MNum &x) |
|
| MNode (const MReal &x) |
|
MVar & | attrs () |
|
const MVar & | attrs () const |
|
bool | hasAttrs () const |
|
void | clearAttrs (bool recursive=false) |
|
bool | operator== (const MNode &n) const |
|
bool | operator!= (const MNode &n) const |
|
bool | isSame (const MNode &n) const |
|
MNode & | operator= (const MNode &n) |
|
MNode & | operator[] (size_t i) const |
|
MNode & | operator[] (int i) const |
|
MNode & | operator[] (const MVar &v) const |
| MNode | copy () const |
| mstr | toStr (bool concise=true, bool quote=true) const |
| MNode & | operator+ (const MNode &n) |
|
MVar & | var () |
|
const MVar & | var () const |
|
| operator bool () const |
|
| operator double () const |
|
| operator float () const |
|
| operator uint8_t () const |
|
| operator int8_t () const |
|
| operator uint16_t () const |
|
| operator int16_t () const |
|
| operator uint32_t () const |
|
| operator int32_t () const |
|
| operator uint64_t () const |
|
| operator int64_t () const |
|
| operator MNum & () |
|
| operator const MNum & () const |
|
| operator const char * () const |
|
| operator mstr & () |
|
| operator const mstr & () const |
|
| operator MVar & () |
|
| operator const MVar & () const |
|
| operator const MVector< MVar > & () const |
|
| operator MVector< MVar > & () |
|
| operator const MList< MVar > & () const |
|
| operator MList< MVar > & () |
| void | add (MNode node) |
| void | addFront (MNode node) |
| void | insert (size_t pos, MNode node) |
| void | remove (size_t pos) |
| void | append (MNode node) |
| size_t | size () const |
| bool | empty () const |
| void | pushBack (MNode node) |
| void | pushFront (MNode node) |
| void | push (MNode node) |
| MNode | popBack () |
| MNode | popFront () |
| MNode | pop () |
| bool | isFunction () const |
| bool | isFunction (const mstr &f) const |
| bool | isFunction (const mstr &f, size_t args) const |
| bool | isFunction (const mstr &f, size_t argsMin, size_t argsMax) const |
| bool | isNumeric () const |
| int | isRational () const |
| bool | isReal () const |
| bool | isObject () const |
| bool | isSymbol () const |
| bool | isSymbol (const mstr &name) const |
| bool | isString () const |
| bool | isConstant () const |
| bool | isCodeData () const |
| bool | isSymbolic () const |
| bool | isTrue () const |
| bool | isFalse () const |
| bool | isPtr () const |
| void | set (MNode n) |
| void | clear () |
| Type | type () const |
| void | setLineNumber (size_t lineNumber) |
| size_t | lineNumber () const |
| void | setFileName (const mstr &fileName) |
| const mstr & | fileName () const |
| void | clearInputs () |
| void | copyParseInfo (MNode node, bool recursive=true) |
| MVar | toVar (bool exact=true) const |
| MObject * | obj () |
| const mstr & | str () const |
| mstr & | str () |
| const char * | cstr () const |
Static Public Member Functions |
| static MNode | parse (const mstr &code) |
Static Public Attributes |
|
static const Type | NumericMask = 0x0010 |
|
static const Type | DefinedNumericMask = 0x0020 |
|
static const Type | Undefined = 0x0010 |
|
static const Type | Constant = 0x0031 |
|
static const Type | Integer = 0x0032 |
|
static const Type | Rational = 0x0033 |
|
static const Type | Float = 0x0034 |
|
static const Type | Matrix = 0x0035 |
|
static const Type | Real = 0x0036 |
|
static const Type | StringMask = 0x0040 |
|
static const Type | String = 0x0040 |
|
static const Type | Symbol = 0x0041 |
|
static const Type | Function = 0x0042 |
|
static const Type | ObjectMask = 0x0080 |
|
static const Type | ObjectPointer = 0x0081 |
|
static const Type | LocalObject = 0x0082 |
|
static const Type | SharedObject = 0x0083 |
|
static const Type | RawPointer = 0x0100 |
|
static const Type | CodeDataMask = 0x0200 |
Detailed Description
Used by the framework for symbolic manipulation, e.g: in parsing, interpretation, etc.
MNode is the central data type used throughout the framework for symbolic manipulation, e.g: parsing, interpretation, etc. It subsumes mvar, adding symbols, and functions which make use of the MNode recursively.
Constructor & Destructor Documentation
| Meta::MNode::MNode |
( |
const MNode & |
n |
) |
|
Member Function Documentation
| void Meta::MNode::add |
( |
MNode |
node |
) |
|
When this node is a function, add node as an argument.
| void Meta::MNode::addFront |
( |
MNode |
node |
) |
|
When this node is a function, add node the the front of the args list.
| void Meta::MNode::append |
( |
MNode |
node |
) |
|
When this node is a function, append the arguments of node to this node's arguments.
| void Meta::MNode::clear |
( |
|
) |
|
Clear this nodes arguments and all data contained within.
| void Meta::MNode::clearInputs |
( |
|
) |
|
Clear function arguments.
| MNode Meta::MNode::copy |
( |
|
) |
const |
| void Meta::MNode::copyParseInfo |
( |
MNode |
node, |
|
|
bool |
recursive = true | |
|
) |
| | |
Set line number and filename from node.
| const char* Meta::MNode::cstr |
( |
|
) |
const [inline] |
Get the c-string this node holds.
| bool Meta::MNode::empty |
( |
|
) |
const |
- Returns:
- true is the function has no arguments.
| const mstr& Meta::MNode::fileName |
( |
|
) |
const |
Get the filename associated with this node.
| void Meta::MNode::insert |
( |
size_t |
pos, |
|
|
MNode |
node | |
|
) |
| | |
When this node is a function, insert node at argument position pos.
| bool Meta::MNode::isCodeData |
( |
|
) |
const |
- Returns:
- true is this is code data.
| bool Meta::MNode::isConstant |
( |
|
) |
const |
- Returns:
- true if this is a constant value, i.e, non-symbolic.
| bool Meta::MNode::isFalse |
( |
|
) |
const |
- Returns:
- true if this is false proper (not numeric false), as defined by MNum.
| bool Meta::MNode::isFunction |
( |
const mstr & |
f, |
|
|
size_t |
argsMin, |
|
|
size_t |
argsMax | |
|
) |
| | const |
- Returns:
- true if this is a function named f of arity between argsMin and argsMax.
| bool Meta::MNode::isFunction |
( |
const mstr & |
f, |
|
|
size_t |
args | |
|
) |
| | const |
- Returns:
- true if this is a function named f of arity args.
| bool Meta::MNode::isFunction |
( |
const mstr & |
f |
) |
const |
- Returns:
- true if this is a function named f.
| bool Meta::MNode::isFunction |
( |
|
) |
const |
- Returns:
- true if this is a function.
| bool Meta::MNode::isNumeric |
( |
|
) |
const |
- Returns:
- true if this is a numeric.
| bool Meta::MNode::isObject |
( |
|
) |
const |
- Returns:
- true if this is an object.
| bool Meta::MNode::isPtr |
( |
|
) |
const |
- Returns:
- true if this node holds a pointer to an mvar or string.
| int Meta::MNode::isRational |
( |
|
) |
const |
- Returns:
- 0 if not rational, 1 if integer else 2.
| bool Meta::MNode::isReal |
( |
|
) |
const |
true if this holds a real.
| bool Meta::MNode::isString |
( |
|
) |
const |
- Returns:
- true if this is a string literal.
| bool Meta::MNode::isSymbol |
( |
const mstr & |
name |
) |
const |
- Returns:
- true if this is a symbol named name.
| bool Meta::MNode::isSymbol |
( |
|
) |
const |
- Returns:
- true if this is a symbol.
| bool Meta::MNode::isSymbolic |
( |
|
) |
const |
- Returns:
- true if this is symbolic, i.e: a function or symbol.
| bool Meta::MNode::isTrue |
( |
|
) |
const |
- Returns:
- true if this is true proper (not numeric true), as defined by MNum.
| size_t Meta::MNode::lineNumber |
( |
|
) |
const |
Get the line number associated with this node.
Get the object this node holds.
| static MNode Meta::MNode::parse |
( |
const mstr & |
code |
) |
[static] |
Parse M code from a string.
- Returns:
- The top-level node as parsed or mnull in the case of failure.
| MNode Meta::MNode::pop |
( |
|
) |
|
| MNode Meta::MNode::popBack |
( |
|
) |
|
Remove and return the last function argument.
| MNode Meta::MNode::popFront |
( |
|
) |
|
Remove and return the first function argument.
| void Meta::MNode::push |
( |
MNode |
node |
) |
|
| void Meta::MNode::pushBack |
( |
MNode |
node |
) |
|
| void Meta::MNode::pushFront |
( |
MNode |
node |
) |
|
| void Meta::MNode::remove |
( |
size_t |
pos |
) |
|
When this node is a function, remove the argument at position pos.
| void Meta::MNode::set |
( |
MNode |
n |
) |
|
Set this node's value to n as opposed to node assignment.
| void Meta::MNode::setFileName |
( |
const mstr & |
fileName |
) |
|
Set the filename associated with this node.
| void Meta::MNode::setLineNumber |
( |
size_t |
lineNumber |
) |
|
Set the line number associated with this node.
| size_t Meta::MNode::size |
( |
|
) |
const |
- Returns:
- The number of function arguments.
| mstr& Meta::MNode::str |
( |
|
) |
|
Get the string this node holds.
| const mstr& Meta::MNode::str |
( |
|
) |
const |
Get the string this node holds.
| mstr Meta::MNode::toStr |
( |
bool |
concise = true, |
|
|
bool |
quote = true | |
|
) |
| | const |
Get a string representation of the node.
- Parameters:
-
| concise | true to use concise numerics. |
| quote | true to quote strings. |
| MVar Meta::MNode::toVar |
( |
bool |
exact = true |
) |
const |
Convert an mnode to mvar. Functions and symbols and never implcitly converted to mvar -- an MError is thrown on attempting to do so.
- Parameters:
-
| exact | if true, symbolic constructs which would normally be converted to mvar, e.g: Vec(1,2,3) => [1,2,3] are retained in symbolic form. |
| Type Meta::MNode::type |
( |
|
) |
const |
- Returns:
- the type of this node.
The documentation for this class was generated from the following file: