Meta::MVar Class Reference

A recursive variant type for holding numerics, strings, and more. More...

#include <MVar.h>

List of all members.

Public Types

enum  ToNodeType { ToNodeTop, ToNodeOne, ToNodeAll, ToNodeNone }
typedef uint16_t Type
typedef void(MVar::* BoolType_ )() const

Public Member Functions

 MVar (bool x)
 MVar (uint8_t x)
 MVar (int8_t x)
 MVar (uint16_t x)
 MVar (int16_t x)
 MVar (uint32_t x)
 MVar (int32_t x)
 MVar (uint64_t x)
 MVar (int64_t x)
 MVar (double x)
 MVar (float x)
 MVar (const MVar &v)
 MVar (const mnum &x)
 MVar (const mstr &str, Type t=String)
 MVar (const std::string &str, Type t=String)
 MVar (const char *str, Type t=String)
 MVar (mstr *str, Type t=String)
 MVar (MObject *o, Type t=ObjectPointer)
 MVar (void *p)
 MVar (const MObject &o)
 MVar (const mnode &n, bool exact=false)
 MVar (const mvec &v)
 MVar (const mlist &l)
 MVar (const mrat &x)
 MVar (const mmat &x)
 MVar (const mreal &x)
mnumasNum ()
const mnumasNum () const
mnumnum ()
const mnumnum () const
 operator const mnum & () const
 operator mnum & ()
bool isTrue () const
bool isFalse () const
mstrasStr ()
const mstrasStr () const
mstrstr ()
const mstrstr () const
const char * cstr () const
mstr toStr (bool concise=true, bool quote=false, bool mml=true) const
const char * asCStr () const
std::string toStdStr () const
int64_t asLong () const
int64_t toLong () const
double asDouble () const
double toDouble () const
const mratasRat () const
mratasRat ()
mrat toRat () const
const mrealasReal () const
mrealasReal ()
mreal toReal () const
const mmatasMat () const
mmatasMat ()
size_t asSize () const
MObjectasObj () const
MObjectobj () const
void * asPtr () const
void * ptr () const
const mvecvec () const
mvecvec ()
 operator const mvec & () const
 operator mvec & ()
const mlistlist () const
mlistlist ()
 operator const mlist & () const
 operator mlist & ()
const mmapmap () const
mmapmap ()
mvec toVec () const
mlist toList () const
 operator const mmap & () const
 operator mmap & ()
 operator double () 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 const char * () const
 operator mstr & ()
 operator const mstr & () const
 operator float () const
 operator bool () const
MVaroperator= (const MVar &v)
MVaroperator= (const MStr &s)
MVaroperator= (const std::string &s)
MVaroperator= (const char *s)
template<typename T >
MVaroperator= (const T &t)
MVaroperator+= (const MVar &v)
MVar operator+ (const MVar &v) const
template<typename T >
MVar operator+ (T &x) const
MVar operator+ (uint32_t x) const
MVar operator+ (int32_t x) const
MVar operator+ (uint64_t x) const
MVar operator+ (int64_t x) const
MVar operator+ (double x) const
MVar operator++ (int)
MVaroperator++ ()
MVaroperator-= (const MVar &v)
MVar operator- (const MVar &v) const
template<typename T >
MVar operator- (T &x) const
MVar operator- (uint32_t x) const
MVar operator- (int32_t x) const
MVar operator- (uint64_t x) const
MVar operator- (int64_t x) const
MVar operator- (double x) const
MVar operator-- (int)
MVaroperator-- ()
MVar operator- () const
MVaroperator*= (const MVar &v)
MVar operator* (const MVar &v) const
template<typename T >
MVar operator* (T &x) const
MVar operator* (uint32_t x) const
MVar operator* (int32_t x) const
MVar operator* (uint64_t x) const
MVar operator* (int64_t x) const
MVar operator* (double x) const
MVaroperator/= (const MVar &v)
MVar operator/ (const MVar &v) const
template<typename T >
MVar operator/ (T &x) const
MVar operator/ (uint32_t x) const
MVar operator/ (int32_t x) const
MVar operator/ (uint64_t x) const
MVar operator/ (int64_t x) const
MVar operator/ (double x) const
bool operator< (const MVar &v) const
template<typename T >
bool operator< (const T &t) const
bool operator> (const MVar &v) const
template<typename T >
bool operator> (const T &t) const
bool operator<= (const MVar &v) const
template<typename T >
bool operator<= (const T &t) const
bool operator>= (const MVar &v) const
template<typename T >
bool operator>= (const T &t) const
bool operator== (const MVar &v) const
bool operator== (const MStr &s) const
template<typename T >
bool operator== (const T &t) const
bool operator== (const std::string &s) const
bool operator== (const char *s) const
bool operator!= (const MVar &v) const
bool operator!= (const MStr &s) const
template<typename T >
bool operator!= (const T &t) const
bool operator!= (const std::string &s) const
bool operator!= (const char *s) const
MVaroperator|= (const MVar &v)
MVar operator| (const MVar &v) const
template<typename T >
MVar operator| (T &x) const
MVar operator| (int x) const
MVar operator| (double x) const
const MVaroperator[] (const MVar &key) const
MVaroperator[] (const MVar &key)
template<typename T >
const MVaroperator[] (const T &key) const
template<typename T >
MVaroperator[] (const T &key)
bool operator! () const
MVaroperator%= (const MVar &v)
MVar operator% (const MVar &v) const
template<typename T >
MVar operator% (const T &t) const
MVar operator% (uint32_t x) const
MVar operator% (int32_t x) const
MVar operator% (uint64_t x) const
MVar operator% (int64_t x) const
MVar operator% (double x) const
MVaroperator<< (const MVar &v)
template<typename T >
MVaroperator<< (const T &x)
void BoolStub_ () const
 operator BoolType_ () const
bool isDefined () const
bool isNumeric () const
int isRational () const
bool isReal () const
Type type () const
MVarget (const MVar &key)
MVaroperator() (const MVar &key)
mvec keys () const
size_t size () const
size_t mapSize () const
bool isMapEmpty () const
bool isSeqEmpty () const
bool isEmpty () const
size_t span () const
bool toBool () const
void setBinary (const char *buf, size_t pos, size_t count, Type t=String)
size_t getBinary (char *buf, size_t pos, size_t count) const
size_t getBinary (char *buf, size_t pos) const
size_t binarySize () const
bool hasKey (const MVar &key) const
bool keyValue (const MVar &key, const MVar &value) const
MVarsetHead (const MVar &v, Type t=String)
MVar head () const
MVarback ()
const MVarback () const
void pushBack (const MVar &v)
void push_back (const MVar &v)
void push (const MVar &v)
void pushFront (const MVar &v)
void push_front (const MVar &v)
MVar popBack ()
void pop_back ()
MVar popFront ()
void pop_front ()
void pop ()
void insert (int64_t pos, const MVar &value)
MVaradd (const MVar &key, const MVar &value)
const MVaruget (const MVar &key, const MVar &def=undef) const
int64_t index (const MVar &value, int64_t start=0, int64_t end=-1) const
void erase (const MVar &key)
void clearSeq ()
void clearMap ()
void clear ()
void merge (const MVar &v)
void outerMerge (const MVar &v)
bool hasVector () const
bool hasList () const
void indexMap (bool flag)
bool isString () const
bool isStringPtr () const
mvec split (const mstr &delimiter, int maxTokens=-1) const
mstr join (const mstr &delimiter) const
MVarunite ()
MVarunite (const MVar &v, bool outer=false)
MVarintersect (const MVar &v, bool outer=false)
MVarcomplement (const MVar &v)
bool subsumesData (const MVar &v) const
MVar clone () const
MVarunlink ()
bool isCodeData () const
void setCodeData (bool flag)
mnode toNode (ToNodeType type=ToNodeTop) const
bool isSymbolic () const
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 isSymbol () const
bool isSymbol (const mstr &name) const

Static Public Member Functions

static MVar fromStr (const mstr &str, bool literal=true, bool exact=false)
static MStr itp (const MStr &str, const mvec &vars)

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

A recursive variant type for holding numerics, strings, and more.

Each mvar has a specific dynamic type (its "head") and may hold other mvar's recursively through its map and vector/list. MVar is used throughout the framework for a large variety of purposes.

Most MVar operators run recursively. A "key" refers to an index in the mvar's list/vector or a string key in its map.


Member Enumeration Documentation

Conversion types used in the call to toNode(). ToNodeTop converts only the top-level code data. ToNodeOne converts code data one level deep. ToNodeAll converts all embedded code data. ToNodeNone does not convert any code data encountered.


Member Function Documentation

void Meta::MVar::clearSeq (  ) 

Clear this mvar's list/vector.

MVar Meta::MVar::clone (  )  const

Clone the object contained in this mvar.

MVar& Meta::MVar::complement ( const MVar v  ) 

Recursive complement-like operator.

bool Meta::MVar::hasKey ( const MVar key  )  const
Returns:
true if this mvar's map has the specified key.
int64_t Meta::MVar::index ( const MVar value,
int64_t  start = 0,
int64_t  end = -1 
) const

Find the index within the list/vector that matches value.

Returns:
-1 on failure to find such a value.
void Meta::MVar::indexMap ( bool  flag  ) 

Set whether map may be indexed by position.

MVar& Meta::MVar::intersect ( const MVar v,
bool  outer = false 
)

Recursive intersection-like operator.

bool Meta::MVar::isCodeData (  )  const [inline]
Returns:
true if this mvar holds code data which should not be converted to an mnode.
bool Meta::MVar::isEmpty (  )  const
Returns:
true if this mvar's list/vector and map is empty.
bool Meta::MVar::isFunction ( const mstr f,
size_t  argsMin,
size_t  argsMax 
) const
Returns:
true if this holds a function named f of arity between argsMin and argsMax.
bool Meta::MVar::isFunction ( const mstr f,
size_t  args 
) const
Returns:
true if this holds a function named f of arity args.
bool Meta::MVar::isFunction ( const mstr f  )  const
Returns:
true if this holds a function named f.
bool Meta::MVar::isFunction (  )  const
Returns:
true if this holds a function.
bool Meta::MVar::isSeqEmpty (  )  const
Returns:
true if this mvar's list/vector is empty.
bool Meta::MVar::isSymbol ( const mstr name  )  const
Returns:
true if this holds a symbol named name.
bool Meta::MVar::isSymbol (  )  const
Returns:
true if this holds a a symbol.
bool Meta::MVar::isSymbolic (  )  const
Returns:
true if this holds a symbolic value, i.e: a function or symbol.
mstr Meta::MVar::join ( const mstr delimiter  )  const

The inverse of join, operating on this mvar's list/vector.

mvec Meta::MVar::keys (  )  const
Returns:
Map keys.
bool Meta::MVar::keyValue ( const MVar key,
const MVar value 
) const
Returns:
true if this mvar's map has a key whose value is matches the specified value.
size_t Meta::MVar::mapSize (  )  const
Returns:
The size of this mvar's map.
void Meta::MVar::setCodeData ( bool  flag  ) 

Set whether this mvar holds code data which should not be converted to an mnode.

size_t Meta::MVar::size (  )  const
Returns:
The size of this mvar's vector/list.
size_t Meta::MVar::span (  )  const
Returns:
The mvar's recursive span.
mvec Meta::MVar::split ( const mstr delimiter,
int  maxTokens = -1 
) const

Split this mvar's string using delimiter into a vector.

Parameters:
maxTokens The max number of items to split, the remaing text is returned as the last item.
bool Meta::MVar::subsumesData ( const MVar v  )  const
Returns:
true if v is contained in this.
mlist Meta::MVar::toList (  )  const

If the mvar contains a vector it is converted to a list.

mnode Meta::MVar::toNode ( ToNodeType  type = ToNodeTop  )  const

Normally, to create an mnode from an mvar, the mnode constructor is simply called. This accomplishes the same, however it additionally forces code data to be converted to an mnode.

mstr Meta::MVar::toStr ( bool  concise = true,
bool  quote = false,
bool  mml = true 
) const

Returns a string reprsentation of the mvar.

Parameters:
concise true to use concise numerics.
quote true to quote strings.
mml true to output code blocks as MML rather than M code.
mvec Meta::MVar::toVec (  )  const

If the mvar contains a list it is converted to a vector.

const MVar& Meta::MVar::uget ( const MVar key,
const MVar def = undef 
) const

Get an item from the list/vector reference by key. If the specified key does not exist, return def.

MVar& Meta::MVar::unite ( const MVar v,
bool  outer = false 
)

Recursive union-like operator.

MVar& Meta::MVar::unite (  ) 

Put the mvar into a form resembling a set.

MVar& Meta::MVar::unlink (  ) 

Recursively convert shared object pointers to ordinary object pointers.


The documentation for this class was generated from the following file:

Generated on Wed Mar 24 16:22:43 2010 for AndroMeta by  doxygen 1.6.1