Skip to content
Snippets Groups Projects
Commit 3ad076bf authored by patmjen's avatar patmjen
Browse files

Add MATLAB util. funs. for arg. count check

parent 27946bcc
Branches
No related tags found
No related merge requests found
......@@ -56,6 +56,20 @@ void ensureSize(const mxArray* a, std::initializer_list<int> size, const std::st
}
}
void ensureArgCount(int narg, int num)
{
ensureOrError(narg == num, "Must supply %d inputs", num);
}
void ensureArgRange(int narg, int min, int max)
{
if (min == max) {
ensureArgCount(narg, min);
} else {
ensureOrError(min <= narg && narg <= max, "Must supply between %d and %d inputs", min, max);
}
}
int getMaxCompThreads()
{
mxArray *matlabCallOut[1] = { 0 };
......
......@@ -150,6 +150,10 @@ inline void ensureMatchingClass(const mxArray *a, const std::string& errPrefixSt
errPrefix, getClassNameFromId(typeClassId<Ty>), mxGetClassName(a));
}
void ensureArgCount(int narg, int num);
void ensureArgRange(int narg, int min, int max);
template <class Ty>
inline Ty getCastScalarChecked(const mxArray *a, const std::string& errPrefixStr = "Value")
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment