/*!\file CheckNumMatlabArguments.cpp:
 * \brief: check number of arguments and report an usage error message.
 */

#ifdef _SERIAL_

#include "../Exceptions/exceptions.h"
#include "mex.h"

int CheckNumMatlabArguments(int nlhs,int NLHS, int nrhs,int NRHS, char* __FUNCT__, void (*function)( void )){
	
	/*checks on arguments on the matlab side: */
	if (nrhs==0 && nlhs==0) {
		/*unless NLHS=0 and NRHS=0, we are just asking for documentation: */
		if (NRHS==0 && NLHS==0)return 1;
		/* special case: */
		function();
		throw ErrorException(__FUNCT__," usage: see above");
	}
	else if ( nlhs!=NLHS || nrhs!=NRHS ) {
		function(); 
		throw ErrorException(__FUNCT__," usage error.");
	}
	return 1;
}

#endif
