#include "../../bdm/libconfig/libconfig.h++" #include #include #include using namespace itpp; using namespace std; using namespace libconfig; class UImxArray : public Config { public: UImxArray(const mxArray *mxarray) : Config() { Setting & setting = this->getRoot(); //setting is a group if (!mxIsStruct(mxarray)) { mexErrMsgTxt("Given mxArray is not a struct."); }; //mexCallMATLAB(0, NULL, 1, (mxArray **) &mxarray, "dump"); fillGroup(setting, mxarray); } private: void storeNumeric(Setting &setting, const mxArray *value, string key = "") { //TODO: integer matrices if (!mxIsNumeric(value)) { mexErrMsgTxt("Given mxArray is not numeric."); }; mat val = mxArray2mat(value); if ((val.rows() == 1) && (val.cols() == 1)) { Setting &child = (key=="") ? setting.add(Setting::TypeFloat) : setting.add(key, Setting::TypeFloat); child = val(0,0); } else { Setting &child = (key=="") ? setting.add(Setting::TypeList) : setting.add(key, Setting::TypeList); Setting &cols = child.add( Setting::TypeInt ); Setting &rows = child.add( Setting::TypeInt ); Setting &elements = child.add( Setting::TypeArray ); cols = val.cols(); rows = val.rows(); for (int i=0; i