From: Mikko Rasa Date: Sun, 16 Jun 2013 08:25:58 +0000 (+0300) Subject: Consider full statement signature when dealing with auxiliary loaders X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=d248c63a252b0efcbcd9ef11cf7f8e22e594403e;p=libs%2Fdatafile.git Consider full statement signature when dealing with auxiliary loaders --- diff --git a/source/loader.cpp b/source/loader.cpp index 2cd27e9..bffa9fd 100644 --- a/source/loader.cpp +++ b/source/loader.cpp @@ -113,14 +113,16 @@ void Loader::load_statement(const Statement &st) try { - if(!aux_loaders.empty() && !has_keyword(st.keyword)) + 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_keyword(st.keyword)) + if((*i)->has_action(key)) return (*i)->load_statement(st); } - LoaderAction *act = find_action(ActionKey(st.keyword, st.get_signature())); + LoaderAction *act = find_action(key); if(act) { sub_loaded = false; @@ -166,10 +168,13 @@ void Loader::add_auxiliary_loader(Loader &ldr) aux_loaders.push_back(&ldr); } -bool Loader::has_keyword(const string &kwd) const +bool Loader::has_action(const ActionKey &key) const { - ActionMap::const_iterator i = actions.lower_bound(ActionKey(kwd, string())); - return i!=actions.end() && i->first.keyword==kwd; + 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 diff --git a/source/loader.h b/source/loader.h index 3ab6d28..dcbbd5d 100644 --- a/source/loader.h +++ b/source/loader.h @@ -136,7 +136,7 @@ protected: void add_auxiliary_loader(Loader &); private: - bool has_keyword(const std::string &) const; + bool has_action(const ActionKey &) const; LoaderAction *find_action(const ActionKey &) const; protected: