validate_arg.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #include "mexErrMsgTxt.h"
  11. #include "../C_STR.h"
  12. IGL_INLINE void igl::matlab::validate_arg_scalar(
  13. const int i, const int nrhs, const mxArray * prhs[], const char * name)
  14. {
  15. requires_arg(i,nrhs,name);
  16. mexErrMsgTxt(mxGetN(prhs[i+1])==1 && mxGetM(prhs[i+1])==1,
  17. C_STR("Parameter '"<<name<<"' requires scalar argument"));
  18. }
  19. IGL_INLINE void igl::matlab::validate_arg_logical(
  20. const int i, const int nrhs, const mxArray * prhs[], const char * name)
  21. {
  22. requires_arg(i,nrhs,name);
  23. mexErrMsgTxt(mxIsLogical(prhs[i+1]),
  24. C_STR("Parameter '"<<name<<"' requires Logical argument"));
  25. }
  26. IGL_INLINE void igl::matlab::validate_arg_char(
  27. const int i, const int nrhs, const mxArray * prhs[], const char * name)
  28. {
  29. requires_arg(i,nrhs,name);
  30. mexErrMsgTxt(mxIsChar(prhs[i+1]),
  31. C_STR("Parameter '"<<name<<"' requires char argument"));
  32. }
  33. IGL_INLINE void igl::matlab::validate_arg_double(
  34. const int i, const int nrhs, const mxArray * prhs[], const char * name)
  35. {
  36. requires_arg(i,nrhs,name);
  37. mexErrMsgTxt(mxIsDouble(prhs[i+1]),
  38. C_STR("Parameter '"<<name<<"' requires double argument"));
  39. }