]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/parser.cpp
More efficient way of loading binary files
[libs/datafile.git] / source / parser.cpp
index d298eca44765ca134ae8b65f191c31296830ca92..9ad70d8742884bfdfa40d5bebbc467b9e289afe7 100644 (file)
@@ -86,5 +86,24 @@ void Parser::process_control_statement(const Statement &st)
                mode->process_control_statement(st);
 }
 
+const StatementKey *Parser::peek(unsigned level)
+{
+       while(1)
+       {
+               const StatementKey *key = mode->peek(level);
+               if(key && !key->keyword.compare(0, 2, "__"))
+                       process_control_statement(mode->parse());
+               else
+                       return key;
+       }
+}
+
+bool Parser::parse_and_load(unsigned level, Loader &ldr, const LoaderAction &act)
+{
+       // Peek first to get any control statements processed
+       peek(level);
+       return mode->parse_and_load(level, ldr, act);
+}
+
 } // namespace DataFile
 } // namespace Msp