X-Git-Url: http://git.tdb.fi/?p=libs%2Fdatafile.git;a=blobdiff_plain;f=source%2Floader.cpp;h=bffa9fd31c6ccf5018535139aa119f859d3c36b0;hp=c495c4cab71ed67b11d678e0cacaf02eec0bb312;hb=d248c63a252b0efcbcd9ef11cf7f8e22e594403e;hpb=4a728161f1a8a575ead2052acf67a0bdee237216 diff --git a/source/loader.cpp b/source/loader.cpp index c495c4c..bffa9fd 100644 --- a/source/loader.cpp +++ b/source/loader.cpp @@ -113,7 +113,16 @@ void Loader::load_statement(const Statement &st) try { - LoaderAction *act = find_action(ActionKey(st.keyword, st.get_signature())); + ActionKey key(st.keyword, st.get_signature()); + + if(!aux_loaders.empty() && !has_action(key)) + { + for(list::const_iterator i=aux_loaders.begin(); i!=aux_loaders.end(); ++i) + if((*i)->has_action(key)) + return (*i)->load_statement(st); + } + + LoaderAction *act = find_action(key); if(act) { sub_loaded = false; @@ -154,6 +163,20 @@ void Loader::add(const string &kwd, LoaderAction *act) actions[key] = act; } +void Loader::add_auxiliary_loader(Loader &ldr) +{ + aux_loaders.push_back(&ldr); +} + +bool Loader::has_action(const ActionKey &key) const +{ + ActionMap::const_iterator i = actions.lower_bound(ActionKey(key.keyword, string())); + for(; (i!=actions.end() && i->first.keyword==key.keyword); ++i) + if(signature_match(key.signature, i->first.signature)) + return true; + return false; +} + LoaderAction *Loader::find_action(const ActionKey &key) const { ActionMap::const_iterator begin = actions.lower_bound(ActionKey(key.keyword, string()));