]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/loader.h
Some more code reformatting
[libs/datafile.git] / source / loader.h
index 0c1dda2cc776db8d293b8696ba6e0e4739aab016..57481cff28d36fca44b19db0c91784e7ecc54573 100644 (file)
@@ -44,24 +44,50 @@ See also classes BasicLoader and BasicLoader2.
 class Loader
 {
 private:
-       /**
-       Loads data from a statement.
-       */
-       void load(const Statement &st);
+       typedef std::map<std::string, LoaderAction *> ActionMap;
+
+       ActionMap       actions;
+       const Statement *cur_st;
 
+protected:
+       Loader(): cur_st(0) { }
 public:
-       /**
-       Loads statements from a parser.
-       */
+       virtual ~Loader();
+
+       /** Loads statements from a parser. */
        void load(Parser &p);
 
-       virtual ~Loader();
+private:
+       /** Loads data from a statement. */
+       void load(const Statement &st);
+
+       /** Processes a single statement */
+       void load_statement(const Statement &st);
+
 protected:
-       Loader(): cur_st(0) { }
+       /** Loads a sub-object from the statement being processed.  The Loader class
+       of the sub-object is automatically used. */
+       template<typename S>
+       void load_sub(S &s)
+       {
+               typename S::Loader ldr(s);
+               load_sub_with(ldr);
+       }
+
+       /** Loads a sub-object from the statement being processed with an extra
+       parameter for the Loader.  The Loader class of the sub-object is
+       automatically used. */
+       template<typename S, typename T>
+       void load_sub(S &s, T &p)
+       {
+               typename S::Loader ldr(s, p);
+               load_sub_with(ldr);
+       }
 
-       /**
-       Adds a keyword that is loaded with a zero-argument function.
-       */
+       /** Processes the current statement's substatements with another Loader. */
+       void load_sub_with(Loader &);
+
+       /** Adds a keyword that is loaded by calling a function. */
        template<typename L>
        void add(const std::string &k, void (L::*func)())
        { add(k, new LoaderFunc0<L>(func)); }
@@ -86,9 +112,7 @@ protected:
        void add(const std::string &k, void (L::*func)(A0, A1, A2, A3, A4))
        { add(k, new LoaderFunc5<L, A0, A1, A2, A3, A4>(func)); }
 
-       /**
-       Adds a keyword that is loaded into a variable of the loaded object.
-       */
+       /** Adds a keyword that is loaded into a member of the loaded object. */
        template<typename L, typename T0>
        void add(const std::string &k, T0 L::*p0)
        { add(k, new LoadValue1<L, T0>(p0)); }
@@ -97,44 +121,17 @@ protected:
        void add(const std::string &k, T0 L::*p0, T1 L::*p1)
        { add(k, new LoadValue2<L, T0, T1>(p0, p1)); }
 
-       /**
-       Adds a keyword that is recognized but ignored.
-       */
+       /** Adds a keyword that is recognized but ignored. */
        void add(const std::string &k)
        { add(k, 0); }
 
-       /**
-       Loads a sub-object from the statement being processed.  The Loader class of
-       the sub-object is automatically used.
-       */
-       template<typename S>
-       void load_sub(S &s)
-       {
-               typename S::Loader ldr(s);
-               load_sub_with(ldr);
-       }
-
-       /**
-       Loads a sub-object from the statement being processed with an extra parameter
-       for the Loader.  The Loader class of the sub-object is automatically used.
-       */
-       template<typename S, typename T>
-       void load_sub(S &s, T &p)
-       {
-               typename S::Loader ldr(s, p);
-               load_sub_with(ldr);
-       }
-
-       /**
-       Processes the current statement's substatements with another Loader.
-       */
-       void load_sub_with(Loader &);
+private:
+       void add(const std::string &, LoaderAction *);
 
-       /**
-       Returns the source of the statement being processed.  This can be used to
-       implement relative paths in include-like statements.  Note that the source
-       may not necessarily be a file.
-       */
+protected:
+       /** Returns the source of the statement being processed.  This can be used
+       to implement relative paths in include-like statements.  Note that the
+       source may not necessarily be a file. */
        const std::string &get_source() const
        {
                if(!cur_st)
@@ -143,14 +140,6 @@ protected:
        }
 
        virtual void finish() { }
-private:
-       typedef std::map<std::string, LoaderAction *> ActionMap;
-
-       ActionMap       actions;
-       const Statement *cur_st;
-
-       void add(const std::string &, LoaderAction *);
-       void load_statement(const Statement &st);
 };