validate_arg.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #include "validate_arg.h"
  9. #include "requires_arg.h"
  10. IGL_INLINE void igl::matlab::validate_arg_scalar(
  11. const int i, const int nrhs, const mxArray * prhs[], const char * name)
  12. {
  13. requires_arg(i,nrhs,name);
  14. mexErrMsgTxt(mxGetN(prhs[i+1])==1 && mxGetM(prhs[i+1])==1,
  15. C_STR("Parameter '"<<name<<"' requires scalar argument"));
  16. }
  17. IGL_INLINE void igl::matlab::validate_arg_logical(
  18. const int i, const int nrhs, const mxArray * prhs[], const char * name)
  19. {
  20. requires_arg(i,nrhs,name);
  21. mexErrMsgTxt(mxIsLogical(prhs[i+1]),
  22. C_STR("Parameter '"<<name<<"' requires Logical argument"));
  23. }
  24. IGL_INLINE void igl::matlab::validate_arg_char(
  25. const int i, const int nrhs, const mxArray * prhs[], const char * name)
  26. {
  27. requires_arg(i,nrhs,name);
  28. mexErrMsgTxt(mxIsChar(prhs[i+1]),
  29. C_STR("Parameter '"<<name<<"' requires char argument"));
  30. }
  31. IGL_INLINE void igl::matlab::validate_arg_double(
  32. const int i, const int nrhs, const mxArray * prhs[], const char * name)
  33. {
  34. requires_arg(i,nrhs,name);
  35. mexErrMsgTxt(mxIsDouble(prhs[i+1]),
  36. C_STR("Parameter '"<<name<<"' requires double argument"));
  37. }