vars: added code to read AQH_VARS from GWEN_DB strings.
This commit is contained in:
@@ -128,6 +128,25 @@ void AQH_Vars_free(AQH_VARS *vt)
|
||||
|
||||
|
||||
|
||||
AQH_VARS_DATATYPE AQH_Vars_DataTypeFromString(const char *s)
|
||||
{
|
||||
if (s && *s) {
|
||||
if (strcasecmp(s, "group")==0)
|
||||
return AQH_Vars_DataType_Group;
|
||||
else if (strcasecmp(s, "variable")==0)
|
||||
return AQH_Vars_DataType_Variable;
|
||||
else if (strcasecmp(s, "char")==0)
|
||||
return AQH_Vars_DataType_ValueString;
|
||||
else if (strcasecmp(s, "int")==0)
|
||||
return AQH_Vars_DataType_ValueInt;
|
||||
else if (strcasecmp(s, "double")==0)
|
||||
return AQH_Vars_DataType_ValueDouble;
|
||||
}
|
||||
return AQH_Vars_DataType_Unknown;
|
||||
}
|
||||
|
||||
|
||||
|
||||
AQH_VARS *AQH_Vars_dup(const AQH_VARS *vt)
|
||||
{
|
||||
AQH_VARS *vtCopy;
|
||||
@@ -215,7 +234,14 @@ const char *AQH_Vars_GetStringData(const AQH_VARS *vt, const char *defValue)
|
||||
case AQH_Vars_DataType_Variable:
|
||||
case AQH_Vars_DataType_ValueString:
|
||||
return vt->data.dataString;
|
||||
case AQH_Vars_DataType_ValueInt:
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Unexpected type INT: %d", vt->data.dataInt);
|
||||
break;
|
||||
case AQH_Vars_DataType_ValueDouble:
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Unexpected type DOUBLE: %f", vt->data.dataDouble);
|
||||
break;
|
||||
default:
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Unexpected type %d", vt->dataType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -348,10 +374,8 @@ const char *AQH_Vars_GetCharValue(AQH_VARS *vt, const char *path, int idx, const
|
||||
AQH_VARS *vtValue;
|
||||
|
||||
vtChild=_getPath(vt, path, AQH_PATH_FLAGS_PATHMUSTEXIST | AQH_PATH_FLAGS_VARIABLE);
|
||||
if (vtChild==NULL) {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Path for var \"%s\" not found", path);
|
||||
if (vtChild==NULL)
|
||||
return defaultValue;
|
||||
}
|
||||
vtValue=_getValueNodeByIdx(vtChild, idx);
|
||||
if (vtValue)
|
||||
return AQH_Vars_GetStringData(vtValue, defaultValue);
|
||||
@@ -388,10 +412,9 @@ int AQH_Vars_GetIntValue(AQH_VARS *vt, const char *path, int idx, int defaultVal
|
||||
AQH_VARS *vtValue;
|
||||
|
||||
vtChild=_getPath(vt, path, AQH_PATH_FLAGS_PATHMUSTEXIST | AQH_PATH_FLAGS_VARIABLE);
|
||||
if (vtChild==NULL) {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Path for var \"%s\" not found", path);
|
||||
if (vtChild==NULL)
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
vtValue=_getValueNodeByIdx(vtChild, idx);
|
||||
if (vtValue)
|
||||
return AQH_Vars_GetIntData(vtValue, defaultValue);
|
||||
@@ -428,10 +451,8 @@ double AQH_Vars_GetDoubleValue(AQH_VARS *vt, const char *path, int idx, double d
|
||||
AQH_VARS *vtValue;
|
||||
|
||||
vtChild=_getPath(vt, path, AQH_PATH_FLAGS_PATHMUSTEXIST | AQH_PATH_FLAGS_VARIABLE);
|
||||
if (vtChild==NULL) {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Path for var \"%s\" not found", path);
|
||||
if (vtChild==NULL)
|
||||
return defaultValue;
|
||||
}
|
||||
vtValue=_getValueNodeByIdx(vtChild, idx);
|
||||
if (vtValue)
|
||||
return AQH_Vars_GetDoubleData(vtValue, defaultValue);
|
||||
@@ -528,7 +549,7 @@ AQH_VARS *_getNodeByTypeAndName(const AQH_VARS *vt, AQH_VARS_DATATYPE dt, const
|
||||
/* look it up */
|
||||
vtChild=AQH_Vars_GetFirstChildByType(vt, dt);
|
||||
while(vtChild) {
|
||||
if (vtChild->data.dataString && strcasecmp(vtChild->data.dataString, name)!=-1) {
|
||||
if (vtChild->data.dataString && strcasecmp(vtChild->data.dataString, name)==0) {
|
||||
if (idx==0)
|
||||
break;
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user