/*
 * zzXml.h
 * 
 * The Zen API 
 * Copyright (C) 2008-2009 by LMI Technologies Inc.
 * 
 * Licensed under The MIT License.
 * Redistributions of files must retain the above copyright notice.
 */
#ifndef LMITECH_ZZXML_H_INCLUDED
#define LMITECH_ZZXML_H_INCLUDED

#include <zXml.h>
#include <zApiBegin.h>

#define zXML_FORMAT_BUFFER_SIZE     (512)

typedef struct zXmlItemAttr
{
    zChar *name;
    zChar *value;
    struct zXmlItemAttr *next;
} zXmlItemAttr;

typedef struct zXmlNode
{
    zChar *name;
    zChar *value;
    zXmlItemAttr *attributes;

    struct zXmlNode *parent;
    struct zXmlNode *child;
    struct zXmlNode *prev;
    struct zXmlNode *next;
} zXmlNode;

typedef struct zXmlClass
{
    zChar *pszHeader;
    zXmlNode *root;
    zChar formatBuffer[zXML_FORMAT_BUFFER_SIZE];
} zXmlClass; 

#define zXML(XML)           ((zXmlClass*)(XML))
#define zXML_ITEM(ITEM)     ((zXmlNode*)(ITEM))

zStatus zXml_InsertItemObjectUnder(zXml xml, zXmlItem parent, zXmlItem item);
zStatus zXml_InsertItemObjectAfter(zXml xml, zXmlItem before, zXmlItem item);
zStatus zXml_ReleaseItem(zXml xml, zXmlNode *item);
zStatus zXml_RecursiveRelease(zXml xml, zXmlNode *item);
zStatus zXml_InsertItemAttr(zXml xml, zXmlItem item, const zChar *name, zXmlItemAttr **attr);
zXmlItemAttr* zXml_FindItemAttributeObject(zXml xml, zXmlItem item, const zChar *name);
zXmlNode* zXml_FindChildByName(zXml xml, zXmlNode *parent, const zChar *name, z32u index);
const zChar* zXml_Format32u(zXml xml, z32u val);
const zChar* zXml_Format32s(zXml xml, z32s val);
const zChar* zXml_Format64u(zXml xml, z64u val);
const zChar* zXml_Format64s(zXml xml, z64s val);
const zChar* zXml_Format32f(zXml xml, z32f val);
const zChar* zXml_Format64f(zXml xml, z64f val);
zStatus zXml_Parse32u(zXml xml, const zChar *string, z32u *val);
zStatus zXml_Parse32s(zXml xml, const zChar *string, z32s *val);
zStatus zXml_Parse64u(zXml xml, const zChar *string, z64u *val);
zStatus zXml_Parse64s(zXml xml, const zChar *string, z64s *val);
zStatus zXml_Parse32f(zXml xml, const zChar *string, z32f *val);
zStatus zXml_Parse64f(zXml xml, const zChar *string, z64f *val);
zStatus zXml_CloneItem(zXmlClass *obj, zXmlNode *pItem, zXmlNode **pClone);
zStatus zXml_ItemToString(zXml xml, zChar* buffer, z32u* totalLength, zXmlNode *pItem, z32u level);

#include <zApiEnd.h>

#endif           /* #ifndef LMITECH_ZZXML_H_INCLUDED */
