1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>NeL: NLGEORGES::CFormLoader class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.6 -->
<div class="qindex"> <form class="search" action="search.php" method="get">
<a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a> | <span class="search"><u>S</u>earch for <input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div>
<h1>NLGEORGES::CFormLoader Class Reference</h1><code>#include <<a class="el" href="a05731.html">form_loader.h</a>></code>
<p>
<p>Inheritance diagram for NLGEORGES::CFormLoader:
<p><center><img src="a02558.png" usemap="#NLGEORGES::CFormLoader_map" border="0" alt=""></center>
<map name="NLGEORGES::CFormLoader_map">
<area href="a02559.html" alt="NLGEORGES::UFormLoader" shape="rect" coords="0,0,172,24">
</map>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Georges form loader implementation<p>
<dl compact><dt><b>Author:</b></dt><dd>Cyril 'Hulud' Corvazier <p>
Nevrax France </dd></dl>
<dl compact><dt><b>Date:</b></dt><dd>2002 </dd></dl>
<p>
<p>
Definition at line <a class="el" href="a05731.html#l00049">49</a> of file <a class="el" href="a05731.html">form_loader.h</a>.<table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03926.html">UForm</a> * </td><td class="memItemRight" valign=bottom><a class="el" href="a02558.html#NLGEORGES_1_1CFormLoadera0">loadForm</a> (const char *<a class="el" href="a04560.html#a1">filename</a>)</td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a02546.html">CFormDfn</a> * </td><td class="memItemRight" valign=bottom><a class="el" href="a02558.html#NLGEORGES_1_1CFormLoadera1">loadFormDfn</a> (const char *<a class="el" href="a04560.html#a1">filename</a>, bool forceLoad)</td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a02547.html">UFormDfn</a> * </td><td class="memItemRight" valign=bottom><a class="el" href="a02558.html#NLGEORGES_1_1CFormLoadera2">loadFormDfn</a> (const char *<a class="el" href="a04560.html#a1">filename</a>)</td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03623.html">UType</a> * </td><td class="memItemRight" valign=bottom><a class="el" href="a02558.html#NLGEORGES_1_1CFormLoadera3">loadFormType</a> (const char *<a class="el" href="a04560.html#a1">filename</a>)</td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03622.html">CType</a> * </td><td class="memItemRight" valign=bottom><a class="el" href="a02558.html#NLGEORGES_1_1CFormLoadera4">loadType</a> (const char *<a class="el" href="a04560.html#a1">filename</a>)</td></tr>
<tr><td colspan=2><br><h2>Static Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a02559.html">UFormLoader</a> * </td><td class="memItemRight" valign=bottom><a class="el" href="a02559.html#NLGEORGES_1_1UFormLoadere0">createLoader</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Create a form loader. <a href="#NLGEORGES_1_1UFormLoadere0"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02559.html#NLGEORGES_1_1UFormLoadere1">releaseLoader</a> (<a class="el" href="a02559.html">UFormLoader</a> *loader)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Create a form loader. <a href="#NLGEORGES_1_1UFormLoadere1"></a><br><br></td></tr>
<tr><td colspan=2><br><h2>Private Types</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>typedef std::map< std::string,<br>
<a class="el" href="a03321.html">NLMISC::CRefPtr</a>< <a class="el" href="a02546.html">CFormDfn</a> > > </td><td class="memItemRight" valign=bottom><a class="el" href="a02558.html#NLGEORGES_1_1CFormLoadery0">TFormDfnMap</a></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>typedef std::map< std::string,<br>
<a class="el" href="a03321.html">NLMISC::CRefPtr</a>< <a class="el" href="a02544.html">CForm</a> > > </td><td class="memItemRight" valign=bottom><a class="el" href="a02558.html#NLGEORGES_1_1CFormLoadery1">TFormMap</a></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>typedef std::map< std::string,<br>
<a class="el" href="a03321.html">NLMISC::CRefPtr</a>< <a class="el" href="a03622.html">CType</a> > > </td><td class="memItemRight" valign=bottom><a class="el" href="a02558.html#NLGEORGES_1_1CFormLoadery2">TTypeMap</a></td></tr>
<tr><td colspan=2><br><h2>Private Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>virtual void </td><td class="memItemRight" valign=bottom><a class="el" href="a02558.html#NLGEORGES_1_1CFormLoaderd0">warning</a> (bool exception, const char *function, const char *<a class="el" href="a04223.html#a641">format</a>,...) const </td></tr>
<tr><td colspan=2><br><h2>Private Attributes</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a02558.html#NLGEORGES_1_1CFormLoadery1">TFormMap</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02558.html#NLGEORGES_1_1CFormLoaderr0">_MapForm</a></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a02558.html#NLGEORGES_1_1CFormLoadery0">TFormDfnMap</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02558.html#NLGEORGES_1_1CFormLoaderr1">_MapFormDfn</a></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a02558.html#NLGEORGES_1_1CFormLoadery2">TTypeMap</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02558.html#NLGEORGES_1_1CFormLoaderr2">_MapType</a></td></tr>
</table>
<hr><h2>Member Typedef Documentation</h2>
<a class="anchor" name="NLGEORGES_1_1CFormLoadery0" doxytag="NLGEORGES::CFormLoader::TFormDfnMap" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> typedef std::map<std::string, <a class="el" href="a03321.html">NLMISC::CRefPtr</a><<a class="el" href="a02546.html">CFormDfn</a>> > <a class="el" href="a02558.html#NLGEORGES_1_1CFormLoadery0">NLGEORGES::CFormLoader::TFormDfnMap</a><code> [private]</code>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
<p>
Definition at line <a class="el" href="a05731.html#l00068">68</a> of file <a class="el" href="a05731.html">form_loader.h</a>. </td>
</tr>
</table>
<a class="anchor" name="NLGEORGES_1_1CFormLoadery1" doxytag="NLGEORGES::CFormLoader::TFormMap" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> typedef std::map<std::string, <a class="el" href="a03321.html">NLMISC::CRefPtr</a><<a class="el" href="a02544.html">CForm</a>> > <a class="el" href="a02558.html#NLGEORGES_1_1CFormLoadery1">NLGEORGES::CFormLoader::TFormMap</a><code> [private]</code>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
<p>
Definition at line <a class="el" href="a05731.html#l00069">69</a> of file <a class="el" href="a05731.html">form_loader.h</a>. </td>
</tr>
</table>
<a class="anchor" name="NLGEORGES_1_1CFormLoadery2" doxytag="NLGEORGES::CFormLoader::TTypeMap" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> typedef std::map<std::string, <a class="el" href="a03321.html">NLMISC::CRefPtr</a><<a class="el" href="a03622.html">CType</a>> > <a class="el" href="a02558.html#NLGEORGES_1_1CFormLoadery2">NLGEORGES::CFormLoader::TTypeMap</a><code> [private]</code>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
<p>
Definition at line <a class="el" href="a05731.html#l00067">67</a> of file <a class="el" href="a05731.html">form_loader.h</a>. </td>
</tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="NLGEORGES_1_1UFormLoadere0" doxytag="NLGEORGES::CFormLoader::createLoader" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="a02559.html">UFormLoader</a> * NLGEORGES::UFormLoader::createLoader </td>
<td class="md" valign="top">( </td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top"> ) </td>
<td class="md" nowrap><code> [static, inherited]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Create a form loader.
<p>
<p>
Definition at line <a class="el" href="a05730.html#l00053">53</a> of file <a class="el" href="a05730.html">form_loader.cpp</a>.
<p>
Referenced by <a class="el" href="a05465.html#l00358">NLSOUND::CAudioMixerUser::init()</a>, and <a class="el" href="a05926.html#l00145">loadForm()</a>.
<p>
<div class="fragment"><pre>00054 {
00055 <span class="keywordflow">return</span> <span class="keyword">new</span> CFormLoader;
00056 }
</pre></div> </td>
</tr>
</table>
<a class="anchor" name="NLGEORGES_1_1CFormLoadera0" doxytag="NLGEORGES::CFormLoader::loadForm" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="a03926.html">UForm</a> * NLGEORGES::CFormLoader::loadForm </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const char * </td>
<td class="mdname1" valign="top" nowrap> <em>filename</em> </td>
<td class="md" valign="top"> ) </td>
<td class="md" nowrap><code> [virtual]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Load a form, use NMISC::CPath to find the file.<p>
The pointer on the form must be held in a CSmartPtr<UForm>. Returns NULL if the form can't be loaded.
<p>
Implements <a class="el" href="a02559.html#NLGEORGES_1_1UFormLoadera0">NLGEORGES::UFormLoader</a>.
<p>
Definition at line <a class="el" href="a05730.html#l00205">205</a> of file <a class="el" href="a05730.html">form_loader.cpp</a>.
<p>
References <a class="el" href="a05731.html#l00078">_MapForm</a>, <a class="el" href="a05538.html#l02654">file</a>, <a class="el" href="a05646.html#l00225">index</a>, <a class="el" href="a05730.html#l00302">loadFormDfn()</a>, <a class="el" href="a05586.html#l00536">NLMISC::strlwr()</a>, <a class="el" href="a05981.html#l00105">uint</a>, and <a class="el" href="a05730.html#l00316">warning()</a>.
<p>
Referenced by <a class="el" href="a05724.html#l00154">NLGEORGES::CForm::readParent()</a>.
<p>
<div class="fragment"><pre>00206 {
00207 <span class="comment">// Lower string filename</span>
00208 string lowerStr = <a class="code" href="a05378.html#a273">strlwr</a> ((string)filename);
00209 lowerStr = CFile::getFilename (lowerStr);
00210
00211 <span class="comment">// Already in the map ?</span>
00212 TFormMap::iterator ite = <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoaderr0">_MapForm</a>.find (lowerStr);
00213 <span class="keywordflow">if</span> (ite != <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoaderr0">_MapForm</a>.end() && ite->second)
00214 {
00215 <span class="comment">// Return the pointer</span>
00216 <span class="keywordflow">return</span> (CForm*)ite->second;
00217 }
00218 <span class="keywordflow">else</span>
00219 {
00220 <span class="comment">// Create the form</span>
00221 CForm *form = <span class="keyword">new</span> CForm;
00222
00223 <span class="comment">// Insert the form first</span>
00224 <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoaderr0">_MapForm</a>[lowerStr] = form;
00225
00226 <span class="comment">// Load the type</span>
00227 <span class="keywordflow">try</span>
00228 {
00229 <span class="comment">// Get the form DFN filename</span>
00230 string name = CFile::getFilename (filename);
00231 <a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a566">index</a> = name.rfind (<span class="charliteral">'.'</span>);
00232 <span class="keywordflow">if</span> (<a class="code" href="a04223.html#a566">index</a> == string::npos)
00233 {
00234 <span class="comment">// Output error</span>
00235 <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoaderd0">warning</a> (<span class="keyword">false</span>, <span class="stringliteral">"loadForm"</span>, <span class="stringliteral">"Form name is invalid (%s). It should have the extension of its DFN type."</span>, name.c_str ());
00236
00237 <span class="comment">// Delete the form</span>
00238 <span class="keyword">delete</span> form;
00239 form = NULL;
00240 <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoaderr0">_MapForm</a>.erase (lowerStr);
00241 }
00242 name = name.substr (index+1);
00243 name += <span class="stringliteral">".dfn"</span>;
00244
00245 <span class="comment">// Load the dfn</span>
00246 CFormDfn *dfn = <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoadera2">loadFormDfn</a> (name.c_str (), <span class="keyword">false</span>);
00247 <span class="keywordflow">if</span> (dfn)
00248 {
00249 <span class="comment">// Open the file</span>
00250 name = CPath::lookup (filename, <span class="keyword">false</span>, <span class="keyword">false</span>);
00251 <span class="keywordflow">if</span> (name.empty())
00252 name = <a class="code" href="a05377.html#a2">filename</a>;
00253 <a class="code" href="a02653.html">CIFile</a> <a class="code" href="a04115.html#a95">file</a>;
00254 <span class="keywordflow">if</span> (<a class="code" href="a04115.html#a95">file</a>.open (name))
00255 {
00256 <span class="comment">// Init an xml stream</span>
00257 CIXml read;
00258 read.init (file);
00259
00260 <span class="comment">// Read the form</span>
00261 form->read (read.getRootNode (), *<span class="keyword">this</span>, dfn, <a class="code" href="a05377.html#a2">filename</a>);
00262 }
00263 <span class="keywordflow">else</span>
00264 {
00265 <span class="comment">// Output error</span>
00266 <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoaderd0">warning</a> (<span class="keyword">false</span>, <span class="stringliteral">"loadForm"</span>, <span class="stringliteral">"Can't open the form file (%s)."</span>, filename);
00267
00268 <span class="comment">// Delete the form</span>
00269 <span class="keyword">delete</span> form;
00270 form = NULL;
00271 <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoaderr0">_MapForm</a>.erase (lowerStr);
00272 }
00273 }
00274 <span class="keywordflow">else</span>
00275 {
00276 <span class="comment">// Output error</span>
00277 <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoaderd0">warning</a> (<span class="keyword">false</span>, <span class="stringliteral">"loadForm"</span>, <span class="stringliteral">"Can't open the dfn file (%s)."</span>, name.c_str ());
00278
00279 <span class="comment">// Delete the form</span>
00280 <span class="keyword">delete</span> form;
00281 form = NULL;
00282 <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoaderr0">_MapForm</a>.erase (lowerStr);
00283 }
00284 }
00285 <span class="keywordflow">catch</span> (<a class="code" href="a02482.html">Exception</a> &e)
00286 {
00287 <span class="comment">// Output error</span>
00288 <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoaderd0">warning</a> (<span class="keyword">false</span>, <span class="stringliteral">"loadForm"</span>, <span class="stringliteral">"Error while loading the form (%s): %s"</span>, filename, e.what());
00289
00290 <span class="comment">// Delete the form</span>
00291 <span class="keyword">delete</span> form;
00292 form = NULL;
00293 <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoaderr0">_MapForm</a>.erase (lowerStr);
00294 }
00295
00296 <span class="keywordflow">return</span> form;
00297 }
00298 }
</pre></div> </td>
</tr>
</table>
<a class="anchor" name="NLGEORGES_1_1CFormLoadera1" doxytag="NLGEORGES::CFormLoader::loadFormDfn" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="a02546.html">CFormDfn</a> * NLGEORGES::CFormLoader::loadFormDfn </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const char * </td>
<td class="mdname" nowrap> <em>filename</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>bool </td>
<td class="mdname" nowrap> <em>forceLoad</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
<p>
Definition at line <a class="el" href="a05730.html#l00139">139</a> of file <a class="el" href="a05730.html">form_loader.cpp</a>.
<p>
References <a class="el" href="a05731.html#l00075">_MapFormDfn</a>, <a class="el" href="a05538.html#l02654">file</a>, <a class="el" href="a05586.html#l00536">NLMISC::strlwr()</a>, and <a class="el" href="a05730.html#l00316">warning()</a>.
<p>
<div class="fragment"><pre>00140 {
00141 <span class="comment">// Lower string filename</span>
00142 string lowerStr = <a class="code" href="a05378.html#a273">strlwr</a> ((string)filename);
00143 lowerStr = CFile::getFilename (lowerStr);
00144
00145 <span class="comment">// Already in the map ?</span>
00146 TFormDfnMap::iterator ite = <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoaderr1">_MapFormDfn</a>.find (lowerStr);
00147 <span class="keywordflow">if</span> (ite != <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoaderr1">_MapFormDfn</a>.end() && ite->second)
00148 {
00149 <span class="comment">// Return the pointer</span>
00150 <span class="keywordflow">return</span> ite->second;
00151 }
00152 <span class="keywordflow">else</span>
00153 {
00154 <span class="comment">// Create the formDfn</span>
00155 CFormDfn *formDfn = <span class="keyword">new</span> CFormDfn;
00156
00157 <span class="comment">// Insert the form first</span>
00158 <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoaderr1">_MapFormDfn</a>[lowerStr] = formDfn;
00159
00160 <span class="comment">// Load the type</span>
00161 <span class="keywordflow">try</span>
00162 {
00163 <span class="comment">// Open the file</span>
00164 string name = CPath::lookup (filename, <span class="keyword">false</span>, <span class="keyword">false</span>);
00165 <span class="keywordflow">if</span> (name.empty())
00166 name = <a class="code" href="a05377.html#a2">filename</a>;
00167 <a class="code" href="a02653.html">CIFile</a> <a class="code" href="a04115.html#a95">file</a>;
00168 <span class="keywordflow">if</span> (<a class="code" href="a04115.html#a95">file</a>.open (name))
00169 {
00170 <span class="comment">// Init an xml stream</span>
00171 CIXml read;
00172 read.init (file);
00173
00174 <span class="comment">// Read the type</span>
00175 formDfn->read (read.getRootNode (), *<span class="keyword">this</span>, forceLoad, <a class="code" href="a05377.html#a2">filename</a>);
00176 }
00177 <span class="keywordflow">else</span>
00178 {
00179 <span class="comment">// Output error</span>
00180 <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoaderd0">warning</a> (<span class="keyword">false</span>, <span class="stringliteral">"loadFormDfn"</span>, <span class="stringliteral">"Can't open the form file (%s)."</span>, filename);
00181
00182 <span class="comment">// Delete the formDfn</span>
00183 <span class="keyword">delete</span> formDfn;
00184 formDfn = NULL;
00185 <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoaderr1">_MapFormDfn</a>.erase (lowerStr);
00186 }
00187 }
00188 <span class="keywordflow">catch</span> (<a class="code" href="a02482.html">Exception</a> &e)
00189 {
00190 <span class="comment">// Output error</span>
00191 <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoaderd0">warning</a> (<span class="keyword">false</span>, <span class="stringliteral">"loadFormDfn"</span>, <span class="stringliteral">"Error while loading the form (%s): %s"</span>, filename, e.what());
00192
00193 <span class="comment">// Delete the formDfn</span>
00194 <span class="keyword">delete</span> formDfn;
00195 formDfn = NULL;
00196 <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoaderr1">_MapFormDfn</a>.erase (lowerStr);
00197 }
00198
00199 <span class="keywordflow">return</span> formDfn;
00200 }
00201 }
</pre></div> </td>
</tr>
</table>
<a class="anchor" name="NLGEORGES_1_1CFormLoadera2" doxytag="NLGEORGES::CFormLoader::loadFormDfn" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="a02547.html">UFormDfn</a> * NLGEORGES::CFormLoader::loadFormDfn </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const char * </td>
<td class="mdname1" valign="top" nowrap> <em>filename</em> </td>
<td class="md" valign="top"> ) </td>
<td class="md" nowrap><code> [virtual]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Load a DFN, use NMISC::CPath to find the file.<p>
The pointer on the form must be held in a CSmartPtr<UFormDfn>. Returns NULL if the DFN can't be loaded.
<p>
Implements <a class="el" href="a02559.html#NLGEORGES_1_1UFormLoadera1">NLGEORGES::UFormLoader</a>.
<p>
Definition at line <a class="el" href="a05730.html#l00302">302</a> of file <a class="el" href="a05730.html">form_loader.cpp</a>.
<p>
Referenced by <a class="el" href="a05730.html#l00205">loadForm()</a>, <a class="el" href="a05728.html#l02175">NLGEORGES::CFormElmVirtualStruct::read()</a>, <a class="el" href="a05726.html#l00118">NLGEORGES::CFormDfn::read()</a>, <a class="el" href="a05726.html#l00477">NLGEORGES::CFormDfn::CEntry::setDfn()</a>, and <a class="el" href="a05726.html#l00456">NLGEORGES::CFormDfn::setParent()</a>.
<p>
<div class="fragment"><pre>00303 {
00304 <span class="keywordflow">return</span> <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoadera2">loadFormDfn</a> (filename, <span class="keyword">false</span>);
00305 }
</pre></div> </td>
</tr>
</table>
<a class="anchor" name="NLGEORGES_1_1CFormLoadera3" doxytag="NLGEORGES::CFormLoader::loadFormType" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="a03623.html">UType</a> * NLGEORGES::CFormLoader::loadFormType </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const char * </td>
<td class="mdname1" valign="top" nowrap> <em>filename</em> </td>
<td class="md" valign="top"> ) </td>
<td class="md" nowrap><code> [virtual]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Load a type, use NMISC::CPath to find the file.<p>
The pointer on the form must be held in a CSmartPtr<UType>. Returns NULL if the type can't be loaded.
<p>
Implements <a class="el" href="a02559.html#NLGEORGES_1_1UFormLoadera2">NLGEORGES::UFormLoader</a>.
<p>
Definition at line <a class="el" href="a05730.html#l00309">309</a> of file <a class="el" href="a05730.html">form_loader.cpp</a>.
<p>
References <a class="el" href="a05730.html#l00069">loadType()</a>.
<p>
<div class="fragment"><pre>00310 {
00311 <span class="keywordflow">return</span> <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoadera4">loadType</a> (filename);
00312 }
</pre></div> </td>
</tr>
</table>
<a class="anchor" name="NLGEORGES_1_1CFormLoadera4" doxytag="NLGEORGES::CFormLoader::loadType" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="a03622.html">CType</a> * NLGEORGES::CFormLoader::loadType </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const char * </td>
<td class="mdname1" valign="top" nowrap> <em>filename</em> </td>
<td class="md" valign="top"> ) </td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
<p>
Definition at line <a class="el" href="a05730.html#l00069">69</a> of file <a class="el" href="a05730.html">form_loader.cpp</a>.
<p>
References <a class="el" href="a05731.html#l00072">_MapType</a>, <a class="el" href="a05538.html#l02654">file</a>, <a class="el" href="a05586.html#l00536">NLMISC::strlwr()</a>, <a class="el" href="a05646.html#l00244">type</a>, and <a class="el" href="a05730.html#l00316">warning()</a>.
<p>
Referenced by <a class="el" href="a05730.html#l00309">loadFormType()</a>, <a class="el" href="a05726.html#l00118">NLGEORGES::CFormDfn::read()</a>, and <a class="el" href="a05726.html#l00467">NLGEORGES::CFormDfn::CEntry::setType()</a>.
<p>
<div class="fragment"><pre>00070 {
00071 <span class="comment">// Lower string filename</span>
00072 string lowerStr = <a class="code" href="a05378.html#a273">strlwr</a> ((string)filename);
00073 lowerStr = CFile::getFilename (lowerStr);
00074
00075 <span class="comment">// Already in the map ?</span>
00076 TTypeMap::iterator ite = <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoaderr2">_MapType</a>.find (lowerStr);
00077 <span class="keywordflow">if</span> (ite != <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoaderr2">_MapType</a>.end() && (ite->second != NULL) )
00078 {
00079 <span class="comment">// Return the pointer</span>
00080 <span class="keywordflow">return</span> ite->second;
00081 }
00082 <span class="keywordflow">else</span>
00083 {
00084 <span class="comment">// Create the type</span>
00085 CType *<a class="code" href="a04223.html#a581">type</a> = <span class="keyword">new</span> CType;
00086
00087 <span class="comment">// Load the type</span>
00088 <span class="keywordflow">try</span>
00089 {
00090 <span class="comment">// Open the file</span>
00091 string name = CPath::lookup (filename, <span class="keyword">false</span>, <span class="keyword">false</span>);
00092 <span class="keywordflow">if</span> (name.empty())
00093 name = <a class="code" href="a05377.html#a2">filename</a>;
00094 <a class="code" href="a02653.html">CIFile</a> <a class="code" href="a04115.html#a95">file</a>;
00095 <span class="keywordflow">if</span> (<a class="code" href="a04115.html#a95">file</a>.open (name))
00096 {
00097 <span class="comment">// Init an xml stream</span>
00098 CIXml read;
00099 read.init (file);
00100
00101 <span class="comment">// Read the type</span>
00102 <a class="code" href="a04223.html#a581">type</a>->read (read.getRootNode ());
00103 }
00104 <span class="keywordflow">else</span>
00105 {
00106 <span class="comment">// Output error</span>
00107 <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoaderd0">warning</a> (<span class="keyword">false</span>, <span class="stringliteral">"loadType"</span>, <span class="stringliteral">"Can't open the form file (%s)."</span>, filename);
00108
00109 <span class="comment">// Delete the type</span>
00110 <span class="keyword">delete</span> <a class="code" href="a04223.html#a581">type</a>;
00111 <a class="code" href="a04223.html#a581">type</a> = NULL;
00112 }
00113 }
00114 <span class="keywordflow">catch</span> (<a class="code" href="a02482.html">Exception</a> &e)
00115 {
00116 <span class="comment">// Output error</span>
00117 <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoaderd0">warning</a> (<span class="keyword">false</span>, <span class="stringliteral">"loadType"</span>, <span class="stringliteral">"Error while loading the form (%s): %s"</span>, filename, e.what());
00118
00119 <span class="comment">// Delete the type</span>
00120 <span class="keyword">delete</span> <a class="code" href="a04223.html#a581">type</a>;
00121 <a class="code" href="a04223.html#a581">type</a> = NULL;
00122 }
00123
00124 <span class="comment">// Loaded ?</span>
00125 <span class="keywordflow">if</span> (<a class="code" href="a04223.html#a581">type</a>)
00126 {
00127 <span class="comment">// Insert a new entry</span>
00128 <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoaderr2">_MapType</a>[lowerStr]= <a class="code" href="a04223.html#a581">type</a>;
00129 ite = <a class="code" href="a02558.html#NLGEORGES_1_1CFormLoaderr2">_MapType</a>.find (lowerStr);
00130 <span class="comment">//CType *typeType = ite->second;</span>
00131 <span class="comment">// int toto = 0;</span>
00132 }
00133 <span class="keywordflow">return</span> <a class="code" href="a04223.html#a581">type</a>;
00134 }
00135 }
</pre></div> </td>
</tr>
</table>
<a class="anchor" name="NLGEORGES_1_1UFormLoadere1" doxytag="NLGEORGES::CFormLoader::releaseLoader" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void NLGEORGES::UFormLoader::releaseLoader </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top"><a class="el" href="a02559.html">UFormLoader</a> * </td>
<td class="mdname1" valign="top" nowrap> <em>loader</em> </td>
<td class="md" valign="top"> ) </td>
<td class="md" nowrap><code> [static, inherited]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Create a form loader.
<p>
<p>
Definition at line <a class="el" href="a05730.html#l00060">60</a> of file <a class="el" href="a05730.html">form_loader.cpp</a>.
<p>
Referenced by <a class="el" href="a05465.html#l00358">NLSOUND::CAudioMixerUser::init()</a>, and <a class="el" href="a05926.html#l00145">loadForm()</a>.
<p>
<div class="fragment"><pre>00061 {
00062 <span class="keyword">delete</span> ((CFormLoader*)loader);
00063 }
</pre></div> </td>
</tr>
</table>
<a class="anchor" name="NLGEORGES_1_1CFormLoaderd0" doxytag="NLGEORGES::CFormLoader::warning" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void NLGEORGES::CFormLoader::warning </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">bool </td>
<td class="mdname" nowrap> <em>exception</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const char * </td>
<td class="mdname" nowrap> <em>function</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>const char * </td>
<td class="mdname" nowrap> <em>format</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td></td>
<td class="md" nowrap>... </td>
<td class="mdname" nowrap></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"> const<code> [private, virtual]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
<p>
Definition at line <a class="el" href="a05730.html#l00316">316</a> of file <a class="el" href="a05730.html">form_loader.cpp</a>.
<p>
References <a class="el" href="a05646.html#l00649">buffer</a>, <a class="el" href="a05646.html#l01016">format</a>, and <a class="el" href="a05724.html#l00045">NLGEORGES::warning()</a>.
<p>
Referenced by <a class="el" href="a05730.html#l00205">loadForm()</a>, <a class="el" href="a05730.html#l00139">loadFormDfn()</a>, and <a class="el" href="a05730.html#l00069">loadType()</a>.
<p>
<div class="fragment"><pre>00317 {
00318 <span class="comment">// Make a buffer string</span>
00319 va_list args;
00320 va_start( args, format );
00321 <span class="keywordtype">char</span> <a class="code" href="a04223.html#a589">buffer</a>[1024];
00322 vsnprintf( buffer, 1024, format, args );
00323 va_end( args );
00324
00325 <span class="comment">// Set the warning</span>
00326 <a class="code" href="a05374.html#a0">NLGEORGES::warning</a> (exception, <span class="stringliteral">"(CFormLoader::%s) : %s"</span>, function, buffer);
00327 }
</pre></div> </td>
</tr>
</table>
<hr><h2>Field Documentation</h2>
<a class="anchor" name="NLGEORGES_1_1CFormLoaderr0" doxytag="NLGEORGES::CFormLoader::_MapForm" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="a02558.html#NLGEORGES_1_1CFormLoadery1">TFormMap</a> <a class="el" href="a02558.html#NLGEORGES_1_1CFormLoaderr0">NLGEORGES::CFormLoader::_MapForm</a><code> [private]</code>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
<p>
Definition at line <a class="el" href="a05731.html#l00078">78</a> of file <a class="el" href="a05731.html">form_loader.h</a>.
<p>
Referenced by <a class="el" href="a05730.html#l00205">loadForm()</a>. </td>
</tr>
</table>
<a class="anchor" name="NLGEORGES_1_1CFormLoaderr1" doxytag="NLGEORGES::CFormLoader::_MapFormDfn" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="a02558.html#NLGEORGES_1_1CFormLoadery0">TFormDfnMap</a> <a class="el" href="a02558.html#NLGEORGES_1_1CFormLoaderr1">NLGEORGES::CFormLoader::_MapFormDfn</a><code> [private]</code>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
<p>
Definition at line <a class="el" href="a05731.html#l00075">75</a> of file <a class="el" href="a05731.html">form_loader.h</a>.
<p>
Referenced by <a class="el" href="a05730.html#l00139">loadFormDfn()</a>. </td>
</tr>
</table>
<a class="anchor" name="NLGEORGES_1_1CFormLoaderr2" doxytag="NLGEORGES::CFormLoader::_MapType" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="a02558.html#NLGEORGES_1_1CFormLoadery2">TTypeMap</a> <a class="el" href="a02558.html#NLGEORGES_1_1CFormLoaderr2">NLGEORGES::CFormLoader::_MapType</a><code> [private]</code>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
<p>
Definition at line <a class="el" href="a05731.html#l00072">72</a> of file <a class="el" href="a05731.html">form_loader.h</a>.
<p>
Referenced by <a class="el" href="a05730.html#l00069">loadType()</a>. </td>
</tr>
</table>
<hr>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="a05731.html">form_loader.h</a><li><a class="el" href="a05730.html">form_loader.cpp</a></ul>
<hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 12:45:16 2004 for NeL by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 >
</a>1.3.6 </small></address>
</body>
</html>
|