CMappedFileLoader.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include "StdInc.h"
  2. #include "CMappedFileLoader.h"
  3. #include "CResourceLoader.h"
  4. #include "../JsonNode.h"
  5. CMappedFileLoader::CMappedFileLoader(const JsonNode &config)
  6. {
  7. BOOST_FOREACH(auto entry, config.Struct())
  8. {
  9. fileList[ResourceID(entry.first)] = entry.second.String();
  10. }
  11. }
  12. std::unique_ptr<CInputStream> CMappedFileLoader::load(const std::string & resourceName) const
  13. {
  14. return CResourceHandler::get()->load(ResourceID(resourceName));
  15. }
  16. bool CMappedFileLoader::existsEntry(const std::string & resourceName) const
  17. {
  18. for(auto it = fileList.begin(); it != fileList.end(); ++it)
  19. {
  20. if(it->second == resourceName)
  21. {
  22. return true;
  23. }
  24. }
  25. return false;
  26. }
  27. boost::unordered_map<ResourceID, std::string> CMappedFileLoader::getEntries() const
  28. {
  29. return fileList;
  30. }
  31. std::string CMappedFileLoader::getOrigin() const
  32. {
  33. return ""; // does not have any meaning with this type of data source
  34. }
  35. std::string CMappedFileLoader::getFullName(const std::string & resourceName) const
  36. {
  37. return CResourceHandler::get()->getResourceName(ResourceID(resourceName));
  38. }