aqhome-react, aqhome: added units/functions for handling local variables.
This commit is contained in:
@@ -87,6 +87,36 @@ void _releaseData(AQH_VARS *vt)
|
||||
|
||||
|
||||
|
||||
AQH_VARS *_dupData(const AQH_VARS *vt)
|
||||
{
|
||||
if (vt) {
|
||||
AQH_VARS *vtCopy;
|
||||
|
||||
vtCopy=_newData();
|
||||
vtCopy->dataType=vt->dataType;
|
||||
switch(vt->dataType) {
|
||||
case AQH_Vars_DataType_Unknown:
|
||||
break;
|
||||
case AQH_Vars_DataType_Group:
|
||||
case AQH_Vars_DataType_Variable:
|
||||
case AQH_Vars_DataType_ValueString:
|
||||
vtCopy->data.dataString=(vt->data.dataString)?strdup(vt->data.dataString):NULL;
|
||||
break;
|
||||
case AQH_Vars_DataType_ValueInt:
|
||||
vtCopy->data.dataInt=vt->data.dataInt;
|
||||
break;
|
||||
case AQH_Vars_DataType_ValueDouble:
|
||||
vtCopy->data.dataDouble=vt->data.dataDouble;
|
||||
break;
|
||||
}
|
||||
|
||||
return vtCopy;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_Vars_free(AQH_VARS *vt)
|
||||
{
|
||||
if (vt) {
|
||||
@@ -98,6 +128,24 @@ void AQH_Vars_free(AQH_VARS *vt)
|
||||
|
||||
|
||||
|
||||
AQH_VARS *AQH_Vars_dup(const AQH_VARS *vt)
|
||||
{
|
||||
AQH_VARS *vtCopy;
|
||||
AQH_VARS *vtChild;
|
||||
|
||||
vtCopy=_dupData(vt);
|
||||
vtChild=AQH_Vars_Tree2_GetFirstChild(vt);
|
||||
while(vtChild) {
|
||||
AQH_Vars_Tree2_AddChild(vtCopy, _dupData(vtChild));
|
||||
vtChild=AQH_Vars_Tree2_GetNext(vtChild);
|
||||
}
|
||||
|
||||
return vtCopy;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
AQH_VARS *AQH_Vars_CreateGroup(const char *s)
|
||||
{
|
||||
return _newStringElement(s?strdup(s):NULL, AQH_Vars_DataType_Group);
|
||||
@@ -266,6 +314,13 @@ AQH_VARS *AQH_Vars_GetNextByType(const AQH_VARS *vt, AQH_VARS_DATATYPE dt)
|
||||
|
||||
|
||||
|
||||
AQH_VARS *AQH_Vars_GetGroup(AQH_VARS *vt, const char *path, uint32_t flags)
|
||||
{
|
||||
return vt?_getPath(vt, path, (flags & ~AQH_PATH_FLAGS_VARIABLE)):NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int AQH_Vars_SetCharValue(AQH_VARS *vt, uint32_t flags, const char *path, const char *value)
|
||||
{
|
||||
if (vt) {
|
||||
@@ -404,8 +459,6 @@ AQH_VARS *_getValueNodeByIdx(const AQH_VARS *vt, int idx)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
AQH_VARS *_getPath(AQH_VARS *vt, const char *s, uint32_t flags)
|
||||
{
|
||||
return (AQH_VARS *)AQH_Path_Handle(s, (void*) vt, flags, "/", _pathHandlerFn);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#ifndef AQH_VARS_H
|
||||
#define AQH_VARS_H
|
||||
|
||||
#include <aqhome/api.h>
|
||||
|
||||
#include <gwenhywfar/tree2.h>
|
||||
|
||||
@@ -30,43 +31,53 @@ typedef enum {
|
||||
|
||||
|
||||
typedef struct AQH_VARS AQH_VARS;
|
||||
GWEN_TREE2_FUNCTION_DEFS(AQH_VARS, AQH_Vars);
|
||||
GWEN_TREE2_FUNCTION_LIB_DEFS(AQH_VARS, AQH_Vars, AQHOME_API);
|
||||
|
||||
|
||||
AQH_VARS *AQH_Vars_CreateGroup(const char *s);
|
||||
AQH_VARS *AQH_Vars_CreateVariable(const char *s);
|
||||
AQH_VARS *AQH_Vars_CreateStringValue(char *s);
|
||||
AQH_VARS *AQH_Vars_CreateIntValue(int d);
|
||||
AQH_VARS *AQH_Vars_CreateDoubleValue(double d);
|
||||
AQHOME_API AQH_VARS *AQH_Vars_CreateGroup(const char *s);
|
||||
AQHOME_API AQH_VARS *AQH_Vars_CreateVariable(const char *s);
|
||||
AQHOME_API AQH_VARS *AQH_Vars_CreateStringValue(char *s);
|
||||
AQHOME_API AQH_VARS *AQH_Vars_CreateIntValue(int d);
|
||||
AQHOME_API AQH_VARS *AQH_Vars_CreateDoubleValue(double d);
|
||||
|
||||
void AQH_Vars_free(AQH_VARS *vt);
|
||||
AQHOME_API AQH_VARS *AQH_Vars_dup(const AQH_VARS *vt);
|
||||
|
||||
AQHOME_API void AQH_Vars_free(AQH_VARS *vt);
|
||||
|
||||
|
||||
AQH_VARS_DATATYPE AQH_Vars_GetDataType(const AQH_VARS *vt);
|
||||
uint32_t AQH_Vars_GetFlags(const AQH_VARS *vt);
|
||||
AQHOME_API AQH_VARS_DATATYPE AQH_Vars_GetDataType(const AQH_VARS *vt);
|
||||
AQHOME_API uint32_t AQH_Vars_GetFlags(const AQH_VARS *vt);
|
||||
|
||||
const char *AQH_Vars_GetStringData(const AQH_VARS *vt, const char *defValue);
|
||||
void AQH_Vars_SetStringData(AQH_VARS *vt, char *s);
|
||||
AQHOME_API const char *AQH_Vars_GetStringData(const AQH_VARS *vt, const char *defValue);
|
||||
AQHOME_API void AQH_Vars_SetStringData(AQH_VARS *vt, char *s);
|
||||
|
||||
int AQH_Vars_GetIntData(const AQH_VARS *vt, int defValue);
|
||||
void AQH_Vars_SetIntData(AQH_VARS *vt, int d);
|
||||
AQHOME_API int AQH_Vars_GetIntData(const AQH_VARS *vt, int defValue);
|
||||
AQHOME_API void AQH_Vars_SetIntData(AQH_VARS *vt, int d);
|
||||
|
||||
double AQH_Vars_GetDoubleData(const AQH_VARS *vt, double defValue);
|
||||
void AQH_Vars_SetDoubleData(AQH_VARS *vt, double d);
|
||||
AQHOME_API double AQH_Vars_GetDoubleData(const AQH_VARS *vt, double defValue);
|
||||
AQHOME_API void AQH_Vars_SetDoubleData(AQH_VARS *vt, double d);
|
||||
|
||||
|
||||
AQH_VARS *AQH_Vars_GetFirstChildByType(const AQH_VARS *vt, AQH_VARS_DATATYPE dt);
|
||||
AQH_VARS *AQH_Vars_GetNextByType(const AQH_VARS *vt, AQH_VARS_DATATYPE dt);
|
||||
AQHOME_API AQH_VARS *AQH_Vars_GetFirstChildByType(const AQH_VARS *vt, AQH_VARS_DATATYPE dt);
|
||||
AQHOME_API AQH_VARS *AQH_Vars_GetNextByType(const AQH_VARS *vt, AQH_VARS_DATATYPE dt);
|
||||
|
||||
|
||||
int AQH_Vars_SetCharValue(AQH_VARS *vt, uint32_t flags, const char *path, const char *value);
|
||||
const char *AQH_Vars_GetCharValue(AQH_VARS *vt, const char *path, int idx, const char *defaultValue);
|
||||
|
||||
int AQH_Vars_SetIntValue(AQH_VARS *vt, uint32_t flags, const char *path, int value);
|
||||
int AQH_Vars_GetIntValue(AQH_VARS *vt, const char *path, int idx, int defaultValue);
|
||||
/**
|
||||
* @name Functions Using Paths
|
||||
*/
|
||||
/*@{*/
|
||||
AQHOME_API AQH_VARS *AQH_Vars_GetGroup(AQH_VARS *vt, const char *path, uint32_t flags);
|
||||
|
||||
int AQH_Vars_SetDoubleValue(AQH_VARS *vt, uint32_t flags, const char *path, double value);
|
||||
double AQH_Vars_GetDoubleValue(AQH_VARS *vt, const char *path, int idx, double defaultValue);
|
||||
AQHOME_API int AQH_Vars_SetCharValue(AQH_VARS *vt, uint32_t flags, const char *path, const char *value);
|
||||
AQHOME_API const char *AQH_Vars_GetCharValue(AQH_VARS *vt, const char *path, int idx, const char *defaultValue);
|
||||
|
||||
AQHOME_API int AQH_Vars_SetIntValue(AQH_VARS *vt, uint32_t flags, const char *path, int value);
|
||||
AQHOME_API int AQH_Vars_GetIntValue(AQH_VARS *vt, const char *path, int idx, int defaultValue);
|
||||
|
||||
AQHOME_API int AQH_Vars_SetDoubleValue(AQH_VARS *vt, uint32_t flags, const char *path, double value);
|
||||
AQHOME_API double AQH_Vars_GetDoubleValue(AQH_VARS *vt, const char *path, int idx, double defaultValue);
|
||||
/*@}*/
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user