Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for tyre data files which are basically INI files with … #23

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
202 changes: 88 additions & 114 deletions ExternData/Examples/package.mo

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions ExternData/Examples/package.order
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
CSVTest
INITest
JSONTest
MATTest
XLSTest
XLSXTest
XMLTest
CSVTest
INITest
JSONTest
MATTest
XLSTest
XLSXTest
XMLTest
TIRTest
8 changes: 4 additions & 4 deletions ExternData/Resources/C-Sources/ED_INIFile.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void ED_destroyINI(void* _ini)
}
}

double ED_getDoubleFromINI(void* _ini, const char* varName, const char* section)
double ED_getDoubleFromINI(void* _ini, const char* varName, const char* section, int strict)
{
double ret = 0.;
INIFile* ini = (INIFile*)_ini;
Expand All @@ -169,7 +169,7 @@ double ED_getDoubleFromINI(void* _ini, const char* varName, const char* section)
if (_section != NULL) {
INIPair* pair = findKey(_section, varName);
if (pair != NULL) {
if (ED_strtod(pair->value, ini->loc, &ret)) {
if (ED_strtod(pair->value, ini->loc, &ret, strict)) {
ModelicaFormatError("Cannot read double value \"%s\" from file \"%s\"\n",
pair->value, ini->fileName);
}
Expand Down Expand Up @@ -224,7 +224,7 @@ const char* ED_getStringFromINI(void* _ini, const char* varName, const char* sec
return "";
}

int ED_getIntFromINI(void* _ini, const char* varName, const char* section)
int ED_getIntFromINI(void* _ini, const char* varName, const char* section, int strict)
{
long ret = 0;
INIFile* ini = (INIFile*)_ini;
Expand All @@ -233,7 +233,7 @@ int ED_getIntFromINI(void* _ini, const char* varName, const char* section)
if (_section != NULL) {
INIPair* pair = findKey(_section, varName);
if (pair != NULL) {
if (ED_strtol(pair->value, ini->loc, &ret)) {
if (ED_strtol(pair->value, ini->loc, &ret, strict)) {
ModelicaFormatError("Cannot read int value \"%s\" from file \"%s\"\n",
pair->value, ini->fileName);
}
Expand Down
20 changes: 12 additions & 8 deletions ExternData/Resources/C-Sources/ED_locale.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,30 @@ enum {
#define ED_INIT_LOCALE _create_locale(LC_NUMERIC, "C")
#define ED_FREE_LOCALE(loc) _free_locale(loc)

static __inline int ED_strtod(char* token, ED_LOCALE_TYPE loc, double* val)
static __inline int ED_strtod(char* token, ED_LOCALE_TYPE loc, double* val, int strict)
{
int ret = ED_OK;
char* endptr;
*val = _strtod_l(token, &endptr, loc);
if (*endptr != 0) {
*val = 0.;
ret = ED_ERROR;
if (strict == 1) {
if (*endptr != 0) {
*val = 0.;
ret = ED_ERROR;
}
}
return ret;
}

static __inline int ED_strtol(char* token, ED_LOCALE_TYPE loc, long* val)
static __inline int ED_strtol(char* token, ED_LOCALE_TYPE loc, long* val, int strict)
{
int ret = ED_OK;
char* endptr;
*val = _strtol_l(token, &endptr, 10, loc);
if (*endptr != 0) {
*val = 0;
ret = ED_ERROR;
if (strict == 1) {
if (*endptr != 0) {
*val = 0;
ret = ED_ERROR;
}
}
return ret;
}
Expand Down
257 changes: 257 additions & 0 deletions ExternData/Resources/Examples/sample.tir

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions ExternData/Resources/Include/ED_INIFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@

void* ED_createINI(const char* fileName, int verbose);
void ED_destroyINI(void* _ini);
double ED_getDoubleFromINI(void* _ini, const char* varName, const char* section);
double ED_getDoubleFromINI(void* _ini, const char* varName, const char* section, int strict);
const char* ED_getStringFromINI(void* _ini, const char* varName, const char* section);
int ED_getIntFromINI(void* _ini, const char* varName, const char* section);
int ED_getIntFromINI(void* _ini, const char* varName, const char* section, int strict);

#endif
Binary file modified ExternData/Resources/Library/win32/ED_INIFile.lib
Binary file not shown.
Binary file modified ExternData/Resources/Library/win32/ITI_ED_INIFile.dll
Binary file not shown.
Binary file modified ExternData/Resources/Library/win32/bsxml-json.lib
Binary file not shown.
Binary file modified ExternData/Resources/Library/win64/ED_INIFile.lib
Binary file not shown.
Binary file modified ExternData/Resources/Library/win64/ITI_ED_INIFile.dll
Binary file not shown.
Binary file modified ExternData/Resources/Library/win64/bsxml-json.lib
Binary file not shown.
281 changes: 187 additions & 94 deletions ExternData/package.mo

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions ExternData/package.order
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ MATFile
XLSFile
XLSXFile
XMLFile
TIRFile
Functions
Interfaces
Types