{{arg.tp}} {{arg.name}} = inputs[{{ loop.index0 }}].to{{arg.tp|toUpperCamelCase}}();
{% endfor %}
{% for opt in fun.opt|inputs %}
- {{opt.tp}} {{opt.name}} = (nrhs > {{loop.index0 + fun.req|inputs|length}}) ? inputs[{{loop.index0 + fun.req|inputs|length}}].to{{opt.tp|toUpperCamelCase}}() : {% if opt.ref == '*' -%} {{opt.tp}}() {%- else -%} {{opt.default}} {%- endif %};
+ {{opt.tp}} {{opt.name}} = inputs[{{loop.index0 + fun.req|inputs|length}}].empty() ? {% if opt.ref == '*' -%} {{opt.tp}}() {%- else -%} {{opt.default}} {%- endif %} : inputs[{{loop.index0 + fun.req|inputs|length}}].to{{opt.tp|toUpperCamelCase}}();
{% endfor %}
{# ----------- Outputs ------------ #}
{% for arg in fun.req|only|outputs %}
ArgumentParser parser("{{fun.name}}");
parser.{{ functional.composeVariant(fun) }};
MxArrayVector sorted = parser.parse(MxArrayVector(prhs, prhs+nrhs));
- {%endif %}
+ {% endif %}
{% if fun|ninputs or fun|noutputs %}
// setup
Bridge() {}
virtual ~Bridge() {}
+ // --------------------------------------------------------------------------
+ // Bridge Properties
+ // --------------------------------------------------------------------------
+ bool empty() const { return ptr_.empty(); }
+
/*! @brief unpack an object from Matlab into C++
*
* this function checks whether the given bridge is derived from an
/*!
* @brief default constructor
*
- * Construct a valid 0x0 matrix (so all other methods do not need validity checks
+ * Construct a valid 0x0 matrix (so all other methods do not need validity checks)
*/
- MxArray() : ptr_(mxCreateDoubleMatrix(1, 1, matlab::Traits<>::Real)), owns_(true) {}
+ MxArray() : ptr_(mxCreateDoubleMatrix(0, 0, matlab::Traits<>::Real)), owns_(true) {}
/*!
* @brief inheriting constructor
}
size_t size() const { return mxGetNumberOfElements(ptr_); }
+ bool empty() const { return size() == 0; }
size_t rows() const { return mxGetDimensions(ptr_)[0]; }
size_t cols() const { return mxGetDimensions(ptr_)[1]; }
size_t channels() const { return (mxGetNumberOfDimensions(ptr_) > 2) ? mxGetDimensions(ptr_)[2] : 1; }