X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Floader.cpp;h=51cdabec478d812a23a8133f3716b77c58568163;hb=8d6360cbcd8fe92d97dcba5e68e3adb6f2c0c3bc;hp=6da8599ba550e373828ea96af9bd81942216180c;hpb=b34b46788d69853eabdbbd9e71ca82f2f5c09df8;p=libs%2Fdatafile.git diff --git a/source/loader.cpp b/source/loader.cpp index 6da8599..51cdabe 100644 --- a/source/loader.cpp +++ b/source/loader.cpp @@ -1,11 +1,4 @@ -/* $Id$ - -This file is part of libmspdatafile -Copyright © 2006-2008, 2010 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - -#include +#include #include "loader.h" #include "type.h" @@ -51,6 +44,11 @@ bool signature_match(const string &st_sig, const string &act_sig) namespace Msp { namespace DataFile { +Loader::Loader(): + cur_st(0), + check_sub_loads(false) +{ } + Loader::~Loader() { for(ActionMap::iterator i = actions.begin(); i!=actions.end(); ++i) @@ -83,7 +81,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 +106,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()) {