#include "resourceloc.hpp" #include #include #include #include #include #include #include #include namespace resourceloc { std::string resolve(std::string inp) { boost::algorithm::trim_if(inp, boost::is_any_of(" \n\r\"")); std::vector components; boost::algorithm::split(components, inp, boost::is_any_of("/")); if (components.size() < 3 || components[0] != "" || components[1] != "mods") { BOOST_LOG_TRIVIAL(warning) << "invalid resourceloc"; return ""; } std::string path_component; for (unsigned int i = 3; i < components.size(); i++) { path_component += components[i]; if (i != components.size() - 1) { path_component += "/"; } } return boost::str( boost::format("new ResourceLocation(\"%1%\", \"%2%\")") % components[2] % path_component ); } }