aqhome: added AQH_Vars_Dump().
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include <gwenhywfar/misc.h>
|
#include <gwenhywfar/misc.h>
|
||||||
#include <gwenhywfar/debug.h>
|
#include <gwenhywfar/debug.h>
|
||||||
|
#include <gwenhywfar/buffer.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -35,6 +36,7 @@ static AQH_VARS *_getValueNodeByIdx(const AQH_VARS *vt, int idx);
|
|||||||
static AQH_VARS *_getPath(AQH_VARS *vt, const char *s, uint32_t flags);
|
static AQH_VARS *_getPath(AQH_VARS *vt, const char *s, uint32_t flags);
|
||||||
static void *_pathHandlerFn(const char *entry, void *data, int idx, uint32_t flags);
|
static void *_pathHandlerFn(const char *entry, void *data, int idx, uint32_t flags);
|
||||||
static AQH_VARS *_getNodeByTypeAndName(const AQH_VARS *vt, AQH_VARS_DATATYPE dt, const char *name, int idx);
|
static AQH_VARS *_getNodeByTypeAndName(const AQH_VARS *vt, AQH_VARS_DATATYPE dt, const char *name, int idx);
|
||||||
|
static void _dumpElement(const AQH_VARS *vt, int indent, GWEN_BUFFER *dbuf);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -580,6 +582,54 @@ AQH_VARS *_getNodeByTypeAndName(const AQH_VARS *vt, AQH_VARS_DATATYPE dt, const
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQH_Vars_Dump(const AQH_VARS *vt, int indent)
|
||||||
|
{
|
||||||
|
GWEN_BUFFER *dbuf;
|
||||||
|
|
||||||
|
dbuf=GWEN_Buffer_new(0, 256, 0, 1);
|
||||||
|
_dumpElement(vt, indent, dbuf);
|
||||||
|
fprintf(stderr, "%s\n", GWEN_Buffer_GetStart(dbuf));
|
||||||
|
GWEN_Buffer_free(dbuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void _dumpElement(const AQH_VARS *vt, int indent, GWEN_BUFFER *dbuf)
|
||||||
|
{
|
||||||
|
const AQH_VARS *vtChild;
|
||||||
|
|
||||||
|
if (indent)
|
||||||
|
GWEN_Buffer_FillWithBytes(dbuf, ' ', indent);
|
||||||
|
|
||||||
|
switch(vt->dataType) {
|
||||||
|
case AQH_Vars_DataType_Unknown:
|
||||||
|
GWEN_Buffer_AppendString(dbuf, "unknown\n");
|
||||||
|
break;
|
||||||
|
case AQH_Vars_DataType_Group:
|
||||||
|
GWEN_Buffer_AppendArgs(dbuf, "group..\"%s\"\n", (vt->data.dataString)?vt->data.dataString:"<no name>");
|
||||||
|
break;
|
||||||
|
case AQH_Vars_DataType_Variable:
|
||||||
|
GWEN_Buffer_AppendArgs(dbuf, "var....\"%s\"\n", (vt->data.dataString)?vt->data.dataString:"<no name>");
|
||||||
|
break;
|
||||||
|
case AQH_Vars_DataType_ValueString:
|
||||||
|
GWEN_Buffer_AppendArgs(dbuf, "char...\"%s\"\n", (vt->data.dataString)?vt->data.dataString:"<no data>");
|
||||||
|
break;
|
||||||
|
case AQH_Vars_DataType_ValueInt:
|
||||||
|
GWEN_Buffer_AppendArgs(dbuf, "int....\"%d\"\n", vt->data.dataInt);
|
||||||
|
break;
|
||||||
|
case AQH_Vars_DataType_ValueDouble:
|
||||||
|
GWEN_Buffer_AppendArgs(dbuf, "double.\"%f\"\n", vt->data.dataDouble);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
vtChild=AQH_Vars_Tree2_GetFirstChild(vt);
|
||||||
|
while(vtChild) {
|
||||||
|
_dumpElement(vtChild, indent+2, dbuf);
|
||||||
|
vtChild=AQH_Vars_Tree2_GetNext(vtChild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "./vars-t.c"
|
#include "./vars-t.c"
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ AQHOME_API void AQH_Vars_SetDoubleData(AQH_VARS *vt, double d);
|
|||||||
AQHOME_API AQH_VARS *AQH_Vars_GetFirstChildByType(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);
|
AQHOME_API AQH_VARS *AQH_Vars_GetNextByType(const AQH_VARS *vt, AQH_VARS_DATATYPE dt);
|
||||||
|
|
||||||
|
AQHOME_API void AQH_Vars_Dump(const AQH_VARS *vt, int indent);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user