#include "rulefont.h"

#include <exception>

RuleFont::RuleFont(const std::string& name, ruleFunc rule) : name(name), rule(rule) {
	if(!rule) {
		throw std::exception(); // "invalid Rule"
	}
}

void RuleFont::applyFont(const std::string& in, std::string& out) const {
	out.reserve(in.size());
	for(size_t pos = 0; pos < in.size(); ++pos) {
		char c = in[pos];
		std::string append = rule(c);
		out += append;
	}
}

const std::string& RuleFont::getName() const {
	return name;
}

bool RuleFont::canApply(const std::string& in) const {
	return true;
}