X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Floader.cpp;h=54604dd8bebcd20abbd7892bc254aaf0b4c9ec8a;hb=e5d760ccfaaa01884be2424b62e47a24466e0c4b;hp=6da8599ba550e373828ea96af9bd81942216180c;hpb=b34b46788d69853eabdbbd9e71ca82f2f5c09df8;p=libs%2Fdatafile.git diff --git a/source/loader.cpp b/source/loader.cpp index 6da8599..54604dd 100644 --- a/source/loader.cpp +++ b/source/loader.cpp @@ -51,6 +51,12 @@ bool signature_match(const string &st_sig, const string &act_sig) namespace Msp { namespace DataFile { +Loader::Loader(): + cur_st(0), + allow_pointer_reload(true), + check_sub_loads(false) +{ } + Loader::~Loader() { for(ActionMap::iterator i = actions.begin(); i!=actions.end(); ++i) @@ -83,7 +89,12 @@ void Loader::load_statement(const Statement &st) { LoaderAction *act = find_action(ActionKey(st.keyword, st.get_signature())); if(act) + { + sub_loaded = false; act->execute(*this, st); + if(check_sub_loads && !st.sub.empty() && !sub_loaded) + throw Exception("Substatements were not loaded"); + } } catch(Exception &e) { @@ -103,11 +114,12 @@ void Loader::load_sub_with(Loader &ldr) throw InvalidState("load_sub called without current statement"); ldr.load(*cur_st); + sub_loaded = true; } void Loader::add(const string &kwd, LoaderAction *act) { - ActionKey key(kwd, act->get_signature()); + ActionKey key(kwd, (act ? act->get_signature() : "*")); ActionMap::iterator i = actions.find(key); if(i!=actions.end()) {