Click here to Skip to main content
15,885,032 members
Articles / Desktop Programming / ATL

CM_ConfigBuilder 1.2g: Visual Studio 6/Visual Studio 2005/Visual Studio 2008 Code Generator for Application Settings Graphic Management

Rate me:
Please Sign up or sign in to vote.
4.94/5 (126 votes)
12 Feb 2008CPOL17 min read 696.3K   9.8K   262  
CM_ConfigBuilder generates and compiles the required files to manage your application's settings/preferences and to store/retrieve them in XML format.
// XmlProjectPostGen.cpp: implementation of the CXmlProjectPostGen class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "AsCfgBuilder.h"
#include "XmlProjectPostGen.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CXmlProjectPostGen::CXmlProjectPostGen()
{
	SetDefaults();
}

CXmlProjectPostGen::~CXmlProjectPostGen()
{

}

void CXmlProjectPostGen::SetActionId(enGeneratorAction actionId)
{
	actionId_ = actionId;
}

enGeneratorAction CXmlProjectPostGen::GetActionId() const
{
	return actionId_;
}

void CXmlProjectPostGen::SetConfigId(enGeneratorConfig configId)
{
	configId_ = configId;
}

enGeneratorConfig CXmlProjectPostGen::GetConfigId() const
{
	return configId_;
}

void CXmlProjectPostGen::SetTestProjectActionId(enTestProjectAction actionId)
{
	testProjectActionId_ = actionId;
}

enTestProjectAction CXmlProjectPostGen::GetTestProjectActionId() const
{
	return testProjectActionId_;
}

void CXmlProjectPostGen::SetDefaults()
{
	actionId_ = enGeneratorAction_GenerateAndCompile;
	configId_ = enGeneratorConfig_All;
	testProjectActionId_ = enTestProjectAction_None;
}

void CXmlProjectPostGen::Clear()
{}

bool CXmlProjectPostGen::BuildFromXml(CXMLDOMNode& node)
{
	USES_CONVERSION;

	CXMLDOMNode childNode;
	CXMLDOMNodeList children;
	std::string nodeName;

	Clear();

	children = node.GetChildNodes();
	
	for (long i = 0; i < children.GetLength(); i++) {
		childNode = children.GetItem(i);
	
		nodeName = childNode.GetNodeName();

		if(nodeName == "GeneratorActionId") {
			actionId_ = (enGeneratorAction)atoi(W2A(childNode.GetNodeTypedValue().bstrVal));
		} else if(nodeName == "ConfigurationId") {
			configId_ = (enGeneratorConfig)(atoi(W2A(childNode.GetNodeTypedValue().bstrVal)));
		} else if(nodeName == "TestProjectActionId") {
			testProjectActionId_ = (enTestProjectAction)(atoi(W2A(childNode.GetNodeTypedValue().bstrVal)));
		}
	}

	return true;

}

bool CXmlProjectPostGen::AppendToDOMDocument(CXMLDOMDocument2& xmlDoc, CXMLDOMElement& parentElement, bool parentIsValid)
{
	CXMLDOMElement newElement;
	CXMLDOMElement member;

	newElement = xmlDoc.CreateElement(GetXmlNodeName().c_str());
   
	AppendMemberNode("GeneratorActionId", actionId_, newElement, xmlDoc);
	AppendMemberNode("ConfigurationId", configId_, newElement, xmlDoc);
	AppendMemberNode("TestProjectActionId", testProjectActionId_, newElement, xmlDoc);
		
	parentElement.AppendChild(newElement);

	return true;
}

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
Web Developer
Italy Italy
For all Stefano's latest code, binaries and tutorials visit www.codemachines.com

Comments and Discussions