<commit_before>
#pragma once

#include "control.h"

namespace OpenApoc {

class Framework;

class Form : public Control
{

	protected:
		virtual void OnRender() override;

	public:
		Form( Framework &fw, tinyxml2::XMLElement* FormConfiguration );
		virtual ~Form();

		virtual void EventOccured( Event* e ) override;
		virtual void Update() override;
		virtual void UnloadResources() override;
};

}; //namespace OpenApoc<commit_msg>Add Form::FindControlTyped helper<commit_after>
#pragma once

#include "control.h"
#include "framework/logger.h"

#include <typeinfo>

namespace OpenApoc {

class Framework;

class Form : public Control
{

	protected:
		virtual void OnRender() override;

	public:
		Form( Framework &fw, tinyxml2::XMLElement* FormConfiguration );
		virtual ~Form();

		virtual void EventOccured( Event* e ) override;
		virtual void Update() override;
		virtual void UnloadResources() override;

		template <typename T>
		T* FindControlTyped(const UString &name)
		{
			Control *c = this->FindControl(name);
			if (!c)
			{
				LogError("Failed to find control \"%s\" within form \"%s\"",
					name.str().c_str(), this->Name.str().c_str());
				return nullptr;
			}
			T* typedControl = dynamic_cast<T*>(c);
			if (!c)
			{
				LogError("Failed cast  control \"%s\" within form \"%s\" to type \"%s\"",
					name.str().c_str(), this->Name.str().c_str(), typeid(T).name());
				return nullptr;
			}
			return typedControl;
		}
};

}; //namespace OpenApoc
{'fraction_non_alphanumeric': 0.14246762099522836, 'fraction_numerical': 0.0013633265167007499, 'mean_word_length': 3.976271186440678, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '5578285', 'n_tokens_mistral': 530, 'n_tokens_neox': 466, 'n_words': 135}