Hosted by: BerliOS Developer Logo

OpenMBV C++ Interface

BerliOS Project Page
 All Classes Functions Enumerations
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends
MBXMLUtils::OctEval Class Reference

#include <octeval.h>

List of all members.

Public Types

enum  ValueType {
  ScalarType, VectorType, MatrixType, StringType,
  SXType, DMatrixType, SXFunctionType
}
 Known type for the "ret" variable.

Public Member Functions

 OctEval (std::vector< boost::filesystem::path > *dependencies_=NULL)
 Constructor.
 ~OctEval ()
 Destructor.
void addParam (const std::string &paramName, const octave_value &value)
 Add a octave value to the current parameters.
void addParamSet (const xercesc::DOMElement *e)
void addPath (const boost::filesystem::path &dir, const xercesc::DOMElement *e)
octave_value eval (const xercesc::DOMElement *e)
octave_value eval (const xercesc::DOMAttr *a, const xercesc::DOMElement *pe=NULL)
octave_value stringToOctValue (const std::string &str, const xercesc::DOMElement *e=NULL, bool fullEval=true) const
template<>
string cast (const octave_value &value)
template<>
long cast (const octave_value &value)
template<>
double cast (const octave_value &value)
template<>
vector< double > cast (const octave_value &value)
template<>
vector< vector< double > > cast (const octave_value &value)
template<>
DOMElement * cast (const octave_value &value, DOMDocument *doc)
template<>
long cast (const octave_value &value)
template<>
double cast (const octave_value &value)
template<>
CasADi::SX cast (const octave_value &value)
template<>
CasADi::SX * cast (const octave_value &value)
template<>
CasADi::SXFunction cast (const octave_value &value)
template<>
CasADi::SXFunction * cast (const octave_value &value)
template<>
CasADi::DMatrix cast (const octave_value &value)
template<>
CasADi::DMatrix * cast (const octave_value &value)

Static Public Member Functions

template<typename T >
static T cast (const octave_value &value, xercesc::DOMDocument *doc)
template<typename T >
static T cast (const octave_value &value)
 see cast(const octave_value &value, shared_ptr<DOMDocument> &doc)
static ValueType getType (const octave_value &value)
 get the type of value

Protected Member Functions

void deinitOctave ()
 This function deinitialized octave. It is used in the dtor and before exceptions in the ctor are thrown.
octave_value fullStringToOctValue (const std::string &str, const xercesc::DOMElement *e=NULL) const
 evaluate str fully and return result as an octave variable
std::string partialStringToOctValue (const std::string &str, const xercesc::DOMElement *e) const
 evaluate str partially and return result as an std::string
void pushParams ()
 Push the current parameters to a internal stack.
void popParams ()
 Overwrite the current parameter with the top level set from the internal stack.
void pushPath ()
 Push the current path to a internal stack.
void popPath ()
 Overwrite the current path with the top level path from the internal stack.
octave_value handleUnit (const xercesc::DOMElement *e, const octave_value &ret)

Static Protected Member Functions

template<typename T >
static T castToSwig (const octave_value &value)
 cast value to the corresponding swig object of type T, without ANY type check.
static octave_value createCasADi (const std::string &name)
 create octave value of CasADi type name. Created using the default ctor.
static octave_value_list fevalThrow (octave_function *func, const octave_value_list &arg, int n=0, const std::string &msg=std::string())

Protected Attributes

std::vector
< boost::filesystem::path > * 
dependencies
std::unordered_map
< std::string, octave_value > 
currentParam
std::stack< std::unordered_map
< std::string, octave_value > > 
paramStack
std::stack< std::string > pathStack

Static Protected Attributes

static std::string initialPath
static std::string pathSep
static int initCount = 0
static std::map< std::string,
std::string > 
units
static InitXerces initXerces
static boost::scoped_ptr
< octave_value > 
casadiOctValue

Friends

class NewParamLevel

Detailed Description

Octave expression evaluator and converter.


Member Function Documentation

void MBXMLUtils::OctEval::addParamSet ( const xercesc::DOMElement *  e)

Add all parameters from XML element e. The parameters are added from top to bottom as they appear in the XML element e. Parameters may depend on parameters already added.

void MBXMLUtils::OctEval::addPath ( const boost::filesystem::path &  dir,
const xercesc::DOMElement *  e 
)

Add dir to octave search path A relative path in dir is expanded to an absolute path using the current directory.

template<typename T >
T MBXMLUtils::OctEval::cast ( const octave_value &  value,
xercesc::DOMDocument *  doc 
) [static]

Cast the octave value value to type T. Possible combinations of allowed octave value types and template types T are listed in the following table. If a combination is not allowed a exception is thrown, except for casts which are marked as not type save in the table. If a c-pointer is returned this c-pointer is only guaranteed to be valid for the lifetime of the octave object value being passed as argument. If a DOMElement* is returned doc must be given and ownes the memory of the returned DOM tree. For other return types this function must be called with only one argument cast(const octave_value &value);

value is of Octave Type ...
Template Type T equals ... real string SWIG CasADi::SXFunction SWIG CasADi::SX SWIG CasADi::DMatrix

SWIG XYZ

int only if 1 x 1 and a integral number only if 1 x 1 and constant and a integral number only if 1 x 1 and a integral number
double only if 1 x 1 only if 1 x 1 and constant only if 1 x 1
vector<double> only if n x 1 only if n x 1 and constant only if n x 1
vector<vector<double> > X only if constant X
string returns e.g. "5" or "[1,3;5,4]" returns e.g. "'foo'" only if constant; returns e.g. "5" or "[1,3;5,4]" returns e.g. "5" or "[1,3;5,4]"
DOMElement* X
CasADi::SXFunction X
CasADi::SXFunction* X
CasADi::SX X X X
CasADi::SX* X
CasADi::DMatrix X X X
CasADi::DMatrix* X
XYZ l not type save
XYZ* not type save
octave_value MBXMLUtils::OctEval::eval ( const xercesc::DOMElement *  e)

Evaluate the XML element e using the current parameters returning the resulting octave value. The type of evaluation depends on the type of e.

octave_value MBXMLUtils::OctEval::eval ( const xercesc::DOMAttr *  a,
const xercesc::DOMElement *  pe = NULL 
)

Evaluate the XML attribute a using the current parameters returning the resulting octave value. The type of evaluation depends on the type of a. The result of a "partially" evaluation is returned as a octave string even so it is not really a string.

octave_value MBXMLUtils::OctEval::stringToOctValue ( const std::string &  str,
const xercesc::DOMElement *  e = NULL,
bool  fullEval = true 
) const

evaluate str and return result as an octave variable, this can be used to evaluate outside of XML. If e is given it is used as location information in case of errors. If fullEval is false the "partially" evaluation is returned as a octave string even so it is not really a string.


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