cantera/src/matlab/ctmatutils.h
Ray Speth 2528df0f75 Reorganized source tree structure
These changes make it unnecessary to copy header files around during
the build process, which tends to confuse IDEs and debuggers. The
headers which comprise Cantera's external C++ interface are now in
the 'include' directory.

All of the samples and demos are now in the 'samples' subdirectory.
2012-02-12 02:27:14 +00:00

56 lines
1.2 KiB
C++

#ifndef CT_MATUTILS_H
#define CT_MATUTILS_H
const double Undef = -999.123;
//const double DERR = -999.999;
#include <string>
// Workaround for VS2010 and Matlab 2010a.
// mex.h must be included after <string> or another include from
// the standard library which includes <yvals.h>.
#if (_MSC_VER >= 1600) && defined(_CHAR16T)
#define CHAR16_T char16_t
#endif
#include "mex.h"
void reportError();
void checkNArgs(const int n, const int nrhs);
template<class A>
inline int getInt(A* mxhndl)
{
return int(mxGetScalar(mxhndl));
}
template<class A>
inline double getDouble(A* mxhndl)
{
return double(mxGetScalar(mxhndl));
}
inline char* getString(const mxArray* p)
{
char* input_buf = 0;
int status;
size_t m = mxGetM(p);
size_t n = mxGetN(p);
mwSize buflen = (mwSize)(m*n + 1);
std::string msg;
if (m == 1) {
input_buf = (char*)mxCalloc(buflen, sizeof(char));
status = mxGetString(p, input_buf, buflen);
if (status != 0) {
msg = std::string(input_buf)
+ "\nNot enough space. String is truncated.";
mexWarnMsgTxt(msg.c_str());
}
} else {
mexErrMsgTxt("string must be a row vector");
}
return input_buf;
}
#endif