26 #if defined( MATLAB_MEX_FILE) 42 #if defined( MATLAB_MEX_FILE) 56 if( str && mxCHAR_CLASS == mxGetClassID( str ) )
58 size_t size = mxGetNumberOfElements( str ) + 1;
62 mxGetString( str, result, (
int)size );
83 result =
sizeof(mxChar);
87 result =
sizeof(double);
91 result =
sizeof(real32_T);
95 result =
sizeof(int8_T);
99 result =
sizeof(uint8_T);
103 result =
sizeof(int16_T);
107 result =
sizeof(uint16_T);
111 result =
sizeof(int32_T);
115 result =
sizeof(uint32_T);
136 unsigned char ch, *p = buffer ? buffer : &ch;
148 *p = ( s[0] << 6 ) | ( s[1] & 63 );
174 unsigned char ch[2], *p = buffer ? buffer : ch;
187 *p++ = 128 + 64 + ( *s >> 6 );
188 *p++ = 128 + ( *s++ & 63 );
215 if( flagConvertUTF8 )
222 newstr = (
char*)
MEM_ALLOC( buflen,
sizeof(
char) );
233 newstr = (
char*)
MEM_ALLOC( strlen(s) + 1,
sizeof(char) );
257 while( p && ( *p = ::tolower(*p) ) )
294 #if defined( MATLAB_MEX_FILE) 307 mxArray* tmp = pmxarr;
309 mxDestroyArray( tmp );
352 LARGE_INTEGER time,freq;
354 if( !QueryPerformanceFrequency( &freq ) )
360 if( !QueryPerformanceCounter( &time ) )
366 return (
double)time.QuadPart / freq.QuadPart;
373 if( GetProcessTimes( GetCurrentProcess(), &a, &b, &c, &d ) != 0 )
378 (
double)( d.dwLowDateTime |
379 ( (
unsigned long long)d.dwHighDateTime << 32 ) ) * 0.0000001;
391 #include <sys/time.h> 396 if( gettimeofday( &time, NULL ) )
402 return (
double)time.tv_sec + (double)time.tv_usec * .000001;
407 return (
double)clock() / CLOCKS_PER_SEC;
char * utils_strlwr(char *)
Change string to lowercase (inplace)
size_t utils_elbytes(mxClassID classID)
Get the size of one element in bytes.
double utils_get_wall_time()
Returns current counter time in seconds.
double utils_get_cpu_time()
Returns user mode time of current process in seconds.
#define MEM_FREE(ptr)
standard memory free function
void utils_destroy_array(mxArray *&pmxarr)
Freeing memory allocated by mxCreateNumericMatrix() or mxCreateNumericArray().
int utils_utf2latin(const unsigned char *s, unsigned char *buffer)
Convert UTF-8 string to char string.
void utils_free_ptr(T *&pmxarr)
Freeing memory allocated by mxAlloc() or mxRealloc()
char * utils_strnewdup(const char *s, int flagConvertUTF8)
duplicate a string and recode from UTF8 to char due to flag flagConvertUTF8
int utils_latin2utf(const unsigned char *s, unsigned char *buffer)
Convert char string to UTF-8 string.
char * utils_getString(const mxArray *str)
Copy string characters into allocated memory.
#define MEM_ALLOC(count, bytes)
standard memory allocator