]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/loader.cpp
Some more code reformatting
[libs/datafile.git] / source / loader.cpp
index 8d4f2bea35b07f0cf485cbc50a8d22fe146b5cd1..655514e5057c57a3c062317241abeeff5f9a08bb 100644 (file)
@@ -12,54 +12,34 @@ using namespace std;
 namespace Msp {
 namespace DataFile {
 
-void Loader::load(const Statement &st)
+Loader::~Loader()
 {
-       for(list<Statement>::const_iterator i=st.sub.begin(); i!=st.sub.end(); ++i)
-               load_statement(*i);
-       finish();
+       for(ActionMap::iterator i = actions.begin(); i!=actions.end(); ++i)
+               delete i->second;
 }
 
 void Loader::load(Parser &p)
 {
        while(p)
        {
-               Statement st=p.parse();
+               Statement st = p.parse();
                if(st.valid)
                        load_statement(st);
        }
        finish();
 }
 
-Loader::~Loader()
-{
-       for(ActionMap::iterator i=actions.begin(); i!=actions.end(); ++i)
-               delete i->second;
-}
-
-void Loader::load_sub_with(Loader &ldr)
-{
-       if(!cur_st)
-               throw InvalidState("load_sub called without current statement");
-
-       ldr.load(*cur_st);
-}
-
-void Loader::add(const string &k, LoaderAction *a)
+void Loader::load(const Statement &st)
 {
-       ActionMap::iterator i=actions.find(k);
-       if(i!=actions.end())
-       {
-               delete i->second;
-               i->second=a;
-       }
-       else
-               actions[k]=a;
+       for(list<Statement>::const_iterator i = st.sub.begin(); i!=st.sub.end(); ++i)
+               load_statement(*i);
+       finish();
 }
 
 void Loader::load_statement(const Statement &st)
 {
-       cur_st=&st;
-       ActionMap::iterator j=actions.find(st.keyword);
+       cur_st = &st;
+       ActionMap::iterator j = actions.find(st.keyword);
        if(j==actions.end())
                throw_at(KeyError("Unknown keyword", st.keyword), st.get_location());
        if(j->second)
@@ -75,7 +55,27 @@ void Loader::load_statement(const Statement &st)
                        throw;
                }
        }
-       cur_st=0;
+       cur_st = 0;
+}
+
+void Loader::load_sub_with(Loader &ldr)
+{
+       if(!cur_st)
+               throw InvalidState("load_sub called without current statement");
+
+       ldr.load(*cur_st);
+}
+
+void Loader::add(const string &k, LoaderAction *a)
+{
+       ActionMap::iterator i = actions.find(k);
+       if(i!=actions.end())
+       {
+               delete i->second;
+               i->second = a;
+       }
+       else
+               actions[k] = a;
 }
 
 } // namespace DataFile