]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/collection.h
Fix comment handling
[libs/datafile.git] / source / collection.h
index 9f5ddfcf7f78e5ba988636cc501edf05a87247a2..f79e567d5c0e4e5fc1a5d6f8c2c9e481265a6d27 100644 (file)
@@ -42,6 +42,9 @@ method for details.
 Collections also support a notion of "future objects".  These are objects which
 are known to be possible to load, but loading them is deferred to the first
 time they are requested.
+
+Other classes are available to provide refined ways of loading objects from
+files.  See DirectoryCollection and PackCollection.
 */
 class Collection
 {
@@ -485,7 +488,10 @@ T &Collection::get(const std::string &name)
                if((*j)->can_create() && (*j)->check_type<NCT>())
                        (*j)->create_item(*this, name);
 
-       return *get_item(items, name).value<RefPtr<NCT> >();
+       NCT *ptr = get_item(items, name).value<RefPtr<NCT> >().get();
+       if(!ptr)
+               throw key_error(typeid(ItemMap));
+       return *ptr;
 }
 
 template<typename T>