// XmlSerializable.h
//

#if !defined(_XMLSERIALIZABLE_H_)
#define _XMLSERIALIZABLE_H_

#include "msxmlcpp.h"
#include <string>

using namespace std;

class CXmlSerializable
{
public:
	virtual bool BuildFromXml(CXMLDOMNode& node) = 0;
	virtual bool AppendToDOMDocument(CXMLDOMDocument2& xmlDoc, CXMLDOMElement& parentElement, bool parentIsValid = true) = 0;
	
	virtual bool SaveToXmlFile(const string& fileName);
	virtual bool LoadFromXmlFile(const string& fileName);

	virtual void Clear() = 0;
	virtual void SetDefaults() = 0;

	virtual string GetXmlNodeName();

protected:
	void AppendMemberNode(const string& nodeName, 
						 const string& nodeValue, 
						 CXMLDOMElement& parentElement,
						 CXMLDOMDocument2& xmlDoc);

	void AppendMemberNode(const string& nodeName, 
						 int nodeValue, 
						 CXMLDOMElement& parentElement,
						 CXMLDOMDocument2& xmlDoc);
	
	void AppendMemberNode(const string& nodeName, 
						  double nodeValue, 
						  int precision,
						  CXMLDOMElement& parentElement,
						  CXMLDOMDocument2& xmlDoc);
};

#endif //!defined(_XMLSERIALIZABLE_H_)
