X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcollection.cpp;h=e1c25ddc914e6afd0f2be1b8e4ef198846c5c209;hb=refs%2Fheads%2Fwip;hp=8b295858ac72fadf42a535be78c7272d8e50ba27;hpb=982f6785f541879c86a2f386fbdd4057e960b12c;p=libs%2Fdatafile.git diff --git a/source/collection.cpp b/source/collection.cpp index 8b29585..e1c25dd 100644 --- a/source/collection.cpp +++ b/source/collection.cpp @@ -7,10 +7,6 @@ using namespace std; namespace Msp { namespace DataFile { -Collection::Collection(): - fallback(0) -{ } - Collection::~Collection() { for(CollectionItemTypeBase *t: types) @@ -20,8 +16,16 @@ Collection::~Collection() void Collection::add_var(const string &name, const CollectionItemTypeBase *type, const Variant &var) { insert_unique(items, name, var); - if(type) - type->notify_item(name, var); + try + { + if(type) + type->notify_item(name, var); + } + catch(...) + { + remove_existing(items, name); + throw; + } } const Variant &Collection::get_var(const string &name, const CollectionItemTypeBase *type) @@ -59,7 +63,7 @@ const Variant *Collection::find_var(const string &name, const CollectionItemType } i = items.find(name); - return (i!=items.end() ? &i->second : 0); + return (i!=items.end() ? &i->second : nullptr); } void Collection::gather_items(vector *vars, list *names, const CollectionItemTypeBase &type, bool include_sources) const @@ -99,7 +103,7 @@ CollectionItemTypeBase *Collection::get_type(const CollectionItemTypeBase &type) for(CollectionItemTypeBase *t: types) if(t->is_same_type(type)) return t; - return 0; + return nullptr; } CollectionItemTypeBase *Collection::get_type_for_item(const Variant &var) const @@ -107,7 +111,7 @@ CollectionItemTypeBase *Collection::get_type_for_item(const Variant &var) const for(CollectionItemTypeBase *t: types) if(t->check_item_type(var)) return t; - return 0; + return nullptr; } void Collection::add_source(const CollectionSource &s) @@ -121,7 +125,7 @@ IO::Seekable *Collection::open_raw(const string &name) const if(IO::Seekable *io = s->open(name)) return io; - return 0; + return nullptr; } void Collection::gather_names_from_sources(list &names, const CollectionItemTypeBase &type) const