void AppendListToString(std::string *dest)
{
	std::vector<entry> entries;

	size_t total_size = 0;
	for (VertexLoaderMap::const_iterator iter = s_vertex_loader_map.begin(); iter != s_vertex_loader_map.end(); ++iter)
	{
		entry e;
		iter->second->AppendToString(&e.text);
		e.num_verts = iter->second->m_numLoadedVertices;
		entries.push_back(e);
		total_size += e.text.size() + 1;
	}
	sort(entries.begin(), entries.end());
	dest->reserve(dest->size() + total_size);
	for (std::vector<entry>::const_iterator iter = entries.begin(); iter != entries.end(); ++iter)
	{
		dest->append(iter->text);
	}
}
static void DumpLoadersCode()
{
	std::vector<codeentry> entries;
	for (VertexLoaderMap::const_iterator iter = s_vertex_loader_map.begin(); iter != s_vertex_loader_map.end(); ++iter)
	{
		if (!iter->second->IsPrecompiled())
		{
			codeentry e;
			e.conf.append(To_HexString(iter->first.GetElement(0)));
			e.conf.append(", ");
			e.conf.append(To_HexString(iter->first.GetElement(1)));
			e.conf.append(", ");
			e.conf.append(To_HexString(iter->first.GetElement(2)));
			e.conf.append(", ");
			e.conf.append(To_HexString(iter->first.GetElement(3)));				
			e.name = iter->second->GetName();
			e.num_verts = iter->second->m_numLoadedVertices;
			e.hash = std::to_string(iter->first.GetHash());
			entries.push_back(e);
		}
	}
	if (entries.size() == 0)
	{
		return;
	}		
	std::string filename = StringFromFormat("%sG_%s_pvt.h", File::GetUserPath(D_DUMP_IDX).c_str(), last_game_code.c_str());		
	std::string header;
	header.append("// Copyright 2013 Dolphin Emulator Project\n");
	header.append("// Licensed under GPLv2+\n");
	header.append("// Refer to the license.txt file included.\n");
	header.append("// Added for Ishiiruka by Tino\n");
	header.append("#pragma once\n");
	header.append("#include <map>\n");
	header.append("#include \"VideoCommon/NativeVertexFormat.h\"\n");
	header.append("class G_");
	header.append(last_game_code);
	header.append("_pvt\n{\npublic:\n");
	header.append("static void Initialize(std::map<u64, TCompiledLoaderFunction> &pvlmap);\n");
	header.append("};\n");
	std::ofstream headerfile(filename);
	headerfile << header;
	headerfile.close();
	filename = StringFromFormat("%sG_%s_pvt.cpp", File::GetUserPath(D_DUMP_IDX).c_str(), last_game_code.c_str());		
	sort(entries.begin(), entries.end());
	std::string sourcecode;
	sourcecode.append("#include \"VideoCommon/G_");
	sourcecode.append(last_game_code);
	sourcecode.append("_pvt.h\"\n");
	sourcecode.append("#include \"VideoCommon/VertexLoader_Template.h\"\n\n");
	sourcecode.append("\n\nvoid G_");
	sourcecode.append(last_game_code);
	sourcecode.append("_pvt::Initialize(std::map<u64, TCompiledLoaderFunction> &pvlmap)\n{\n");
	for (std::vector<codeentry>::const_iterator iter = entries.begin(); iter != entries.end(); ++iter)
	{
		sourcecode.append("\t// ");
		sourcecode.append(iter->name);
		sourcecode.append("\n// num_verts= ");
		sourcecode.append(std::to_string(iter->num_verts));			
		sourcecode.append("#if _M_SSE >= 0x301\n");
		sourcecode.append("\tif (cpu_info.bSSSE3)\n");
		sourcecode.append("\t{\n");
		sourcecode.append("\t\tpvlmap[");
		sourcecode.append(iter->hash);
		sourcecode.append("] = ");
		sourcecode.append("TemplatedLoader");
		sourcecode.append("<0x301, ");
		sourcecode.append(iter->conf);
		sourcecode.append(">;\n");
		sourcecode.append("\t}\n\telse\n");
		sourcecode.append("#endif\n");
		sourcecode.append("\t{\n");
		sourcecode.append("\t\tpvlmap[");
		sourcecode.append(iter->hash);
		sourcecode.append("] = ");
		sourcecode.append("TemplatedLoader");
		sourcecode.append("<0, ");
		sourcecode.append(iter->conf);
		sourcecode.append(">;\n");
		sourcecode.append("\t}\n");
	}
	sourcecode.append("}\n");
	std::ofstream out(filename);
	out << sourcecode;
	out.close();
}