#ifndef _cxml_H_
#define _cxml_H_
//------------------------------------------------------------------------------
//   skoro XML handler by  M.Lisztwan                                          -
//------------------------------------------------------------------------------
/* $Id: cxml.h,v 1.1 2008/10/16 14:34:16 mastny Exp $ */


typedef  enum   {ntElement,ntAttribute,ntText} TNodeType;

typedef struct TCXMLnode
 {
char * Name;
char * Data;
 TNodeType Type;
 struct TCXMLnode * *Subnodes;
 int SubnodesCnt;
 } TCXMLnode;
typedef struct TCXMLnodeW
 {
wchar_t * Name;
wchar_t * Data;
 TNodeType Type;
 struct TCXMLnodeW * *Subnodes;
 int SubnodesCnt;
 } TCXMLnodeW;


#ifdef __cplusplus
//extern "C" {
#endif
TCXMLnode *CxmlCreateNodeL(const char * aName,const int aNameL, TNodeType NodeType, const char * aDatam,const int aDataL );
TCXMLnode *CxmlCreateNode(const char * aName, TNodeType NodeType, const char * aData);
TCXMLnode *CxmlAddChild(TCXMLnode *node,TCXMLnode *cnode);
TCXMLnode *CxmlDestroyNode(TCXMLnode *node);

char * CxmlNodeToText(TCXMLnode *node, int *size);
void CxmlTextFree(char* p);
TCXMLnode * CxmlTextToNode(char * s,int length);

char *CxmlGetName(TCXMLnode *node);
int CxmlGetNumAttribs(TCXMLnode *node);
int CxmlGetNumElements(TCXMLnode *node);
int CxmlGetNumTexts(TCXMLnode *node);

TCXMLnode * CxmlGetSubElemnetI(TCXMLnode *node,int index);
TCXMLnode * CxmlGetSubElemnetN(TCXMLnode *node,char * Name);
char * CxmlGetAttribute(TCXMLnode *node,char * Name);
TCXMLnode * CxmlGetSubNodeI(TCXMLnode *node,int index);
TCXMLnode * CxmlGetSubTextI(TCXMLnode *node,int index);
char *CxmlGetSubTextIText(TCXMLnode *node,int index);

TCXMLnodeW *CxmlCreateNodeLW(const wchar_t * aName,const int aNameL, TNodeType NodeType, const wchar_t * aDatam,const int aDataL );
TCXMLnodeW *CxmlCreateNodeW(const wchar_t * aName, TNodeType NodeType, const wchar_t * aData);
TCXMLnodeW *CxmlAddChildW(TCXMLnodeW *node,TCXMLnodeW *cnode);
TCXMLnodeW *CxmlDestroyNodeW(TCXMLnodeW *node);

wchar_t * CxmlNodeToTextW(TCXMLnodeW *node, int *size);
void CxmlTextFreeW(wchar_t* p);
TCXMLnodeW * CxmlTextToNodeW(wchar_t * s,int length);

wchar_t *CxmlGetNameW(TCXMLnodeW *node);
int CxmlGetNumAttribsW(TCXMLnodeW *node);
int CxmlGetNumElementsW(TCXMLnodeW *node);
int CxmlGetNumTextsW(TCXMLnodeW *node);

TCXMLnodeW * CxmlGetSubElemnetIW(TCXMLnodeW *node,int index);
TCXMLnodeW * CxmlGetSubElemnetNW(TCXMLnodeW *node,wchar_t * Name);
wchar_t * CxmlGetAttributeW(TCXMLnodeW *node,wchar_t * Name);
TCXMLnodeW * CxmlGetSubNodeIW(TCXMLnodeW *node,int index);
TCXMLnodeW * CxmlGetSubTextIW(TCXMLnodeW *node,int index);
wchar_t *CxmlGetSubTextITextW(TCXMLnodeW *node,int index);

#ifdef __cplusplus
//}
#endif

#endif
