<commit_before>/**
* \file ParameterBag.cpp
* \author <NAME>/<NAME>
* \date 20 november 2014
*
* Parameters for all classes.
*
*/

#include "ParameterBag.h"

using namespace ci;
using namespace std;
using namespace Reymenta;

ParameterBag::ParameterBag()
{
	// reset no matter what, so we don't miss anything
	reset();

	// check to see if ReymentaSettings.xml file exists and restore if it does
	fs::path params = getAssetPath("") / settingsFileName;
	if (fs::exists(params))
		restore();
}

ParameterBagRef ParameterBag::create()
{
	return shared_ptr<ParameterBag>(new ParameterBag());
}

bool ParameterBag::save()
{
	// attempt to create "reymenta" directory in Documents directory
	fs::path directory = getAssetPath("");
	if (!fs::exists(directory)) {
		if (!createDirectories(directory / settingsFileName)) {
			return false;
		}
	}

	fs::path path = directory / settingsFileName;

	XmlTree settings("settings", "");

	XmlTree ShowConsole("ShowConsole", "");
	ShowConsole.setAttribute("value", toString(mShowConsole));
	settings.push_back(ShowConsole);

	XmlTree UseDX9("UseDX9", "");
	UseDX9.setAttribute("value", toString(mUseDX9));
	settings.push_back(UseDX9);

	XmlTree ShowUI("ShowUI", "");
	ShowUI.setAttribute("value", toString(mShowUI));
	settings.push_back(ShowUI);

	// TODO: test for successful writing of XML
	settings.write(writeFile(path));

	return true;
}

bool ParameterBag::restore()
{
	// check to see if ReymentaSettings.xml file exists
	fs::path params = getAssetPath("") / settingsFileName;
	if (fs::exists(params)) {
		// if it does, restore
		const XmlTree xml(loadFile(params));

		if (!xml.hasChild("settings")) {
			return false;
		}
		else {
			const XmlTree settings = xml.getChild("settings");

			if (settings.hasChild("ShowConsole")) {
				XmlTree ShowConsole = settings.getChild("ShowConsole");
				mShowConsole = ShowConsole.getAttributeValue<bool>("value");
			}
			if (settings.hasChild("UseDX9")) {
				XmlTree UseDX9 = settings.getChild("UseDX9");
				mUseDX9 = UseDX9.getAttributeValue<bool>("value");
			}
			if (settings.hasChild("ShowUI")) {
				XmlTree ShowUI = settings.getChild("ShowUI");
				mShowUI = ShowUI.getAttributeValue<bool>("value");
			}

			return true;
		}
	}
	else {
		// if it doesn't, return false
		return false;
	}<commit_msg>fbowidth as a parameter for performance<commit_after>/**
* \file ParameterBag.cpp
* \author <NAME>/<NAME>
* \date 20 november 2014
*
* Parameters for all classes.
*
*/

#include "ParameterBag.h"

using namespace ci;
using namespace std;
using namespace Reymenta;

ParameterBag::ParameterBag()
{
	// reset no matter what, so we don't miss anything
	reset();

	// check to see if ReymentaSettings.xml file exists and restore if it does
	fs::path params = getAssetPath("") / settingsFileName;
	if (fs::exists(params))
		restore();
}

ParameterBagRef ParameterBag::create()
{
	return shared_ptr<ParameterBag>(new ParameterBag());
}

bool ParameterBag::save()
{
	// attempt to create "reymenta" directory in Documents directory
	fs::path directory = getAssetPath("");
	if (!fs::exists(directory)) {
		if (!createDirectories(directory / settingsFileName)) {
			return false;
		}
	}

	fs::path path = directory / settingsFileName;

	XmlTree settings("settings", "");

	XmlTree ShowConsole("ShowConsole", "");
	ShowConsole.setAttribute("value", toString(mShowConsole));
	settings.push_back(ShowConsole);

	XmlTree UseDX9("UseDX9", "");
	UseDX9.setAttribute("value", toString(mUseDX9));
	settings.push_back(UseDX9);

	XmlTree ShowUI("ShowUI", "");
	ShowUI.setAttribute("value", toString(mShowUI));
	settings.push_back(ShowUI);

	XmlTree FboWidth("FboWidth", "");
	FboWidth.setAttribute("value", toString(mFboWidth));
	settings.push_back(FboWidth);

	XmlTree FboHeight("FboHeight", "");
	FboHeight.setAttribute("value", toString(mFboHeight));
	settings.push_back(FboHeight);

	// TODO: test for successful writing of XML
	settings.write(writeFile(path));

	return true;
}

bool ParameterBag::restore()
{
	// check to see if ReymentaSettings.xml file exists
	fs::path params = getAssetPath("") / settingsFileName;
	if (fs::exists(params)) {
		// if it does, restore
		const XmlTree xml(loadFile(params));

		if (!xml.hasChild("settings")) {
			return false;
		}
		else {
			const XmlTree settings = xml.getChild("settings");

			if (settings.hasChild("ShowConsole")) {
				XmlTree ShowConsole = settings.getChild("ShowConsole");
				mShowConsole = ShowConsole.getAttributeValue<bool>("value");
			}
			if (settings.hasChild("UseDX9")) {
				XmlTree UseDX9 = settings.getChild("UseDX9");
				mUseDX9 = UseDX9.getAttributeValue<bool>("value");
			}
			if (settings.hasChild("ShowUI")) {
				XmlTree ShowUI = settings.getChild("ShowUI");
				mShowUI = ShowUI.getAttributeValue<bool>("value");
			}
			if (settings.hasChild("FboWidth")) {
				XmlTree FboWidth = settings.getChild("FboWidth");
				mFboWidth = FboWidth.getAttributeValue<int>("value");
			}
			if (settings.hasChild("FboHeight")) {
				XmlTree FboHeight = settings.getChild("FboHeight");
				mFboHeight = FboHeight.getAttributeValue<int>("value");
			}

			return true;
		}
	}
	else {
		// if it doesn't, return false
		return false;
	}
{'fraction_non_alphanumeric': 0.14749034749034748, 'fraction_numerical': 0.006177606177606178, 'mean_word_length': 4.860859728506787, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '618407', 'n_tokens_mistral': 1806, 'n_tokens_neox': 1662, 'n_words': 373}