File DataNode.h

File List > engine > include > DataNode.h

Go to the documentation of this file


#ifndef DATANODE_H
#define DATANODE_H

#include <stdbool.h>
#include <stdlib.h>

typedef struct _xmlNode xmlNode;
struct DataNode;

enum DNPropValType
{
    DN_Int,
    DN_Float,
    DN_Bool,
    DN_String,
    DN_UNKNOWN,
    DN_PROP_NOT_FOUND,
};


typedef enum DNPropValType (*GetDNPropTypeFn)(struct DataNode* pNode, const char* propName);
typedef float (*GetDNFloatFn)(struct DataNode* pNode, const char* propName);
typedef int (*GetDNIntFn)(struct DataNode* pNode, const char* propName);
typedef bool (*GetDNBoolFn)(struct DataNode* pNode, const char* propName);
typedef size_t (*GetDNStrlenFn)(struct DataNode* pNode, const char* propName);
typedef void (*GetDNStrcpyFn)(struct DataNode* pNode, const char* propName, char* dest);

typedef bool (*GetDNStrCmpFn)(struct DataNode* pNode, const char* propName, const char* cmpTo);


typedef size_t (*GetDNStrlenContentFn)(struct DataNode* pNode);
typedef void (*GetDNStrcpyContentFn)(struct DataNode* pNode, char* dest);
typedef bool (*GetDNStrCmpContentFn)(struct DataNode* pNode, const char* cmpTo);

void DN_InitForXMLNode(struct DataNode* pOutNode, xmlNode* pXMLNode);
void DN_InitForLuaTableOnTopOfStack(struct DataNode* pOutNode);

struct DataNode
{
    GetDNPropTypeFn fnGetPropType;
    GetDNFloatFn fnGetFloat;
    GetDNIntFn fnGetInt;
    GetDNBoolFn fnGetBool;
    GetDNStrlenFn fnGetStrlen;
    GetDNStrcpyFn fnGetStrcpy;
    GetDNStrCmpFn fnStrCmp;
    GetDNStrlenContentFn fnGetContentStrlen;
    GetDNStrcpyContentFn fnGetContentStrcpy;
    GetDNStrCmpContentFn fnContentStrCmp;

    void* pData; 
};

#endif