// XmlProjectSettings.cpp
//
#include "stdafx.h"
#include "XmlProjectSettings.h"

CXmlProjectSettings::CXmlProjectSettings()
{}

CXmlProjectSettings::~CXmlProjectSettings()
{}

bool CXmlProjectSettings::BuildFromXml(IXMLDOMNode* node)
{
	Clear();

	ExtractMemberNode(node, CXmlProjectSettings_Cpp::GetXmlNodeName(), cppSettings_);
	ExtractMemberNode(node, CXmlProjectSettings_Atl::GetXmlNodeName(), atlSettings_);
	ExtractMemberNode(node, CXmlProjectSettings_CSharp::GetXmlNodeName(), cSharpSettings_);

	return true;
}

bool CXmlProjectSettings::AppendToDOMDocument(IXMLDOMDocument2* xmlDoc, IXMLDOMElement* parentElement)
{
	IXMLDOMElement* newElement;
	HRESULT hr;

	hr = xmlDoc->createElement(CComBSTR((const TCHAR*)GetXmlNodeName()), &newElement);
 
	cppSettings_.AppendToDOMDocument(xmlDoc, newElement);
	atlSettings_.AppendToDOMDocument(xmlDoc, newElement);
	cSharpSettings_.AppendToDOMDocument(xmlDoc, newElement);

	if (parentElement)
		hr = parentElement->appendChild(newElement, NULL);
	else
		hr = xmlDoc->appendChild(newElement, NULL);
	
	return true;
}

void CXmlProjectSettings::Clear()
{
	cppSettings_.Clear();
	atlSettings_.Clear();
	cSharpSettings_.Clear();
}

void CXmlProjectSettings::SetDefaults()
{
	cppSettings_.SetDefaults();
	atlSettings_.SetDefaults();
	cSharpSettings_.SetDefaults();
}

CXmlProjectSettings_Cpp* CXmlProjectSettings::GetCppSettings()
{
	return &cppSettings_;
}

/***
CXmlProjectSettings_Vb* CXmlProjectSettings::GetVbSettings()
{
	return &vbSettings_;
}
***/

CXmlProjectSettings_Atl* CXmlProjectSettings::GetAtlSettings()
{
	return &atlSettings_;
}

CXmlProjectSettings_CSharp* CXmlProjectSettings::GetCSharpSettings()
{
	return &cSharpSettings_;
}
