bool Reflection::accum_conv_path(const Type& source, const Type& dest, ConverterList& conv, std::vector<const Type* > &chain, CastType castType) { // break unwanted loops if (std::find(chain.begin(), chain.end(), &source) != chain.end()) return false; // store the type being processed to avoid loops chain.push_back(&source); // search a converter from "source" StaticData::ConverterMapMap::const_iterator i = getOrCreateStaticData().convmap.find(&source); if (i == getOrCreateStaticData().convmap.end()) return false; // search a converter to "dest" const StaticData::ConverterMap& cmap = i->second; StaticData::ConverterMap::const_iterator j = cmap.find(&dest); if (j != cmap.end() && (j->second->getCastType() == castType)) { conv.push_back(j->second); return true; } // search a undirect converter from "source" to ... to "dest" for (j=cmap.begin(); j!=cmap.end(); ++j) { if ((j->second->getCastType() == castType) && accum_conv_path(*j->first, dest, conv, chain, castType)) { conv.push_front(j->second); return true; } } return false; }
const AdapterChain::ConverterList AdapterChain::translateConverterids(const AdapterChain::ConverteridList &&ids) { ConverterList ret; ret.reserve(ids.size()); for (const auto id : ids) { ret.push_back(&global.converters.get(id)); } return ret; }