1This is xparam.info, produced by makeinfo version 4.1 from
2/tmp/linuxdoc-dir-24148/sgmltmp.xparam.info.2.
3
4   \input texinfo
5
6
7File: xparam.info,  Node: Installation in Unix,  Next: Installation in Windows,  Up: Installing XParam
8
9Installation in Unix
10====================
11
12   * The XParam source files are available in the file
13     `xparam-1.22.tar.gz'.  Use `tar zxvf xparam-1.22.tar.gz' to
14     uncompress and untar this file to where you want it. We will
15     assume you put the XParam files under `/usr/local/src/'.
16
17   * The XParam files are under four main directories. Under `lib' you
18     will find the code for building the library itself.  Under
19     `examples' you will find example programs using XParam. Under
20     `tests' you will find regression testing code. Under `doc' you
21     will find the library's html documentation, including this file.
22     The tar file only contains sources for building the library,
23     example code and regression testing code, and does not by itself
24     contain the executables or the linkable library. Building XParam,
25     according to the instructions given below, will create these
26     executables and library code.
27
28   * XParam uses autoconf. Run './configure' from the main directory to
29     create the library's Makefile, then run 'make install' from the
30     main directory to build the library and install it. (Using 'make'
31     will build the library, but will not install it.) 'make check'
32     will run regression testing. 'make examples' will compile the
33     example code.  'make check' and 'make examples' will only work
34     after the library is installed.
35
36   * Set environment variable XPARAM_CLASSPATH to include all
37     directories where you want XParam to search for its '.xpn' files
38     (separated by colons).  To run the example programs, you will need
39     this path to include
40     `/usr/local/src/xparam-1.22/examples/classpath' (or the equivalent
41     to reach the `examples/classpath' subdirectory in the
42     distribution, if you untarred XParam in a directory other than
43     `/usr/local/src').
44
45   * The standard XParam installation places the file `libxparam.so'
46     under `/usr/local/lib', the XParam header files xparam.h and
47     xparam_extend.h under `/usr/local/include', and the rest of
48     XParam's include files (which are never used directly) under
49     `/usr/local/include/xparam'. Use the './configure' directive
50     '-disable-priv-includes' if you want to install all include files
51     in the same directory, or '-enable-priv-includes[=path]' to
52     install the private include files to a relative path other than
53     'xparam'.
54
55   * Use the './configure' directive '-disable-dynamic' if you wish to
56     have the dynamic loading feature disabled. This will only affect
57     your system if it has dynamic loading support. Otherwise, this
58     feature will be automatically disabled.
59
60   * If, for some reason, you do not want XParam to be useable until a
61     certain point in your program, use -enable-explicit-init. This
62     will cause XParam not to work before a call to xparam_init().
63     Otherwise, XParam registrations will all be executed on the first
64     use of XParam in the program.  This option is particularly useful
65     if you are concerned that someone might use XParam before
66     "main()", when you can not be sure that all registrations have
67     already been initiated. Typically, xparam_init() will be the first
68     line of your "main()".
69
70   * XParam's configuration can make use of environment variables such
71     as LDFLAGS, CPPFLAGS and CXXFLAGS, in the normal way. However, by
72     default, it does not set the -O2 and -g flags in CXXFLAGS, even if
73     your compiler supports them. This is because neither speed
74     optimization nor debug information is usually important for the
75     XParam user. (After all, this is an I/O package.) On the other
76     hand, these flags can slow down compilation considerably. To
77     override this default behavior, and have XParam turn on the -O2
78     and -g flags if they are available, use '-enable-cxxflags' when
79     running './configure'.
80
81   * The examples subdirectory of XParam can be configured separately
82     from the rest of the package. It is equipped with its own
83     configure script.  It can be executed using "examples/configure".
84     By default, configuring the package also configures the examples
85     subdirectory, using equivalent parameters. If you want to
86     configure the library without configuring its examples, use the
87     ./configure option -disable-config-examples.
88
89   * Make sure that the directory where you installed the XParam library
90     is a trusted directory for loading shared objects. (See "man
91     ldconfig" for details.)
92
93   * If, while running 'make install', environment variable DESTDIR is
94     set, XParam will install to that directory. That is, any file that
95     is meant to be installed to the directory /X will, instead, be
96     installed to DESTDIR/X.  This is useful for checking XParam's
97     installation without actually installing.  Running 'make check'
98     with DESTDIR still set to the same value will run the XParam tests
99     on the copy of the installation based in DESTDIR. Note that
100     installing with DESTDIR causes no 'ldconfig' command to be
101     executed.  (See ldconfig's documentation for details.) If you
102     install to DESTDIR, you should subsequently copy all files created
103     in DESTDIR's subdirectory to their proper places and run ldconfig
104     to complete the installation.  This is not necessary when
105     installing directly to the final destination.
106
107   * You have now finished the installation of XParam. All the usage
108     instructions are in the `doc' library, including how to run the
109     programs under `examples' to verify that the installation was
110     successful.
111
112
113File: xparam.info,  Node: Installation in Windows,  Next: Making Changes,  Prev: Installation in Unix,  Up: Installing XParam
114
115Installation in Windows
116=======================
117
118   * The XParam source files are available in the file
119     `xparam-1.22.tar.gz'.  Use WinZip or similar utility to uncompress
120     and untar this file to where you want it.
121
122   * The XParam files are under four main directories. Under `lib' you
123     will find the code for building the library itself.  Under
124     `examples' you will find example programs using XParam. Under
125     `tests' you will find regression testing code. Under `doc' you
126     will find the library's html documentation, including this file.
127     The tar file only contains sources for building the library,
128     example code and regression testing code, and does not by itself
129     contain the executables or the linkable library. Building XParam,
130     according to the instructions given below, will create these
131     executables and library code.
132
133   * Load the workspace file `xparam.dsw' (for Visual C++ 6.0).  It
134     contains all the projects and settings for compiling the XParam
135     library and examples with Visual C++ 6.0 - just run the `build'
136     command on your selected project.  When you want to create your
137     own project using XParam, you should make the following project
138     settings:
139        * Turn on RTTI (Under the `C/C++' tab, `C++ Language' category)
140
141        * Add the include directory for XParam's include files (Under
142          the `C/C++' tab, `Preprocessor' category, `Additional include
143          directories' field). You should enter here the directory
144          `lib/xparam' in the XParam distribution.
145
146        * Link with the XParam library. To do this go to the `Link' tab,
147          `input' category. Add `xparam.lib' at the end of the field
148          `Object/library modules', and add the path to the XParam
149          library in the `Additional library path' field (If you've
150          used the supplied project settings to compile the library,
151          this entry should be `lib/bin' relative to the root of the
152          XParam distribution).
153
154   * If your non-Unix compiler is not Visual C++, there may be certain
155     features that XParam uses that your compiler might not support.
156     Consult the XParam header file `xp_config.h' in order to decide on
157     the correct compilation flags that will make XParam work around
158     the missing features.
159
160   * You have now finished the installation of XParam. All the usage
161     instructions are in the `doc' library, including how to run the
162     programs under `examples' to verify that the installation was
163     successful.
164
165
166File: xparam.info,  Node: Making Changes,  Prev: Installation in Windows,  Up: Installing XParam
167
168Making Changes
169==============
170
171   All that was said above refers to the library's ready-to-compile
172sources.  If you want to make changes in these sources, you should take
173the following into account:
174   * The XParam parser and lexer were written using a parser generator
175     called ANTLR. The descriptions of the parser and lexer appear
176     under directory `lib/meta_sources/*.g'. In order to re-create the
177     parser, you must first install ANTLR. ANTLR is freeware, available
178     from www.antlr.org.  ANTLR is written in Java, so you must also
179     have Java installed, in order to run it.
180
181   * Use `lib/meta_sources/update_parsers.pl' to run ANTLR, because
182     XParam has to tweak the ANTLR output before it can use the files.
183
184   * XParam's ready-to-compile version can handle constructors of only
185     up to 13 parameters. If you wish to exceed this limit, simply run
186     `lib/meta_sources/ctor_code_gen.pl' with the upper limit you
187     desire as a parameter. (See `README.txt', in the same directory
188     for further details.)
189
190   * The `.pl' files in `lib/meta_sources' are Perl files.  In order to
191     run them, you must have a Perl interpreter installed.
192
193   * If you write any patch, bug-fix or extension to XParam, make sure
194     you send us a copy. Simply `diff' your version with ours, and send
195     the resulting patch-file to the tracker at
196     `xparam.sourceforge.net'.
197
198
199File: xparam.info,  Node: Usage Examples,  Next: Frequently Asked Questions,  Prev: Installing XParam,  Up: Top
200
201Usage Examples
202**************
203
204* Menu:
205
206* Intro to the Examples::
207* Simple Example::
208* Involved Example::
209* Calculator Example::
210
211
212File: xparam.info,  Node: Intro to the Examples,  Next: Simple Example,  Up: Usage Examples
213
214Intro to the Examples
215=====================
216
217   The following sections describe three examples of XParam programs in
218order of increasing sophistication. The full compileable sources and
219run-able binaries can be found in the "examples" directory of the
220XParam distribution. If you've installed the xparam-devel RPM, you will
221find these examples in a tar ball, in the same directory as this
222documentation.
223
224   The files referenced by this HTML have been abbreviated, for
225clarity, by omitting a large part of the license notice at the beginning
226of each. The code, however, is still protected by the same license as
227the rest of XParam. Other than this change, the files are identical to
228those used in the actual working code.
229
230
231File: xparam.info,  Node: Simple Example,  Next: Involved Example,  Prev: Intro to the Examples,  Up: Usage Examples
232
233Simple Example
234==============
235
236   This little C++ program demonstrates a very simple usage of XParam.
237It asks for two inputs, an integer called "num" and a string called
238"name". "num" is a number you're guessing; "name" is your name. The
239program reads this input from the command line. Next it reads an
240integer from the file my_number.txt (doc_examples/my_number.txt) and
241sees whether you guessed too high or too low. Finally, the program
242outputs "my_number" as a ParamSet, in the format recognizeable by other
243XParam programs, which is also human-readable.
244
245   You can execute this program with no parameters, and will receive
246the reply that "num" is a required parameter. You can input "num" only,
247in which case the program will enter the default name: "John Doe", or
248you can enter both parameters. You can also execute this program with
249the help-request option:
250
251          ~> simple !
252
253   for example, and this will give you all the parameter information.
254
255   One particularly amusing way to execute this program is by using
256
257          ~> simple num=@my_number.txt
258
259   This will redirect "num" to be read from "my_number.txt", which, of
260course, will lead to your number being exactly correct.
261
262   The full code can be found in simple.cpp (doc_examples/simple.cpp).
263
264
265File: xparam.info,  Node: Involved Example,  Next: Calculator Example,  Prev: Simple Example,  Up: Usage Examples
266
267Involved Example
268================
269
270   A more involved example is the example of initializing an entire
271drawing, using a polymorphic Shape pointer. This example is given in
272involved.cpp (doc_examples/involved.cpp).  The generic shape interface
273is given in shapes.h (doc_examples/shapes.h) and its implementation is
274in shapes.cpp (doc_examples/shapes.cpp). The interface is registered in
275reg_shapes.cpp (doc_examples/reg_shapes.cpp).
276
277   You can execute this program using
278
279          ~> bin/involved @data/my_shape.txt
280
281   This will load the shape information from the file my_shape.txt
282(doc_examples/my_shape.txt).  The shape information itself uses class
283"Circle", which has not been defined in "shapes.h". Consequently,
284XParam will dynamically load the dynamic link library that was compiled
285from the files circle.cpp (doc_examples/circle.cpp) and reg_circle.cpp
286(doc_examples/reg_circle.cpp) (the command to do so is in circle.xpn
287(doc_examples/circle.xpn)).  These files implement and register the
288circle class, whose interface appears in circle.h
289(doc_examples/circle.h).
290
291   This program demonstrates parameter passing with user-defined
292classes and dynamic loading. For it to work, you must make sure that
293environment variable XPARAM_CLASSPATH is set, and that the path of
294circle.xpn (doc_examples/circle.xpn) appears in it.
295
296   Note: XParam does not currently support dynamic loading in Windows,
297so for the example to work in Windows you will have to link in the
298files circle.cpp (doc_examples/circle.cpp) and reg_circle.cpp
299(doc_examples/reg_circle.cpp) statically.
300
301
302File: xparam.info,  Node: Calculator Example,  Prev: Involved Example,  Up: Usage Examples
303
304Calculator Example
305==================
306
307   This program demonstrates an interactive usage of streams. The main
308program code appears in calculator.cpp (doc_examples/calculator.cpp).
309This is all the code you need to program a calculator in XParam,
310because all the parsing is done by XParam for you. However, you still
311need to program classes for the different arithmetic operations. These
312classes appear in functions.h (doc_examples/functions.h) and
313functions.cpp (doc_examples/functions.cpp).  They are registered into
314XParam in reg_functions.cpp (doc_examples/reg_functions.cpp).  With
315these files alone, this is already a functioning calculator.
316
317   However, we also wanted to demonstrate that the calculator is easily
318extendable. By adding the files mathfunc.h (doc_examples/mathfunc.h),
319reg_mathfunc.cpp (doc_examples/reg_mathfunc.cpp) and mathfunc.xpn
320(doc_examples/mathfunc.xpn) we managed to add two functions, "sqrt" and
321"ln", which are loaded dynamically when needed.
322
323   The program is a calculator, working on doubles, that supports the
324functions "add", "sub", "mul" and "div" (as well as "sqrt" and "ln").
325It reads its input as an input object stream from the standard input
326and outputs its output as an output object stream to the standard
327output. Errors go to the standard error. The calculator supports
328commands that look like this: "mul(5,add(4,2))". This input will cause
329it to output "30.0", because 5*(4+2)=30. The calculator also supports
330variables. use "def(var1,13)" to define "var1" to be "13".  Variable
331names are general strings. To use the variable, simply use its name:
332"sub(var1,8)" will output "5.0". To exit the calculator, simple
333truncate the input stream (^D in Unix or ^Z under Windows).
334
335   Another thing you can do is import an object, by using the
336redirection operator. A single object may contain many variable
337definitions. This is done by placing them between brackets. Use
338"@data/constants.dat" to import Pi and E from constants.dat
339(doc_examples/constants.dat), for example.
340
341   Calculator also demonstrates another use-case for paramsets. Though
342there is no command-line input needed for the calculator, it
343nevertheless uses a paramset to read the command line. This allows the
344calculator to give usage instructions with the "!" directive, as well
345as help on specific functions.
346
347   The main thing to note about the calculator is that no concessions
348had to be made regarding its interface (with the exception that it has
349to use functions instead of operators), because of the use of XParam.
350Correct design of the class hierarchy it uses makes it possible for you
351to write "15" and it to be accepted as a number, "max" and it to be
352accepted as a variable, "[ def(one,1), def(two,2) ]" and for that to be
353accepted as a list of definitions, a single redirection to import many
354variables, any format of double to be readable, usage of "div" and
355"sqrt", even though these are functions that already have a meaning in
356C++, and so on. On the output side, the interface provides output as
357soon as you finish writing an expression, it outputs a stream of XParam
358doubles, readable by other XParam-supporting programs, when you input a
359calculation, and nothing when you input a definition or a list of
360definitions - these were all design goals.
361
362   The class hierarchy in the calculator program makes XParam implicitly
363convert values to the type you need them in, in order for the user not
364to have to be at all aware of the existence of classes such as
365`ArithValue', `Expression' and `MultiDef'. She will only ever encounter
366them in error messages.
367
368
369File: xparam.info,  Node: Frequently Asked Questions,  Next: Conversion Rules,  Prev: Usage Examples,  Up: Top
370
371Frequently Asked Questions
372**************************
373
374   * `XParam is great, but I'm not sure if your license allows me to
375     use it in my product.'
376
377     Here's the good news: the XParam license doesn't restrict anybody
378     from using the library. If all you want is to link in with the
379     XParam library and/or include the XParam header files into your
380     program, then XParam's license does not restrict you at all. You
381     can use XParam in any program, including commercial, non-free,
382     products. You don't owe us money for it, nor even an
383     acknowledgement (though we generally think it would be a nice
384     thing if you'd mention us somewhere in the documentation).
385
386     XParam's license is GPL with an exemption. The exemption is that
387     programs are not considered derivative works of XParam simply
388     because they are linked in with the library. So, if that's all
389     you're doing, the license simply does not apply to you, and you're
390     free to do whatever you want. This is the case if you're a simple
391     user of the library, a programmer of XParam-using programs, or
392     even a registrator of new classes into XParam.
393
394     If, on the other hand, what you want to do is to add new features
395     to XParam, fix an XParam bug, make XParam work better, or do any
396     other activity that requires modification of the XParam source
397     files (which includes the cpp files, header files, parser files,
398     make files, project files, Perl scripts, etc., that come as part
399     of the XParam distribution), then you are creating a derivative
400     work of XParam, and that means that the XParam license binds you
401     as though it was GPL. Chiefly, this means that you must make the
402     new sources, with whatever changes you make, freely available
403     under a license that is at least as restrictive as the XParam
404     license. (Both GPL and LGPL fall under this category.) You must
405     note the fact that these are not the original sources, that you
406     are the one to change them, and where the original, unmodified
407     sources can be found.
408
409     The simplest way to do all this is to mail us the relevant patch
410     file (or its equivalent), and we'll do the rest. This can be done
411     through our SourceForge homepage.
412
413     We chose the XParam license after reviewing many alternative
414     licenses and finding them too restrictive. We wanted a license
415     that would allow everybody to use the library. We thank Richard
416     Stallman for pointing us to GNU's GUILE, that uses an analogous
417     license.
418
419   * `I've downloaded XParam, but I can't find the library anywhere.
420     What should I do?'
421
422     Up until version 1.21 of XParam, this library only had a source
423     distribution.  For this reason, when you downloaded it, you got
424     cpp files, header files, and virtually nothing that was compiled.
425     Certainly, there was no compiled library there to be found.  For
426     some downloaders, who are more familiar with precompiled packages,
427     such as RPMs, DEBs and the like, this came as something of a
428     surprise.
429
430     What you want to do with a source distribution is follow the
431     instructions given in the "Installing XParam" section of this
432     manual. They will tell you exactly how to get from the sources to
433     the binaries you want. You will, however, need to have some basic
434     tools, such as a C++ compiler, installed.
435
436     Starting version 1.21, XParam also comes with an RPM, so it is no
437     longer necessary to compile it on your computer. In the future, we
438     hope that more and more packages will make use of this RPM,
439     utilizing XParam as an I/O platform for their own packages. We
440     know of some such packages that are currently being developed.
441
442   * `XParam doesn't compile right for me: it complains that it doesn't
443     know what extract<T> and what make_value_copy<T> are, for a class
444     T that I wrote.'
445
446     See next question.
447
448   * `Oh, wait! I've figured out why it doesn't find extract and
449     make_value_copy. You forgot to #include "xpv_facade_imp.h"!'
450
451     If you get a linker error, complaining that XParam does not find
452     these two template functions, what your problem is likely to be,
453     is that you forgot to link some files in with your project.
454     Typically, you forgot to link in the files that register class T.
455
456     And, no. We didn't forget to include "xpv_facade_imp.h". The
457     program is supposed to compile, link and run perfectly without
458     this inclusion. If you try to put it in manually, you will only be
459     making things worse. The omission of this header file is a well
460     know trick, meant to speed up compilation. This is only supposed
461     to cause you trouble if your C++ compiler is extremely old, in
462     which case it will no doubt also lack several other features
463     needed by XParam.
464
465   * `XParam doesn't compile right for me: it complains that it doesn't
466     know what extract<T> and what make_value_copy<T> are, where T is a
467     standard C++/XParam class.'
468
469     Hmmm... If it's a standard class, this is a different problem
470     altogether.  It may be that you didn't link in all the source
471     files of the library when you built it in the first place, or that
472     the relevant function calls were omitted by your compiler.
473
474     One possible cause for this problem is that you have two different
475     versions of XParam on your computer, and are linking against a
476     different copy of the library than you intend. For example, you
477     may have downloaded a local copy of version 1.22, but are still
478     linking against your RPM of version 1.21. Use explicit link and
479     include paths to make sure you are compiling and linking with the
480     intended copy of the library.
481
482     If you've checked these possibilities already, and the problem
483     seems to be elsewhere, try compiling with -DXPARAM_STATIC_LIBRARY,
484     and if that doesn't work either, look at the file xp_config.h, and
485     see if there are other configuration options that may be
486     applicable in your case.
487
488     If the problem persists, tell us about it. Also contact us if you
489     found out that your compiler needs certain special tweaks to make
490     XParam run on it. If we can make these tweaks become part of the
491     package, we'll probably do so for the next release.
492
493   * `What kind of library are you selling here? I did everything just
494     like you said, and XParam still breaks on a Segmentation Fault as
495     soon as I try to use it!'
496
497     If you run XParam and it throws a segmentation fault at you, it's
498     probably because you forgot that XParam uses exceptions. Many
499     XParam functions, such as "xparam_init()" and "ParamSet::input()",
500     can and do throw exceptions, when they detect user errors.
501
502     If you neglect to surround XParam's calls in a "try" block, you
503     can very easily find yourself with an unhandled exception. Many
504     polite compilers exit from the program in such a case, notifying
505     the user of an unhandled exception.  Other, less polite compilers
506     simply make your program crash on a segmentation fault.
507
508     One of the features we want to add to XParam is a work mode in
509     which XParam errors will be reported by means other than
510     exceptions. (For example, you may want XParam to report errors on
511     the standard error stream, and exit from your program immediately
512     afterwards.) However, this is not currently supported, and we can
513     make no guarantees nor even time estimates regarding when such a
514     feature may be introduced.
515
516   * `XParam looks like a great library, and I'm trying to use it in
517     this project of mine, where I've got an inheritance hierarchy nine
518     classes deep, with multiple inheritance, abstract interfaces,
519     virtual inheritance, and conversions between map types over
520     structs and vector types over enums, and I can't get it to work.
521     Is it possible that XParam doesn't support these?'
522
523     Well, XParam does support all of these, but it takes a little time
524     and some practice registering classes before you get to the
525     proficiency level required to pull off something like this.
526
527     If you've successfully registered simple cases of all of the
528     above, there's no reason you shouldn't be able to register the
529     whole thing together. If, on the other hand, this is the first
530     time you've ever tried using XParam's registration, we suggest you
531     start with a few less ambitious experiments.
532
533     If you feel that you've tinkered with XParam long enough to know
534     that what you're trying should work and doesn't, do contact us and
535     we'll try to help.
536
537     Here's one tip: XParam's registrations may take considerable
538     amounts of heap memory to compile. If you've got many registration
539     calls you need to make, do your compiler a favor and split them
540     into several files.
541
542   * `Help! I installed XParam on a ### computer running an ###
543     operating system, with a ### compiler, and it doesn't compile
544     right/link right/install properly/the examples don't work/give me
545     lots of warning messages.'
546
547     We've tested XParam on several systems. These include several
548     generations of MSWindows (including several CygWin versions),
549     several generations of RedHat, several generations of Debian, one
550     Mandrake and one SolarisOS. We've also tried it on quite a few
551     different compilers. On gcc alone we started from the 2.9s and
552     have worked our way up to 3.2.
553
554     Of course, that's just the list of environments that we managed to
555     test in-house. Our install base likely spans many other
556     environments as well, and we've only received relatively few
557     reports about environments where XParam doesn't behave well.
558
559     One thing we've learnt about the C++ language is that no two
560     compilers share identical views about it, nor are there two
561     operating systems completely identical in their quirks. Generally
562     speaking, when you port XParam to a new environment, it may take a
563     little tweaking to make it run exactly right.  (It is, after all,
564     a very compiler intensive library.) However, on the whole, little
565     to no tweaking is all it generally takes. It never posed any
566     serious problems. Not even when we ported it originally from Linux
567     to Windows.
568
569     The XParam distribution comes with an elaborate autoconf script,
570     meant to work around the most common porting pitfalls, and we are
571     using libtool as a further means of making the transitions easier,
572     but neither of these systems is perfect.
573
574     If your operating system is not listed above, this is no reason to
575     assume it won't work there. Try it. If it works, let us know. If
576     it doesn't, let us know, too. If it originally didn't work, and
577     you found a way to work around the problem, this is doubly true.
578
579     As a general policy, we haven't written in XParam any piece of
580     code for which we have no means of testing. We know, for example,
581     that XParam's dynamic loading mechanism will probably not work
582     well on a Digital Alpha, because it was designed for a 32bit
583     operating system. We could have written the code, but had no way
584     of verifying that it actually works correctly. In all such cases,
585     we rely on you, the XParam developer, to help us make XParam work
586     on your favorite platform.
587
588   * `Is there any way to get XParam's documentation as a single HTML
589     file?'
590
591     XParam's HTML documentation usually comes separated into several
592     files. If, for some reason, it is important to you that the
593     documentation will consist of a single file, you can always opt to
594     use the SGML version of our documentation, which comes with the
595     XParam package and is also available for separate download from
596     our CVS (hosted by SourceForge).  It is an SGML file conforming to
597     the linuxdoc dtd.
598
599     If you must have the documentation in HTML form, you can always
600     produce it from the SGML. If you have SGML-Tools installed, the
601     command
602
603          sgml2html --split=0 xparam.sgml
604
605     will yield documentation in a single HTML file.
606
607     If linuxdoc converters are not available to you, you can also find
608     all of XParam's documentation, in formats ranging from single-file
609     HTMLs, through PostScript, to PDFs, in the "XParam-docs" tar file,
610     available for download from our SourceForge homepage.
611
612   * `There's this nifty feature that I really need XParam to support.
613     Can you put it in?'
614
615     See next question.
616
617   * `I want XParam to be able to solve my algebra homework. Are you
618     going to add this feature any time soon?'
619
620     As we mentioned before, we're programming as fast as we can, and
621     we can't predict when - or even if - any particular feature will
622     be added to XParam.  However, if you need any particular feature
623     from XParam, do let us know.  We might not start working on it
624     right away, but it will definitely boost its priority on our
625     worklist.
626
627     If you're just interested in getting a general glimpse of what's
628     planned in XParam's near future, you can take a look at the "help
629     XParam" page on our homepage and at the "TODO" file in the
630     distribution. We don't feel ourselves tied to either list, though,
631     so don't be surprised if items not on either list supercede other,
632     longstanding items.
633
634   * `How can I help XParam?'
635
636     XParam is an ongoing effort. If you look at the "help XParam" page
637     on our homepage, you'll get an idea of some of the things we're
638     planning on putting into XParam. We are programming these as fast
639     as we can, but any additional pair of hands will be invaluable
640     help to us.
641
642     If you want to help us, you can simply program any of the items on
643     the "help XParam" list (it's very diverse in the skills it
644     requires). Better yet, you can contact us and we'll figure out
645     together what subproject best suits your capabilities.
646
647     In fact, if you'll just program for youself the features that you
648     most need for XParam, and then send them to us, that will be
649     great. Most of the features XParam has today were programmed
650     because we needed them in our projects.
651
652
653
654File: xparam.info,  Node: Conversion Rules,  Next: Credits for Contributions to XParam,  Prev: Frequently Asked Questions,  Up: Top
655
656Conversion Rules
657****************
658
659* Menu:
660
661* Intro to the Conversion Rules::
662* The Weights::
663* Tentative Types::
664* List Comparisons::
665
666
667File: xparam.info,  Node: Intro to the Conversion Rules,  Next: The Weights,  Up: Conversion Rules
668
669Intro to the Conversion Rules
670=============================
671
672   In using XParam, it is common to utilize the fact that not all
673conversions must be explicitly requested. Often, XParam performs
674implicit conversions in order to execute a command.  The following is a
675description of XParam's implicit conversion rules.  It is not intended
676to be the definitive guide to the rules. Some rules may be a little
677more complex than they are presented here. This appendix is meant,
678however, to help you understand better why XParam chooses one
679conversion path over another, for this to assist you in controlling its
680behavior, whether as a user or as a registrator.
681
682
683File: xparam.info,  Node: The Weights,  Next: Tentative Types,  Prev: Intro to the Conversion Rules,  Up: Conversion Rules
684
685The Weights
686===========
687
688   As C++, XParam recognizes that not all conversions are alike.
689Certain conversions, such as one from `bool' to `int', look more
690appealing than others, such as from `double' to `int'.  This is
691expressed in the form of weights. The more weight a conversion carries,
692the less attractive it seems. XParam recognizes several basic weights:
693`CONV_EXACT'
694     a conversion between a type and itself. Its weight is essentially
695     zero.
696
697`CONV_PROMOTION'
698     a conversion from a `bool' to an `int' or from an `unsigned char'
699     to an `unsigned int'.
700
701`CONV_STANDARD'
702     any conversion between two built-in C++ types other than those
703     covered by CONV_PROMOTIONs and those involving type `char'.
704
705`CONV_TO_PARENT'
706     a conversion between a pointer to a base type and a pointer to its
707     parent type.
708
709`CONV_USER'
710     any conversion not covered by previous rules. This is the default
711     weight whenever a new conversion is registered by the user.
712
713   The weights are listed here in order of increasing weight. The
714difference in weight between any two is infinite, so, for example, a
715sequence of any number of CONV_TO_PARENT conversions is still
716considered more appealing than a single CONV_USER. Note that XParam does
717not consider a switch from an object to a pointer to bear any weight.
718
719   With the exception of value-lists, explained below, the weight of a
720conversion path is considered to be the sum of the weights of all
721conversions along it. No more than one CONV_USER is allowed on a
722conversion path.
723
724   XParam will always choose the lightest available conversion path.
725If no conversion path can be considered lightest (for example, if two
726conversion paths are exactly as good) then XParam will call this an
727ambiguity.
728
729   This is more or less how C++ evaluates conversions, too. The main
730difference is that, in XParam, all conversions between type `char' and
731other built-in C++ types (numeric types) must be specified explicitly.
732
733
734File: xparam.info,  Node: Tentative Types,  Next: List Comparisons,  Prev: The Weights,  Up: Conversion Rules
735
736Tentative Types
737===============
738
739   In C++, all explicit literal constants have a type. You specify
740strings by quotation marks, characters by apostrophes, single precision
741floating point decimals by a trailing 'f', and so on.
742
743   Because XParam works most commonly from the command-line, a more
744relaxed syntax is allowed in XParam to minimize the necessity of using
745characters that have meaning in Unix shell-parsing, such as quotations
746and apostrophes. For this reason, an assignment such as this:
747
748          my_parameter = 7
749
750   can be interpretted with the character `7' representing an explicit
751literal constant of type `int', `char' or even `std::string'. XParam
752resolves this ambiguity by use of "tentative types" and
753destination-driven type matching. In essence, what this means is that
754XParam checks what types of explicit literal constants are permitted in
755the given context (for example, by checking the type of `my_parameter')
756and then what types the given literal matches (in this case:
757`int',`char' and `std::string').  Of the remaining options, XParam
758chooses according to the following rules:
759   * A numeric type is preferable to a non-numeric type.
760
761   * A `char' is preferable to an `std::string'.
762
763   Remember that it is always possible to override these rules by
764explicitly specifying your desired type (for example, by adding
765quotation marks or apostrophes).
766
767
768File: xparam.info,  Node: List Comparisons,  Prev: Tentative Types,  Up: Conversion Rules
769
770List Comparisons
771================
772
773   List comparisons are different than scalar comparisons. Weighing
774them, in fact, looks very similar to the algorithm used by C++ (and
775XParam) to choose between overloaded functions and methods.
776
777   When choosing between "func(int,int)" and "func(long,long)" when
778receiving an input, for example "func(3,5L)", C++ weighs each element
779separately, so the distance from "func(3,5L)" to "func(int,int)" is
780(CONV_EXACT, CONV_STANDARD), and the distance from "func(3,5L)" to
781"func(long,long)" is (CONV_STANDARD, CONV_EXACT). Now, we must
782determine which of these possibilities is better. The way to do it is
783to go element by element and compare. If one option is at-least as good
784as any other option in all elements, and better than all other options
785in at least one element, then it is considered the best. If two options
786are exactly as good in all elements, then the two options are
787considered to be as good, as a whole.  If, on the other hand, as is the
788case here, when comparing two options there is an element that is
789better in one and another element that is better in the other, then the
790two options are considered incomparable. If asked to choose between
791them, both C++ and XParam will determine that this is an ambiguity.
792
793   XParam takes this element-by-element approach in lists, as well.  If
794`school', for example, is a class that can be constructed from a vector
795of integers or from a vector of `fish', and the initialization line is
796"elementary=[ 4L, 5L ]", where "elementary" is a variable of type
797`school', then XParam must now choose between converting "[4L, 5L]",
798element by element, into a list of integers, "[4, 5]", which can be
799converted into an `std::vector<int>', and converting the "[4L, 5L]",
800element-by-element, into a list of `fish', "[fish(4L), fish(5L)]", and
801from there to a `std::vector<fish>'.
802
803   Supposing class `fish' has a constructor from `long', then the first
804option weighs (CONV_STANDARD, CONV_STANDARD) and the second option
805weighs (CONV_USER, CONV_USER). Therefore, XParam will choose going
806through a vector of integers.
807
808   Let's, however, make this example more complicated. What if
809"elementary" was not of type `school' but of type `school*', and
810`school' was a parent class to `public_school*', and, furthermore, that
811it is not `school' that has a constructor from a vector of integers but
812`public_school'?
813
814   If we sort through all the details, we'll find that XParam must now
815choose between two paths:
816
817   untyped list -> list of `fish' -> `std::vector<fish>' -> `school'
818
819   and
820
821   untyped list -> list of `int' -> `std::vector<int>' ->
822`public_school' -> `school'
823
824   We know that it is easier to go from our list to a vector of
825integers than it is to go to a vector of `fish'. However, once we get
826there, it weighs more to go from integers to `school*' than it is from
827`fish' to `school*'. Which will XParam choose? The rule is that any
828conversions that are done after an HVL-to-class conversion bare a
829negligent weight compared to what is done prior to the conversion.  So,
830in this case, XParam will still decide to go through
831`std::vector<int>'. If the two conversions, until the switch from HVL
832to vector, had been uncomparable, then the entire paths would have been
833uncomparable. Only if the two conversion paths had been of equivalent
834weights until the switch from HVL to vector, the weights of the latter
835part of the conversion path would have had effect.
836
837
838File: xparam.info,  Node: Credits for Contributions to XParam,  Prev: Conversion Rules,  Up: Top
839
840Credits for Contributions to XParam
841***********************************
842
843   XParam was programmed by Ronnie Maor <`maor@operamail.com'> and
844Michael Brand <`mb_xp@xparam.mailshell.com'>.
845
846   Substantial intellectual contributions were made by Erez Louidor and
847Aaron Brand.
848
849   The XParam RPM package was prepared by Shachar Shemesh.
850
851   The XParam parser was written using the ANTLR parser generator. This
852parser is freeware. See the ANTLR homepage (http://www.antlr.org/) for
853further details about ANTLR.  The ANTLR project leader is Terrance
854Parr, and the C++ version of ANTLR was mainly written by Peter Wells
855and Ric Klaren.
856
857
858