std::string Reader::getText(const std::string& name) { StringRef existing = texts.momentaryRequest(name); if (existing) return *existing.get(); StringRef result(new std::string(readString(name))); texts.momentaryPut(name, result); return *result.get(); }
XMLRef Reader::getXMLDoc(const std::string& name, const std::string& dtdFile) { XMLRef existing = xmls.momentaryRequest(name); if (existing) return existing; XMLRef result(readXMLDoc(name, dtdFile)); xmls.momentaryPut(name, result); return result; }
TiledImageRef Reader::getTiledImage(const std::string& name, int w, int h) { TiledImageRef existing = tiles.momentaryRequest(name); if (existing) return existing; if (w <= 0 || h <= 0) return TiledImageRef(); std::unique_ptr<Gosu::Buffer> buffer(readBuffer(name)); if (!buffer) return TiledImageRef(); TiledImageRef result( TiledImage::create(buffer->data(), buffer->size(), (unsigned int)w, (unsigned int)h) ); if (!result) return TiledImageRef(); tiles.momentaryPut(name, result); return result; }