-/* $Id$
-
-This file is part of libmspdatafile
-Copyright © 2006-2008, 2010 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
-#include <msp/strings/formatter.h>
+#include <msp/strings/format.h>
#include "loader.h"
#include "type.h"
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)
{
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)
{
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())
{