<commit_before>#include "RequirementLoader.h"
#include "StringRequirement.h"
#include "IntegerRequirement.h"
#include "NumberRequirement.h"
#include "ObjectRequirement.h"
#include "ArrayRequirement.h"
#include "BooleanRequirement.h"
#include "NullRequirement.h"
#include "EnumRequirement.h"
#include "AllOfRequirement.h"
#include "AnyOfRequirement.h"
#include "OneOfRequirement.h"
#include "NotRequirement.h"

namespace Json
{
	Requirement* RequirementLoader::LoadRequirement(const Value &json)
	{
		Requirement* item = nullptr;
		// Load up apitemriate requirement type.
		if(json["type"].asString() == "string")
			item = new StringRequirement();
		else if(json["type"].asString() == "integer")
			item = new IntegerRequirement();
		else if(json["type"].asString() == "number")
			item = new NumberRequirement();
		else if(json["type"].asString() == "object")
			item = new ObjectRequirement();
		else if(json["type"].asString() == "array")
			item = new ArrayRequirement();
		else if(json["type"].asString() == "boolean")
			item = new BooleanRequirement();
		else if(json["type"].asString() == "null")
			item = new NullRequirement();
		else if(json["allOf"].isArray())
			item = new AllOfRequirement();
		else if(json["anyOf"].isArray())
			item = new AnyOfRequirement();
		else if(json["oneOf"].isArray())
			item = new AnyOfRequirement();
		else if(json["enum"].isArray())
			item = new EnumRequirement();
		else if(json["not"].isObject())
			item = new NotRequirement();
		// last resort.
		else if(json.isObject())
			item = new ObjectRequirement();

		return item;
	}

	Requirement* RequirementLoader::LoadExtended(const Value &json)
	{
		Requirement* item = nullptr;
		if(json.isObject() && json.isMember("allOf") && json["allOf"].isArray())
			item = new AllOfRequirement();
		else if(json.isObject() && json.isMember("anyOf") && json["anyOf"].isArray())
			item = new AnyOfRequirement();
		else if(json.isObject() && json.isMember("oneOf") && json["oneOf"].isArray())
			item = new AnyOfRequirement();

		return item;
	}

	Requirement* RequirementLoader::LoadRequirement(const ValueType& type)
	{
		Requirement* item = nullptr; 

		switch(type)
		{
			case nullValue:
				item = new NullRequirement();
				break;
			case intValue:
				item = new IntegerRequirement();
				break;<commit_msg>Fixed bug with requirementloader. Not sure how it slipped through the cracks!<commit_after>#include "RequirementLoader.h"
#include "StringRequirement.h"
#include "IntegerRequirement.h"
#include "NumberRequirement.h"
#include "ObjectRequirement.h"
#include "ArrayRequirement.h"
#include "BooleanRequirement.h"
#include "NullRequirement.h"
#include "EnumRequirement.h"
#include "AllOfRequirement.h"
#include "AnyOfRequirement.h"
#include "OneOfRequirement.h"
#include "NotRequirement.h"

namespace Json
{
	Requirement* RequirementLoader::LoadRequirement(const Value &json)
	{
		Requirement* item = nullptr;
		// Load up apitemriate requirement type.
		if(json["type"].asString() == "string")
			item = new StringRequirement();
		else if(json["type"].asString() == "integer")
			item = new IntegerRequirement();
		else if(json["type"].asString() == "number")
			item = new NumberRequirement();
		else if(json["type"].asString() == "object")
			item = new ObjectRequirement();
		else if(json["type"].asString() == "array")
			item = new ArrayRequirement();
		else if(json["type"].asString() == "boolean")
			item = new BooleanRequirement();
		else if(json["type"].asString() == "null")
			item = new NullRequirement();
		else if(json["allOf"].isArray())
			item = new AllOfRequirement();
		else if(json["anyOf"].isArray())
			item = new AnyOfRequirement();
		else if(json["oneOf"].isArray())
			item = new OneOfRequirement();
		else if(json["enum"].isArray())
			item = new EnumRequirement();
		else if(json["not"].isObject())
			item = new NotRequirement();
		// last resort.
		else if(json.isObject())
			item = new ObjectRequirement();

		return item;
	}

	Requirement* RequirementLoader::LoadExtended(const Value &json)
	{
		Requirement* item = nullptr;
		if(json.isObject() && json.isMember("allOf") && json["allOf"].isArray())
			item = new AllOfRequirement();
		else if(json.isObject() && json.isMember("anyOf") && json["anyOf"].isArray())
			item = new AnyOfRequirement();
		else if(json.isObject() && json.isMember("oneOf") && json["oneOf"].isArray())
			item = new OneOfRequirement();

		return item;
	}

	Requirement* RequirementLoader::LoadRequirement(const ValueType& type)
	{
		Requirement* item = nullptr; 

		switch(type)
		{
			case nullValue:
				item = new NullRequirement();
				break;
			case intValue:
				item = new IntegerRequirement();
				break;
{'fraction_non_alphanumeric': 0.16274089935760172, 'fraction_numerical': 0.0, 'mean_word_length': 5.011583011583012, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '506182', 'n_tokens_mistral': 1630, 'n_tokens_neox': 1483, 'n_words': 338}