GirToBac  0.2
Create FB Headers from GObject Introspection *.gir files
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
GirToBac_RepData.bas
Go to the documentation of this file.
1 /** \file GirToBac_RepData.bas
2 \brief Helper Classes list and replacements.
3 
4 This file contains two helper classes for a list (first in first out
5 stack) and for a replacement UDT, that checks and replaces a text.
6 It also contains the parser for the configuration file.
7 
8 */
9 
10 
11 /** \brief Object to check texts (Su) and provide replacements (Er)
12 
13 This object can get feeded by search and replacement texts. After
14 adding some pairs the RepData::rep() member function is used to
15 receive the replacement text for a match or the original text
16 otherwise. The search is done case-sensitive. Search text must not
17 contain CHR(0) to CHR(2), because these characters are used
18 internally.
19 
20 The object counts the number of entries and the number of matches
21 for each entry. The list member function executes a callback
22 function on each entry.
23 
24 */
25 class RepData{ public:
26  CONST_gchar_PTR Na;//!< the name of the XML-tag
27  STRING
28 Er,//!< buffer holding replacement texts and match-entry-counters
29  Su = MKL(0) & CHR(1) ;//!< buffer holding the entry counter, search texts and the start of their replacements
30 RepData (BYVAL_AS_CONST_gchar_PTR T);
31 FUNCTION_AS_LONG Az ();
32  SUB add (BYVAL_AS_CONST_ZSTRING_PTR, BYVAL_AS_CONST_ZSTRING_PTR);
33 FUNCTION_AS_CONST_ZSTRING_PTR rep (BYVAL_AS_CONST_gchar_PTR T);
34 SUB list (BYREF_AS_STRING Li);
35 };
36 
37 //! \brief the constructor stores the tag name
38 RepData::RepData (BYVAL_AS_CONST_gchar_PTR T) {
39 
40 };
41 
42 /** \brief provide number of entries in the buffer
43 \returns entries in buffer
44 
45 Each time a text gets added to the UDT a counter gets increased.
46 This function provides the counter result. (An entry can get added
47 only once, a duplicate doesn't get counted.)
48 
49 */
50 FUNCTION_AS_LONG RepData::Az () {
51 };
52 
53 
54 /** \brief Generate a list of un-used symbols
55 \param Li string to list un-used symbols
56 
57 Each symbol-found gets counted. This procedure adds the un-used
58 symbols to the list in the string.
59 
60 */
61 SUB RepData::list (BYREF_AS_STRING Li) {
62 
63 
64 
65 
66 
67 
68 
69 
70 };
71 
72 
73 /** \brief Add entries to buffers
74 \param S The text to search for
75 \param E The replacement for this search text
76 \returns Zero on success (error text otherwise)
77 
78 This function gets called to add some text to the UDT. It adds both,
79 the text to search for and the text replacement to the buffers and
80 sets their counter to zero. In case of duplicates or illegal
81 characters in the search string an error text gets returned (and
82 zero on success). There's no checking of the replacement string, it
83 mustn't contain zero characters.
84 
85 */
86 SUB RepData::add (BYVAL_AS_CONST_ZSTRING_PTR S, BYVAL_AS_CONST_ZSTRING_PTR E) {
87 
88 
89 
90 
91 
92 };
93 
94 
95 /** \brief Get replacement for a text (if any))
96 \param T The text to search for
97 \returns The replacemnt (if any) or the original text
98 
99 This function searches for a text in the search buffer. On found the
100 text (case-sensitive) it returns a pointer to the replacement string
101 (defined when calling the function RepData::add()). In case of no
102 match in the search buffer a pointer to the original text gets
103 returned.
104 
105 */
106 FUNCTION_AS_CONST_ZSTRING_PTR RepData::rep (BYVAL_AS_CONST_gchar_PTR T) {
107 
108 
109 
110 
111 
112 };
113 
114 /** \brief A simple fifo stack list
115 
116 This is a simple first in first out stack. It's used to store the
117 symbols for the ordered part of the header (passX). The entries are
118 separated by ; characters.
119 
120 */
121 class Stack{ public:
122  STRING Dat = ";" ;//!< The buffer for entries, ; separated
123  INTEGER A = 1 ;//!< Start position of next entry (-1)
124  SUB add (BYVAL_AS_CONST_gchar_PTR);
125 FUNCTION_AS_STRING nxt ();
126  FUNCTION_AS_INTEGER find (BYVAL_AS_CONST_gchar_PTR T);
127 };
128 
129 
130 /** \brief Add entries to Stack data
131 \param S The text to add
132 
133 This SUB gets called to add a word to the Stack. It adds the text
134 and the separator character ';'. It's possible to add more than one
135 word, but the text must not contain the separator character. Here
136 it's used for symbol names (without white-spaces).
137 
138 */
139 SUB Stack::add (BYVAL_AS_CONST_gchar_PTR S) {
140  Stack.find();
141 
142 };
143 
144 
145 /** \brief The text of the next entry
146 \returns Retrieves the next entry
147 
148 The stack is meant to add symbols in the required order (read from
149 the configuration file) and retrieve the symbol names later on in
150 the given order, each entry once. To retrieve the entries a second
151 time the position counter needs to get re-initialized (A = 2).)
152 
153 */
154 FUNCTION_AS_STRING Stack::nxt () {
155 
156 
157 };
158 
159 
160 /** \brief Search the stack for a text
161 \param T Text to search for
162 \returns Text position in stack buffer (or zero)
163 
164 This function is used to find a text in the text buffer. On found
165 the text position gets returned (zero otherwise).)
166 
167 */
168 FUNCTION_AS_INTEGER Stack::find (BYVAL_AS_CONST_gchar_PTR T) {
169 
170 };
171 
172 
173 RepData
174 FB_TYP = @"type", //!< Replacements for type declarations
175 FB_NAM = @"name" ;//!< Replacements for symbols (names)
176 Stack
177 FIRST;//!< FiFo stack for ordered elements (pass X))
178 
179 
180 //! The \GMP for the configuration file \em *.GirToBac.
181  SUB_CDECL g2b_parser(){
182 
183 
184 
185 
186 
187 VAR n = find_value("search", AttNams, AttVals) ;
188 
189  RepData.add();
190 
191 VAR s = find_value("search", AttNams, AttVals) ;
192 
193 VAR r = find_value("replace", AttNams, AttVals) ;
194 VAR a = find_value("add", AttNams, AttVals) ;
195  RepData.add();
196 
197 VAR e = *s & *a ;
198  RepData.add();
199 
200 VAR s = find_value("search", AttNams, AttVals) ;
201 
202 VAR r = find_value("replace", AttNams, AttVals) ;
203 VAR a = find_value("add", AttNams, AttVals) ;
204  RepData.add();
205 
206 VAR e = *s & *a ;
207  RepData.add();
208 
209 VAR n = find_value("name", AttNams, AttVals) ;
210 
211 
212 
213 VAR n = find_value("name", AttNams, AttVals) ;
214 
215 
216 
217 VAR n = find_value("name", AttNams, AttVals) ;
218 
219 
220 
221 
222 
223 
224 
225 
226 
227  };
RepData FB_NAM
Replacements for symbols (names)
RepData(BYVAL_AS_CONST_gchar_PTR T)
the constructor stores the tag name
FUNCTION_AS_LONG Az()
provide number of entries in the buffer
STRING Su
buffer holding the entry counter, search texts and the start of their replacements ...
RepData FB_TYP
Replacements for type declarations.
Stack FIRST
FiFo stack for ordered elements (pass X))
STRING Dat
The buffer for entries, ; separated.
SUB list(BYREF_AS_STRING Li)
Generate a list of un-used symbols.
SUB add(BYVAL_AS_CONST_gchar_PTR)
Add entries to Stack data.
STRING Er
buffer holding replacement texts and match-entry-counters
FUNCTION_AS_INTEGER find(BYVAL_AS_CONST_gchar_PTR T)
Search the stack for a text.
A simple fifo stack list.
SUB_CDECL g2b_parser()
The GMarkupParser for the configuration file *.GirToBac.
SUB add(BYVAL_AS_CONST_ZSTRING_PTR, BYVAL_AS_CONST_ZSTRING_PTR)
Add entries to buffers.
FUNCTION_AS_CONST_gchar_PTR find_value(BYVAL_AS_CONST_gchar_PTR Nam, BYVAL_AS_CONST_gchar_PTR_PTR AttNams, BYVAL_AS_CONST_gchar_PTR_PTR AttVals)
Find an attribute by its name.
Definition: GirToBac.bas:147
FUNCTION_AS_CONST_ZSTRING_PTR rep(BYVAL_AS_CONST_gchar_PTR T)
Get replacement for a text (if any))
Object to check texts (Su) and provide replacements (Er)
FUNCTION_AS_STRING nxt()
The text of the next entry.
INTEGER A
Start position of next entry (-1)
CONST_gchar_PTR Na
the name of the XML-tag