Get processed contents from IFT.
More...
#include "tpcclibConfig.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include "tpcift.h"
Go to the source code of this file.
|
| int | iftGetFloat (IFT *ift, int index, float *v) |
| |
| int | iftGetDouble (IFT *ift, int index, double *v) |
| |
| int | iftGetInt (IFT *ift, int index, int *v) |
| |
| int | iftGetUInt (IFT *ift, int index, unsigned int *v) |
| |
| int | iftGetDoubleWithUnit (IFT *ift, int index, double *v, int *unit) |
| |
Get processed contents from IFT.
Definition in file iftget.c.
◆ iftGetDouble()
| int iftGetDouble |
( |
IFT * | ift, |
|
|
int | index, |
|
|
double * | v ) |
Read the value in IFT as a double from given item index.
Value in IFT must not contain decimal comma.
- See also
- iftGetFloat, iftGetDoubleWithUnit, iftFindKey, iftPutDouble
- Returns
- 0 if successful, <>0 in case of an error.
- Author
- Vesa Oikonen
- Parameters
-
| ift | Pointer to IFT |
| index | IFT item index |
| v | Pointer to double which is read from item value. It will be set to NaN in case of an error. |
Definition at line 52 of file iftget.c.
60 {
61 if(v!=NULL) *v=nan(""); else return -2;
62 if(ift==NULL) return -2;
63 if(index<0 || index>=ift->
keyNr)
return -2;
64 if(ift->
item[index].
value==NULL)
return -1;
65 if(sscanf(ift->
item[index].
value,
"%lf", v)!=1 || isnan(*v))
return -1;
66 return 0;
67}
Referenced by parFromIFT().
◆ iftGetDoubleWithUnit()
| int iftGetDoubleWithUnit |
( |
IFT * | ift, |
|
|
int | index, |
|
|
double * | v, |
|
|
int * | unit ) |
Read the value in IFT as a double with unit from given item index.
Value in IFT is allowed to be written with decimal comma, and units may be written in pars () or [].
- See also
- iftGetDouble, iftFindKey, iftSearchKey, iftSearchValue
- Returns
- 0 if at least the double was found, otherwise <>0.
- Author
- Vesa Oikonen
- Parameters
-
| ift | Pointer to IFT |
| index | IFT item index |
| v | Pointer to double which is read from item value. It will be set to NaN in case of an error. |
| unit | Pointer for unit (enum unit) which is read from item value. It will be to 0 (enum UNIT_UNKNOWN) if not identified or not present. |
Definition at line 129 of file iftget.c.
140 {
141 if(v!=NULL) *v=nan("");
143 if(ift==NULL) return(2);
144 if(index<0 || index>=ift->
keyNr)
return(1);
145 if(ift->
item[index].
value==NULL)
return(2);
146 char s[128];
149 if(
unit==NULL)
return(0);
152 return 0;
153}
double atofVerified(const char *s)
void strCleanPars(char *s)
int strTokenNCpy(const char *s1, const char *s2, int i, char *s3, int count)
@ UNIT_UNKNOWN
Unknown unit.
int unitIdentify(const char *s)
Referenced by parReadCSV().
◆ iftGetFloat()
| int iftGetFloat |
( |
IFT * | ift, |
|
|
int | index, |
|
|
float * | v ) |
Read the value in IFT as a float from given item index.
Value in IFT must not contain decimal comma.
- See also
- iftGetDouble, iftFindKey, iftGetInt, iftSearchKey
- Returns
- 0 if successful, <>0 in case of an error.
- Author
- Vesa Oikonen
- Parameters
-
| ift | Pointer to IFT |
| index | IFT item index |
| v | Pointer to float which is read from item value. It will be set to NaN in case of an error. |
Definition at line 25 of file iftget.c.
33 {
34 if(v!=NULL) *v=nanf(""); else return -2;
35 if(ift==NULL) return -2;
36 if(index<0 || index>=ift->
keyNr)
return -2;
37 if(ift->
item[index].
value==NULL)
return -1;
38 if(sscanf(ift->
item[index].
value,
"%f", v)!=1 || isnan(*v))
return -1;
39 return 0;
40}
◆ iftGetInt()
| int iftGetInt |
( |
IFT * | ift, |
|
|
int | index, |
|
|
int * | v ) |
Read the value in IFT as an integer from given item index.
- See also
- iftGetUInt, iftGetDouble, iftFindKey, iftGetUInt, iftPutInt
- Returns
- 0 if successful, <>0 in case of an error.
- Author
- Vesa Oikonen
- Parameters
-
| ift | Pointer to IFT |
| index | IFT item index |
| v | Pointer to int which is read from item value. It will be set to -9999 in case of an error. |
Definition at line 76 of file iftget.c.
84 {
85 if(v!=NULL) *v=-9999; else return -2;
86 if(ift==NULL) return -2;
87 if(index<0 || index>=ift->
keyNr)
return -2;
88 if(ift->
item[index].
value==NULL)
return -1;
89 if(sscanf(ift->
item[index].
value,
"%d", v)!=1 || *v==-9999)
return -1;
90 return 0;
91}
Referenced by parFromIFT(), and parReadCSV().
◆ iftGetUInt()
| int iftGetUInt |
( |
IFT * | ift, |
|
|
int | index, |
|
|
unsigned int * | v ) |
Read the value in IFT as an unsigned integer from given item index.
- See also
- iftGetDouble, iftFindKey, iftSearchKey, iftSearchValue, iftGetInt, iftPutUint
- Returns
- 0 if successful, <>0 in case of an error.
- Author
- Vesa Oikonen
- Parameters
-
| ift | Pointer to IFT |
| index | IFT item index |
| v | Pointer to unsigned int which is read from item value. It will be set to 0 in case of an error. |
Definition at line 101 of file iftget.c.
109 {
110 if(v!=NULL) *v=0; else return -2;
111 if(ift==NULL) return -2;
112 if(index<0 || index>=ift->
keyNr)
return -2;
113 if(ift->
item[index].
value==NULL)
return -1;
114 if(sscanf(ift->
item[index].
value,
"%ud", v)!=1)
return -1;
115 return 0;
116}
Referenced by parFromIFT().