-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgeneral.h
53 lines (42 loc) · 1.49 KB
/
general.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef DSL_GENERAL_H
#define DSL_GENERAL_H
// {{SMILE_PUBLIC_HEADER}}
#include <string>
#include <cstdio>
#include <ctime>
#include <cmath>
#include "constants.h"
#include "errors.h"
#define DSL_FALSE 0
#define DSL_TRUE 1
#define DSL_FILE_LINE_LENGTH 1021
#define DSL_FILE_TOKEN_LENGTH (10 * DSL_FILE_LINE_LENGTH)
#define DSL_NUMBER_PRECISION 8
#define DSL_EPSILON 0.000005
#if defined(_WIN32)
#define DSL_stricmp _stricmp
#define DSL_strnicmp _strnicmp
inline bool DSL_isnan(double x) { return _isnan(x) != 0; }
#else
#define DSL_stricmp strcasecmp
#define DSL_strnicmp strncasecmp
inline bool DSL_isnan(double x) { /*using namespace std;*/ return std::isnan(x) != 0; }
#endif
#ifdef WINCE
void* bsearch(const void *, const void *, size_t, size_t, int (__cdecl *) (const void *, const void *));
inline double difftime(time_t a, time_t b) { return (double)(b - a); }
#endif
time_t DSL_time(time_t *);
clock_t DSL_clock();
inline bool DSL_isFinite(double x)
{
return !DSL_isnan(x) && x <= DBL_MAX && x >= -DBL_MAX;
}
// Global Functions
int DSL_stringToDouble(const char *theString, double &here);
int DSL_doubleToString(double theNumber, char *here, int precission = DSL_NUMBER_PRECISION);
int DSL_intToString(int theNumber, char *here);
int DSL_stringToInt(char *theString, int &here);
bool DSL_nameToIdentifier(std::string &s, int outcomeIndex = -1);
void DSL_appendInt(std::string &s, int x);
#endif // DSL_GENERAL_H