1 //
2 // aegis - project change supervisor
3 // Copyright (C) 2008 Peter Miller
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or (at
8 // your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License along
16 // with this program. If not, see <http://www.gnu.org/licenses/>.
17 //
18 
19 #ifndef LIBAEGIS_META_CONTEXT_INTROSPECTOR_H
20 #define LIBAEGIS_META_CONTEXT_INTROSPECTOR_H
21 
22 #include <libaegis/introspector.h>
23 #include <libaegis/introspector/vector.h>
24 #include <libaegis/meta_context.h>
25 
26 /**
27   * The meta_context_introspector class is used to represent the
28   * processing for parsing meta-data using the introspector technique.
29   */
30 class meta_context_introspector:
31     public meta_context
32 {
33 public:
34     /**
35       * The destructor.
36       */
37     virtual ~meta_context_introspector();
38 
39     /**
40       * The default constructor.
41       */
42     meta_context_introspector();
43 
44     /**
45       * The parse_file method is used to parse the given file through
46       * the given introspector.  It expected that this will be called
47       * from code generated by fmtgen.
48       *
49       * @param filename
50       *     The name of the file to be parsed.
51       * @param ip
52       *     The instrospector to parse into (it is expected to have its
53       *     own reference to the data destination).
54       */
55     void parse_file(const nstring &filename, const introspector::pointer &ip);
56 
57 protected:
58     // See base class for documentation.
59     void integer(long n);
60 
61     // See base class for documentation.
62     void real(double n);
63 
64     // See base class for documentation.
65     void string(const nstring &s);
66 
67     // See base class for documentation.
68     void enumeration(const nstring &s);
69 
70     // See base class for documentation.
71     void list();
72 
73     // See base class for documentation.
74     void list_end();
75 
76     // See base class for documentation.
77     void field(const nstring &name);
78 
79     // See base class for documentation.
80     void field_end();
81 
82     // See base class for documentation.
83     void end();
84 
85 private:
86     /**
87       * The stack instance variable is used to remember the push-don
88       * stack of introspectors used to parse the meta-data.
89       */
90     introspector_vector stack;
91 
92     /**
93       * The copy constructor.  Do not use.
94       */
95     meta_context_introspector(const meta_context_introspector &);
96 
97     /**
98       * The assignment operator.  Do not use.
99       */
100     meta_context_introspector &operator=(const meta_context_introspector &);
101 };
102 
103 #endif // LIBAEGIS_META_CONTEXT_INTROSPECTOR_H
104