Click here to Skip to main content
15,893,923 members
Articles / Containers / Virtual Machine

An extendable report editor

Rate me:
Please Sign up or sign in to vote.
5.00/5 (11 votes)
3 Sep 2008CPOL3 min read 41.2K   2K   35  
An extendable report editor. You can simply add your own controls without recompiling the program or writing annoying plug-ins.
// Xml.h: interface for the CXml class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_XML_H__FA31F9F4_F031_4B0A_8B37_3ABD6AB598ED__INCLUDED_)
#define AFX_XML_H__FA31F9F4_F031_4B0A_8B37_3ABD6AB598ED__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "common.h"
#include "syslog.h"
#include "assert.h"
#include "mem.h"
#include "memfile.h"
#include "xmlreader.h"
#include "file.h"
#include "mem_tool.h"

class CXmlNode{
public:
	CMem	*mem_name;
    CMemFile *mf_attrib;
	CMemFile *mf_value;
	int value_type;
public:
    CXmlNode *parent;
    CXmlNode *child;
    CXmlNode *next;
public:
	CXmlNode * GetChildByName(char *child_name);
	int GetAttrib(char *name, CFileBase *val);
	char * GetName();
	CXmlNode * GetNodeByPath(char *path);
	int GetPath(CFileBase *path);
	int GetPathToStk(CMemStk *ss);
	int WriteToFile(CFileBase *file);
	int AddValueData(char *str);
	int AddAttrib(CFileBase *file);
	int AddValueData(CFileBase *file);
	int AddAttrib(char *attrib,char *val);
	int SetValueType(int type);
	int SetName(char *name);
        CXmlNode();
        ~CXmlNode();
    int Init();
    int Destroy();
    int Print();
    static CXmlNode * Alloc();
    static int Free(CXmlNode *p);
    CXmlNode *  FindChildTail();
    int  AddChild(CXmlNode *node);
    CXmlNode *  GetChild(int i);
    CXmlNode *GetParent();
};

class CXml{
public:
    CXmlNode *root;
public:
	int LoadXml(char *fn);
	CXmlNode * GetNodeByPath(char *path);
	int WriteToFile(char *fn);
	int WriteToFile(CFileBase *mf);
	int LoadXml(CFileBase *file);
    CXml();
    ~CXml();
    int Init();
    int Destroy();
    CXmlNode *  GetRoot();
    int  AddRoot(CXmlNode *node);
};

#endif // !defined(AFX_XML_H__FA31F9F4_F031_4B0A_8B37_3ABD6AB598ED__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
China China
26 years old, 2 years work experience.

Comments and Discussions